<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239278</link>
    <title>MATLAB Central Newsreader - taylor polynomial evaluation</title>
    <description>Feed for thread: taylor polynomial evaluation</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Sat, 15 Nov 2008 01:17:02 -0500</pubDate>
      <title>taylor polynomial evaluation</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239278#611011</link>
      <author>rose lans</author>
      <description>Hi, I am trying to evaluate log(x) by using  taylor polynomial with degree that will approximate it as accurately as possible, on interval 0.5-1.5. For some reason, my code does not work right from 1 to 1.5, although the results from 0.5 to 1.5 are OK. Can anyone see what the problem is? (sorry, I am new to MATLAB, it's probably really simple)&lt;br&gt;
function taylor1(a,b)&lt;br&gt;
% a=0.5, b=1.5&lt;br&gt;
for x=a:0.01:b&lt;br&gt;
t=(x-1)-(1/2)*(x-1)^2+(1/3)*(x-1)^3-(1/4)*(x-1)^4+(1/5)*(x-1)^5-...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(1/6)*(x-1)^6+(1/7)*(x-1)^7-(1/8)*(x-1)^8+(1/9)*(x-1)^9;&lt;br&gt;
&lt;br&gt;
fprintf('t=%2.10g \n',t)&lt;br&gt;
fprintf('x=%1.2g \n',x)&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
Also, does anyone know how to display the results in a nice readable form?&lt;br&gt;
Thank you all,&lt;br&gt;
Rose</description>
    </item>
    <item>
      <pubDate>Sat, 15 Nov 2008 02:22:22 -0500</pubDate>
      <title>Re: taylor polynomial evaluation</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239278#611015</link>
      <author>Nasser Abbasi</author>
      <description>&lt;br&gt;
&quot;rose lans&quot; &amp;lt;byrusel42@yahoo.com&amp;gt; wrote in message &lt;br&gt;
news:gfl7ue$un$1@fred.mathworks.com...&lt;br&gt;
&amp;gt; Hi, I am trying to evaluate log(x) by using  taylor polynomial with degree &lt;br&gt;
&amp;gt; that will approximate it as accurately as possible, on interval 0.5-1.5. &lt;br&gt;
&amp;gt; For some reason, my code does not work right from 1 to 1.5, although the &lt;br&gt;
&amp;gt; results from 0.5 to 1.5 are OK. Can anyone see what the problem is? &lt;br&gt;
&amp;gt; (sorry, I am new to MATLAB, it's probably really simple)&lt;br&gt;
&amp;gt; function taylor1(a,b)&lt;br&gt;
&amp;gt; % a=0.5, b=1.5&lt;br&gt;
&amp;gt; for x=a:0.01:b&lt;br&gt;
&amp;gt; t=(x-1)-(1/2)*(x-1)^2+(1/3)*(x-1)^3-(1/4)*(x-1)^4+(1/5)*(x-1)^5-...&lt;br&gt;
&amp;gt;    (1/6)*(x-1)^6+(1/7)*(x-1)^7-(1/8)*(x-1)^8+(1/9)*(x-1)^9;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; fprintf('t=%2.10g \n',t)&lt;br&gt;
&amp;gt; fprintf('x=%1.2g \n',x)&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Also, does anyone know how to display the results in a nice readable form?&lt;br&gt;
&amp;gt; Thank you all,&lt;br&gt;
&amp;gt; Rose&lt;br&gt;
&lt;br&gt;
Just saying 'does not work' does not help someone to help you.&lt;br&gt;
&lt;br&gt;
what exactly does not work?&lt;br&gt;
&lt;br&gt;
Nasser</description>
    </item>
    <item>
      <pubDate>Sat, 15 Nov 2008 03:02:02 -0500</pubDate>
      <title>Re: taylor polynomial evaluation</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239278#611017</link>
      <author>Roger Stafford</author>
      <description>&quot;rose lans&quot; &amp;lt;byrusel42@yahoo.com&amp;gt; wrote in message &amp;lt;gfl7ue$un$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi, I am trying to evaluate log(x) by using  taylor polynomial with degree that will &lt;br&gt;
&amp;gt; ..... SNIP .....&lt;br&gt;
&amp;gt; Rose&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;In the range from x = 1 to x = 1.5 the terms in your series reverse sign at each term and each one is smaller in magnitude than the previous one.  Therefore the next unused term gives you an upper bound for the total error incurred.  For x = 1.5 the 10-th term would be about 1/10^4, representing overall accuracy better than the fourth decimal place.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;On the other hand x = 0.5 yields a series of terms all of the same negative sign.  This means the error made is the sum of a number of negative quantities beyond the end of the polynomial which combine their magnitudes, and that would explain the larger error that you are apparently experiencing.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;You will find that the Taylor expansion does not in general provide the best approximating polynomials for analytic functions for given intervals.  There exist much better polynomials than that, but it requires some optimization work to find them.  Short of that, you will have to use far more than nine polynomial terms to get good accuracy as far out from x = 1 as x = 0.5.&lt;br&gt;
&lt;br&gt;
Roger Stafford</description>
    </item>
    <item>
      <pubDate>Sat, 15 Nov 2008 21:59:03 -0500</pubDate>
      <title>Re: taylor polynomial evaluation</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239278#611097</link>
      <author>rose lans</author>
      <description>Thank you for your reply, &lt;br&gt;
i got it working OK now. The error is of 10^-16 order.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&quot;Roger Stafford&quot; &amp;lt;ellieandrogerxyzzy@mindspring.com.invalid&amp;gt; wrote in message &amp;lt;gfle3a$30v$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;rose lans&quot; &amp;lt;byrusel42@yahoo.com&amp;gt; wrote in message &amp;lt;gfl7ue$un$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; Hi, I am trying to evaluate log(x) by using  taylor polynomial with degree that will &lt;br&gt;
&amp;gt; &amp;gt; ..... SNIP .....&lt;br&gt;
&amp;gt; &amp;gt; Rose&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;   In the range from x = 1 to x = 1.5 the terms in your series reverse sign at each term and each one is smaller in magnitude than the previous one.  Therefore the next unused term gives you an upper bound for the total error incurred.  For x = 1.5 the 10-th term would be about 1/10^4, representing overall accuracy better than the fourth decimal place.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;   On the other hand x = 0.5 yields a series of terms all of the same negative sign.  This means the error made is the sum of a number of negative quantities beyond the end of the polynomial which combine their magnitudes, and that would explain the larger error that you are apparently experiencing.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;   You will find that the Taylor expansion does not in general provide the best approximating polynomials for analytic functions for given intervals.  There exist much better polynomials than that, but it requires some optimization work to find them.  Short of that, you will have to use far more than nine polynomial terms to get good accuracy as far out from x = 1 as x = 0.5.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Roger Stafford</description>
    </item>
  </channel>
</rss>

