<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Rooting Around in MATLAB - Part 1</title>
	<link>http://blogs.mathworks.com/loren/2009/06/11/rooting-around-in-matlab-part-1/</link>
	<description>Loren Shure  works on design of the MATLAB language at &#60;a href="http://www.mathworks.com/"&#62;The MathWorks&#60;/a&#62;. She writes here about once a week on MATLAB programming and related topics. &#60;br&#62;&#60;br&#62;&#60;a href="/images/loren-full.jpg"&#62;&#60;img src="/images/loren.jpg"&#62;&#60;/a&#62;</description>
	<pubDate>Mon, 23 Nov 2009 01:02:08 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
		<item>
		<title>By: Yi Cao</title>
		<link>http://blogs.mathworks.com/loren/2009/06/11/rooting-around-in-matlab-part-1/#comment-30384</link>
		<dc:creator>Yi Cao</dc:creator>
		<pubDate>Fri, 12 Jun 2009 17:06:15 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2009/06/11/rooting-around-in-matlab-part-1/#comment-30384</guid>
		<description>Loren,

I do not know what you are going to write for Part 2 and Part 3. For me, the logic to use (1-x)^(1/3) is clear since the original equation x^3+x-1=0 is equivalent to x=(1-x)^(1/3). Therefore, the iteration is naturally derived as:

x_k+1 = (1-x_k)^(1/3)

Certainly, there are many ways to work out an iteration like this, e.g. from x = 1 - x^3, we can have iteration

x_k+1 = 1 - x_k^3

However, this iteration is unstable for 3*x_k^2 &#62; 1, i.e. x_k &#62; 0.5774. Since the solution is x=0.68233 &#62; 0.5774, the second iteration is not suitable for this problem.

The advantage of my solution is that

1. It works for fractional order, e.g. x^3.25 + x - 1 =0, which cannot be solved by roots function.
2. It can be vectorised for different constants other than 1:

x^3.25 + x - a = 0, for a = 1:10.

&lt;pre&gt;
a=1:10;
x0=0.5;
x1=0;
while norm(x1-x0)&#62;1e-6,
   x1=x0;
   x0=(a-x1).^(1/3.25);
end
disp(x0)
err=x0.^3.25+x0-a
&lt;/pre&gt;

If we use fzero:

&lt;pre&gt;
fz=zeros(1,10);
for a=1:10
  f=@(x)x.^3.25+x-a;
  fz(a)=fzero(f,0.5);
end
disp(fz)
err=fz.^3.25+fz-(1:10)
&lt;/pre&gt;

Only the first a=1 is solved. Other a's end up with NaN! 

Yi</description>
		<content:encoded><![CDATA[<p>Loren,</p>
<p>I do not know what you are going to write for Part 2 and Part 3. For me, the logic to use (1-x)^(1/3) is clear since the original equation x^3+x-1=0 is equivalent to x=(1-x)^(1/3). Therefore, the iteration is naturally derived as:</p>
<p>x_k+1 = (1-x_k)^(1/3)</p>
<p>Certainly, there are many ways to work out an iteration like this, e.g. from x = 1 - x^3, we can have iteration</p>
<p>x_k+1 = 1 - x_k^3</p>
<p>However, this iteration is unstable for 3*x_k^2 &gt; 1, i.e. x_k &gt; 0.5774. Since the solution is x=0.68233 &gt; 0.5774, the second iteration is not suitable for this problem.</p>
<p>The advantage of my solution is that</p>
<p>1. It works for fractional order, e.g. x^3.25 + x - 1 =0, which cannot be solved by roots function.<br />
2. It can be vectorised for different constants other than 1:</p>
<p>x^3.25 + x - a = 0, for a = 1:10.</p>
<pre>
a=1:10;
x0=0.5;
x1=0;
while norm(x1-x0)&gt;1e-6,
   x1=x0;
   x0=(a-x1).^(1/3.25);
end
disp(x0)
err=x0.^3.25+x0-a
</pre>
<p>If we use fzero:</p>
<pre>
fz=zeros(1,10);
for a=1:10
  f=@(x)x.^3.25+x-a;
  fz(a)=fzero(f,0.5);
end
disp(fz)
err=fz.^3.25+fz-(1:10)
</pre>
<p>Only the first a=1 is solved. Other a&#8217;s end up with NaN! </p>
<p>Yi</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2009/06/11/rooting-around-in-matlab-part-1/#comment-30383</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Fri, 12 Jun 2009 14:55:01 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2009/06/11/rooting-around-in-matlab-part-1/#comment-30383</guid>
		<description>Yao-

True, many ways, but I am thinking of how to derive and explain an algorithm to students.  How would someone know know to use &lt;tt&gt;(1-x)^(1/3)&lt;/tt&gt;?  Wait for my next post to my ideas on how to explore and teach some of these concepts.

--Loren</description>
		<content:encoded><![CDATA[<p>Yao-</p>
<p>True, many ways, but I am thinking of how to derive and explain an algorithm to students.  How would someone know know to use <tt>(1-x)^(1/3)</tt>?  Wait for my next post to my ideas on how to explore and teach some of these concepts.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yi Cao</title>
		<link>http://blogs.mathworks.com/loren/2009/06/11/rooting-around-in-matlab-part-1/#comment-30382</link>
		<dc:creator>Yi Cao</dc:creator>
		<pubDate>Fri, 12 Jun 2009 14:46:33 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2009/06/11/rooting-around-in-matlab-part-1/#comment-30382</guid>
		<description>Another way to get the root:

&lt;pre&gt;
x0=0.5;
x1=0;
while abs(x1-x0)&#62;1e-6, 
   x1=x0; 
   x0=(1-x1)^(1/3);
end 
disp(x0)
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Another way to get the root:</p>
<pre>
x0=0.5;
x1=0;
while abs(x1-x0)&gt;1e-6,
   x1=x0;
   x0=(1-x1)^(1/3);
end
disp(x0)
</pre>
]]></content:encoded>
	</item>
</channel>
</rss>
