<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div><span>I think I've got a handle on this now. As you said, xb4 spirals out of control, so there are a couple of clamping factors that reduce xb4, hopefully below a threshold where it is stable.</span></div><div><br><span></span></div><div><span>It is of course, unstable if the frequency is &lt;0 or &gt;1 (where 1 is the Nyquist frequency) but there is a "safe" mode<br></span></div><div><br><span></span></div><div><span>I'm going to give it a try with this filter and see if any of my colleagues can break it :)</span></div><div><br><span></span></div><div><span>Ed<br></span></div><div>&nbsp;</div><div>Gemnotes-0.1alpha: Live music notation for Pure Data<br>http://sharktracks.co.uk/<br></div>  <div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"> <div style="font-family: times new roman,new
 york,times,serif; font-size: 12pt;"> <div dir="ltr"> <font face="Arial" size="2"> <hr size="1">  <b><span style="font-weight: bold;">From:</span></b> Peter Brinkmann &lt;peter.brinkmann@googlemail.com&gt;<br> <b><span style="font-weight: bold;">To:</span></b> Ed Kelly &lt;morph_2016@yahoo.co.uk&gt; <br><b><span style="font-weight: bold;">Cc:</span></b> PD List &lt;pd-list@iem.at&gt; <br> <b><span style="font-weight: bold;">Sent:</span></b> Saturday, 24 March 2012, 15:08<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [PD] [PD-dev] Filter design for iPhone<br> </font> </div> <br>On Sat, Mar 24, 2012 at 5:20 AM, Ed Kelly &lt;<a ymailto="mailto:morph_2016@yahoo.co.uk" href="mailto:morph_2016@yahoo.co.uk">morph_2016@yahoo.co.uk</a>&gt; wrote:<br>&gt; My mistake<br>&gt;<br>&gt;&gt; Ah.<br>&gt;&gt; As often happens, as soon as I have pressed "send" and posted the<br>&gt;&gt; question, the answer pops out.<br>&gt;&gt; xb4 = xb4 - xb4 * xb4 *
 xb4 * 0.166667f;<br>&gt;&gt;<br>&gt;&gt; is replaced by...<br>&gt;&gt;<br>&gt;&gt; xb4 = xb4 - xb4 * xb4 * xb4 * 0.01f;<br>&gt;&gt;<br>&gt;&gt; ...and it works.<br>&gt;<br>&gt; and then breaks again<br><br>Inf - Inf is NaN.&nbsp; If the value of xb4 spirals out of control, that<br>may happen here.&nbsp; That would also explain why it takes longer to fail<br>when you reduce the last factor.<br><br>&gt;<br>&gt; Gemnotes-0.1alpha: Live music notation for Pure Data<br>&gt; <a href="http://sharktracks.co.uk/" target="_blank">http://sharktracks.co.uk/</a><br>&gt; ________________________________<br>&gt; From: Ed Kelly &lt;<a ymailto="mailto:morph_2016@yahoo.co.uk" href="mailto:morph_2016@yahoo.co.uk">morph_2016@yahoo.co.uk</a>&gt;<br>&gt; To: Mathieu Bouchard &lt;<a ymailto="mailto:matju@artengine.ca" href="mailto:matju@artengine.ca">matju@artengine.ca</a>&gt;<br>&gt; Cc: PD List &lt;<a ymailto="mailto:pd-list@iem.at"
 href="mailto:pd-list@iem.at">pd-list@iem.at</a>&gt;; Joe White &lt;<a ymailto="mailto:joe@rjdj.me" href="mailto:joe@rjdj.me">joe@rjdj.me</a>&gt;; pddev &lt;<a ymailto="mailto:pd-dev@iem.at" href="mailto:pd-dev@iem.at">pd-dev@iem.at</a>&gt;<br>&gt; Sent: Saturday, 24 March 2012, 8:47<br>&gt; Subject: Re: [PD-dev] [PD] Filter design for iPhone<br>&gt;<br>&gt;&gt;&gt; I'm anxious to know what limit is reached in the coefficients of the<br>&gt;&gt;&gt; filter that causes the undefined result (NaN).<br>&gt;&gt;<br>&gt;&gt;I haven't seen the code, but I just want to make you notice that adding<br>&gt;&gt; together -Infinity and +Infinity results in a NaN&nbsp;; so does subtracting<br>&gt;&gt;two infinities of the same sign.<br>&gt;&gt;<br>&gt;&gt;So, the NaN might happen when two expressions that are supposed to<br>&gt;&gt; partially cancel each other, happen to both overflow, in different<br>&gt;&gt; directions.<br>&gt;&gt;<br>&gt;&gt;There are various
 possible causes for NaN, but with formulas that only<br>&gt;&gt; involve +, - and *, the possibilities are a lot more limited.<br>&gt;<br>&gt; Hmmm.<br>&gt; I think that's why it puzzles me so. Can you see a / anywhere here?<br>&gt;<br>&gt; &nbsp; while (n--) {<br>&gt; &nbsp;&nbsp;&nbsp; i1=(*in++);<br>&gt; &nbsp;&nbsp;&nbsp; fc1 = (*fc++);<br>&gt; &nbsp;&nbsp;&nbsp; res1 = (*res++);<br>&gt; &nbsp;&nbsp;&nbsp; q = 1.0f - fc1;<br>&gt; &nbsp;&nbsp;&nbsp; p = fc1 + 0.8f * fc1 * q;<br>&gt; &nbsp;&nbsp;&nbsp; fcoeff = p + p - 1.0f;<br>&gt; &nbsp;&nbsp;&nbsp; q = res1 * (1.0f + 0.5f * q * (1.0f - q + 5.6f * q * q));<br>&gt; &nbsp;&nbsp;&nbsp; i1 -= q * xb4;<br>&gt; &nbsp;&nbsp;&nbsp; t1 = xb1;<br>&gt; &nbsp;&nbsp;&nbsp; xb1 = (i1 + xb0) * p - xb1 * fcoeff;<br>&gt; &nbsp;&nbsp;&nbsp; t2 = xb2;<br>&gt; &nbsp;&nbsp;&nbsp; xb2 = (xb1 + t1) * p - xb2 * fcoeff;<br>&gt; &nbsp;&nbsp;&nbsp; t1 = xb3;<br>&gt; &nbsp;&nbsp;&nbsp; xb3 = (xb2 + t2) * p - xb3 *
 fcoeff;<br>&gt; &nbsp;&nbsp;&nbsp; xb4 = (xb3 + t1) * p - xb4 * fcoeff;<br>&gt; &nbsp;&nbsp;&nbsp; xb4 = xb4 - xb4 * xb4 * xb4 * 0.166667f;<br>&gt; &nbsp;&nbsp;&nbsp; xb0 = i1;<br>&gt; &nbsp;&nbsp;&nbsp; *out++ = xb4;<br>&gt; &nbsp;}<br>&gt;<br>&gt; No reciprocals, no divisions, just +,-,*.<br>&gt; I cannot help thinking I must be reaching a "limit" in the calculus sense...<br>&gt;<br>&gt; Ed<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt; ______________________________________________________________________<br>&gt; | Mathieu BOUCHARD ----- téléphone&nbsp;: +1.514.383.3801 ----- Montréal, QC<br>&gt;<br>&gt;<br>&gt; _______________________________________________<br>&gt; Pd-dev mailing list<br>&gt; <a ymailto="mailto:Pd-dev@iem.at" href="mailto:Pd-dev@iem.at">Pd-dev@iem.at</a><br>&gt; <a href="http://lists.puredata.info/listinfo/pd-dev" target="_blank">http://lists.puredata.info/listinfo/pd-dev</a><br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt;
 _______________________________________________<br>&gt; <a ymailto="mailto:Pd-list@iem.at" href="mailto:Pd-list@iem.at">Pd-list@iem.at</a> mailing list<br>&gt; UNSUBSCRIBE and account-management -&gt;<br>&gt; <a href="http://lists.puredata.info/listinfo/pd-list" target="_blank">http://lists.puredata.info/listinfo/pd-list</a><br>&gt;<br><br><br> </div> </div>  </div></body></html>