<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Fibonacci and filter</title>
	<atom:link href="http://blogs.mathworks.com/loren/2006/05/17/fibonacci-and-filter/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.mathworks.com/loren/2006/05/17/fibonacci-and-filter/</link>
	<description>Loren Shure works on design of the MATLAB language at MathWorks. She writes here about once a week on MATLAB programming and related topics.</description>
	<lastBuildDate>Thu, 09 Feb 2012 04:19:21 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2006/05/17/fibonacci-and-filter/#comment-26570</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Fri, 22 Feb 2008 11:31:38 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=37#comment-26570</guid>
		<description>POONKODI-

It just calls it twice.  The first call completes (recursion and all) before the second one gets called.  This version of recursion is quite wasteful since it doesn&#039;t store and therefore use values that have been previously calculated.

--Loren</description>
		<content:encoded><![CDATA[<p>POONKODI-</p>
<p>It just calls it twice.  The first call completes (recursion and all) before the second one gets called.  This version of recursion is quite wasteful since it doesn&#8217;t store and therefore use values that have been previously calculated.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: POONKODI.S</title>
		<link>http://blogs.mathworks.com/loren/2006/05/17/fibonacci-and-filter/#comment-26568</link>
		<dc:creator>POONKODI.S</dc:creator>
		<pubDate>Fri, 22 Feb 2008 03:52:16 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=37#comment-26568</guid>
		<description>hi Loren,
I just wanted to kmow how matlab calls the recursive function when it is repeated twice as in fibonacci series???</description>
		<content:encoded><![CDATA[<p>hi Loren,<br />
I just wanted to kmow how matlab calls the recursive function when it is repeated twice as in fibonacci series???</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: joe bloggs</title>
		<link>http://blogs.mathworks.com/loren/2006/05/17/fibonacci-and-filter/#comment-25954</link>
		<dc:creator>joe bloggs</dc:creator>
		<pubDate>Fri, 08 Feb 2008 14:49:23 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=37#comment-25954</guid>
		<description>thankyou for the help, it allowed me to cheat!</description>
		<content:encoded><![CDATA[<p>thankyou for the help, it allowed me to cheat!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: erik</title>
		<link>http://blogs.mathworks.com/loren/2006/05/17/fibonacci-and-filter/#comment-14787</link>
		<dc:creator>erik</dc:creator>
		<pubDate>Wed, 15 Nov 2006 20:29:25 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=37#comment-14787</guid>
		<description>hey loren-
i am interested to hear what you or steve think about the idea of matlab supporting gpgpu (using the stream processing hardware of modern video cards to perform vector/matrix operations up to 50 times faster than on the cpu) from matlab.  obvious example related to your article: filtering/fft.  wired has a great story on recent exciting results in this field:
http://www.wired.com/news/technology/computers/0,72090-0.html?tw=wn_index_16 

(i&#039;m not sending to steve because most of the image processing blog is over my head, so i don&#039;t keep up with it  -- but it seems like that community would also be very interested.)
-erik</description>
		<content:encoded><![CDATA[<p>hey loren-<br />
i am interested to hear what you or steve think about the idea of matlab supporting gpgpu (using the stream processing hardware of modern video cards to perform vector/matrix operations up to 50 times faster than on the cpu) from matlab.  obvious example related to your article: filtering/fft.  wired has a great story on recent exciting results in this field:<br />
<a href="http://www.wired.com/news/technology/computers/0,72090-0.html?tw=wn_index_16" rel="nofollow">http://www.wired.com/news/technology/computers/0,72090-0.html?tw=wn_index_16</a> </p>
<p>(i&#8217;m not sending to steve because most of the image processing blog is over my head, so i don&#8217;t keep up with it  &#8212; but it seems like that community would also be very interested.)<br />
-erik</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Gov</title>
		<link>http://blogs.mathworks.com/loren/2006/05/17/fibonacci-and-filter/#comment-217</link>
		<dc:creator>Eric Gov</dc:creator>
		<pubDate>Mon, 29 May 2006 22:33:52 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=37#comment-217</guid>
		<description>Correction to the previous post.

In fact, the 2nd time I run the code I get

Elapsed time is 0.000000 seconds

I believe the 1st time I ended up with 16ms because of the Hard Disk (or memory) read, while the 2nd time the program was running from cache.

Eric</description>
		<content:encoded><![CDATA[<p>Correction to the previous post.</p>
<p>In fact, the 2nd time I run the code I get</p>
<p>Elapsed time is 0.000000 seconds</p>
<p>I believe the 1st time I ended up with 16ms because of the Hard Disk (or memory) read, while the 2nd time the program was running from cache.</p>
<p>Eric</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Gov</title>
		<link>http://blogs.mathworks.com/loren/2006/05/17/fibonacci-and-filter/#comment-216</link>
		<dc:creator>Eric Gov</dc:creator>
		<pubDate>Mon, 29 May 2006 22:17:39 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=37#comment-216</guid>
		<description>What&#039;s wrong with using the closed form expression? Even if you want to calculate the whole series of numbers it will be much faster. For example,

tic;
a=(1+sqrt(5))/2;
nf=102;
b=1-a;
F=(a.^[1:nf]-b.^[1:nf])/sqrt(5);
toc;

gives me report

Elapsed time is 0.016000 seconds

Eric</description>
		<content:encoded><![CDATA[<p>What&#8217;s wrong with using the closed form expression? Even if you want to calculate the whole series of numbers it will be much faster. For example,</p>
<p>tic;<br />
a=(1+sqrt(5))/2;<br />
nf=102;<br />
b=1-a;<br />
F=(a.^[1:nf]-b.^[1:nf])/sqrt(5);<br />
toc;</p>
<p>gives me report</p>
<p>Elapsed time is 0.016000 seconds</p>
<p>Eric</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2006/05/17/fibonacci-and-filter/#comment-209</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Fri, 26 May 2006 13:13:26 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=37#comment-209</guid>
		<description>My prealloc results might have been higher because of the way I ran the code.  Did you run the preallocation in a script, function, or directly from the command line?  That can make a huge difference sometimes, especially command-line vs. file.</description>
		<content:encoded><![CDATA[<p>My prealloc results might have been higher because of the way I ran the code.  Did you run the preallocation in a script, function, or directly from the command line?  That can make a huge difference sometimes, especially command-line vs. file.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ravi</title>
		<link>http://blogs.mathworks.com/loren/2006/05/17/fibonacci-and-filter/#comment-200</link>
		<dc:creator>ravi</dc:creator>
		<pubDate>Wed, 24 May 2006 09:42:47 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=37#comment-200</guid>
		<description>On my PC, I get the following timings for nf=102 :
prealloc :0.015, filter:0.053ms.
For nf=10000, prealloc:3.12,filter:4.61 ms
That is, the prealloc is faster. I have checked this several times. Can this depend on memory, PC internals and so on?
I found another method described in Roman Maeder&#039;s Mathematica book.
Let m=[1 1;1 0];
The matrix, m^(n-1) gives [f(n) f(n-1);f(n-1) f(n-2)]
where f(n) is fibonacci number for n, f(n-1) for (n-1) and so on.
fib=m^(n-1); fib(1,1) gives the fibonacci number for n. As expected,this computation is fast. 
It would be interesting to see how the code can be vectorised with the above method to get the entire series upto n. Any volunteers?</description>
		<content:encoded><![CDATA[<p>On my PC, I get the following timings for nf=102 :<br />
prealloc :0.015, filter:0.053ms.<br />
For nf=10000, prealloc:3.12,filter:4.61 ms<br />
That is, the prealloc is faster. I have checked this several times. Can this depend on memory, PC internals and so on?<br />
I found another method described in Roman Maeder&#8217;s Mathematica book.<br />
Let m=[1 1;1 0];<br />
The matrix, m^(n-1) gives [f(n) f(n-1);f(n-1) f(n-2)]<br />
where f(n) is fibonacci number for n, f(n-1) for (n-1) and so on.<br />
fib=m^(n-1); fib(1,1) gives the fibonacci number for n. As expected,this computation is fast.<br />
It would be interesting to see how the code can be vectorised with the above method to get the entire series upto n. Any volunteers?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Richard</title>
		<link>http://blogs.mathworks.com/loren/2006/05/17/fibonacci-and-filter/#comment-197</link>
		<dc:creator>Richard</dc:creator>
		<pubDate>Tue, 23 May 2006 20:07:34 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=37#comment-197</guid>
		<description>If you don&#039;t want all n numbers, the following can give you a single one: Note, this gives f0 = 1, f = 1, f2 = 2, etc... 
Also, at around n = 70 (near bitmax) this starts deviating from the results returned by addition based implementations

function fn = fibonnacci(n)
  alpha1 = (1 + sqrt(5)) / 2;
  alpha2 = (1 - sqrt(5)) / 2;

  c1     = (1 - alpha2) / (alpha1 - alpha2);
  c2     = (alpha1 - 1) / (alpha1 - alpha2);

  fn     = round(c1 * alpha1^n + c2 * alpha2^n);

% in fact the alpha2 term is really small, so you don&#039;t
% need it, except for n = 0;
  fn     = round(c1 * alpha1^n);</description>
		<content:encoded><![CDATA[<p>If you don&#8217;t want all n numbers, the following can give you a single one: Note, this gives f0 = 1, f = 1, f2 = 2, etc&#8230;<br />
Also, at around n = 70 (near bitmax) this starts deviating from the results returned by addition based implementations</p>
<p>function fn = fibonnacci(n)<br />
  alpha1 = (1 + sqrt(5)) / 2;<br />
  alpha2 = (1 &#8211; sqrt(5)) / 2;</p>
<p>  c1     = (1 &#8211; alpha2) / (alpha1 &#8211; alpha2);<br />
  c2     = (alpha1 &#8211; 1) / (alpha1 &#8211; alpha2);</p>
<p>  fn     = round(c1 * alpha1^n + c2 * alpha2^n);</p>
<p>% in fact the alpha2 term is really small, so you don&#8217;t<br />
% need it, except for n = 0;<br />
  fn     = round(c1 * alpha1^n);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2006/05/17/fibonacci-and-filter/#comment-184</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Thu, 18 May 2006 09:13:55 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=37#comment-184</guid>
		<description>Michael,

You are correct and I have fixed the text in the blog to reflect that.  Thanks for the correction!

--Loren</description>
		<content:encoded><![CDATA[<p>Michael,</p>
<p>You are correct and I have fixed the text in the blog to reflect that.  Thanks for the correction!</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
</channel>
</rss>

