Path: news.mathworks.com!newsfeed-00.mathworks.com!news.kjsl.com!newsfeed.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!flpi089.ffdc.sbc.com!prodigy.net!flpi088.ffdc.sbc.com!prodigy.com!flpi107.ffdc.sbc.com!nlpi064.nbdc.sbc.com.POSTED!ffbda4aa!not-for-mail
Reply-To: "Nasser Abbasi" <nma@12000.org>
From: "Nasser Abbasi" <nma@12000.org>
Newsgroups: comp.soft-sys.matlab
References: <gfl7ue$un$1@fred.mathworks.com>
Subject: Re: taylor polynomial evaluation
Lines: 30
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3350
X-RFC2646: Format=Flowed; Original
Message-ID: <LnqTk.10684$Ws1.3572@nlpi064.nbdc.sbc.com>
NNTP-Posting-Host: 75.41.102.201
X-Complaints-To: abuse@prodigy.net
X-Trace: nlpi064.nbdc.sbc.com 1226715755 ST000 75.41.102.201 (Fri, 14 Nov 2008 21:22:35 EST)
NNTP-Posting-Date: Fri, 14 Nov 2008 21:22:35 EST
Organization: at&t http://my.att.net/
X-UserInfo1: [[PAPDCA[S@OR_D[]P_LJ]UDTJYNQBQLGPQRZ_MHEQR@ETUCCNSKQFCY@TXDX_WHSVB]ZEJLSNY\^J[CUVSA_QLFC^RQHUPH[P[NRWCCMLSNPOD_ESALHUK@TDFUZHBLJ\XGKL^NXA\EVHSP[D_C^B_^JCX^W]CHBAX]POG@SSAZQ\LE[DCNMUPG_VSC@VJM
Date: Fri, 14 Nov 2008 18:22:22 -0800
Xref: news.mathworks.com comp.soft-sys.matlab:500939



"rose lans" <byrusel42@yahoo.com> wrote in message 
news:gfl7ue$un$1@fred.mathworks.com...
> 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)
> function taylor1(a,b)
> % a=0.5, b=1.5
> for x=a:0.01:b
> t=(x-1)-(1/2)*(x-1)^2+(1/3)*(x-1)^3-(1/4)*(x-1)^4+(1/5)*(x-1)^5-...
>    (1/6)*(x-1)^6+(1/7)*(x-1)^7-(1/8)*(x-1)^8+(1/9)*(x-1)^9;
>
> fprintf('t=%2.10g \n',t)
> fprintf('x=%1.2g \n',x)
> end
>
> Also, does anyone know how to display the results in a nice readable form?
> Thank you all,
> Rose

Just saying 'does not work' does not help someone to help you.

what exactly does not work?

Nasser