From: Manuel on 9 Feb 2010 12:09 Hi, How can I evaluate the following Taylor expansion in x=.01:.001:.01 so I can plot it. Thanks, >> syms x >> y=exp(x); >> taylor(y) ans = x^5/120 + x^4/24 + x^3/6 + x^2/2 + x + 1
From: Cygnine on 9 Feb 2010 12:20 "Manuel " <m.pinuela09(a)imperial.ac.uk> wrote in message > How can I evaluate the following Taylor expansion in x=.01:.001:.01 so I can plot it. You can do >> xgrid = linspace(0, 1, 1e2); >> ygrid = subs(y, xgrid); I think there's a better (i.e. faster) way...perhaps someone will provide it.
From: Steven Lord on 9 Feb 2010 12:26 "Manuel " <m.pinuela09(a)imperial.ac.uk> wrote in message news:hks4rg$3fu$1(a)fred.mathworks.com... > Hi, > > How can I evaluate the following Taylor expansion in x=.01:.001:.01 so I > can plot it. > Thanks, > >>> syms x >>> y=exp(x); >>> taylor(y) > > ans = > > x^5/120 + x^4/24 + x^3/6 + x^2/2 + x + 1 Since this is a polynomial, and assuming you don't need to evaluate this in greater-than-double precision, use SYM2POLY and then POLYVAL. [In any case, you're going to need to convert the values to double at some point in order to plot the function.] -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
From: Manuel on 9 Feb 2010 12:31 and then how do I evaluate the Taylor expansion? "Cygnine " <cygnine(a)remove.this.gmail.com> wrote in message <hks5gr$hm8$1(a)fred.mathworks.com>... > "Manuel " <m.pinuela09(a)imperial.ac.uk> wrote in message > > How can I evaluate the following Taylor expansion in x=.01:.001:.01 so I can plot it. > > You can do > >> xgrid = linspace(0, 1, 1e2); > >> ygrid = subs(y, xgrid); > > I think there's a better (i.e. faster) way...perhaps someone will provide it.
From: Manuel on 9 Feb 2010 13:00
Thanks!! this is what I was looking for. Is there any other instruction that does the same but with higher precision? "Steven Lord" <slord(a)mathworks.com> wrote in message <hks5rt$9lj$1(a)fred.mathworks.com>... > > "Manuel " <m.pinuela09(a)imperial.ac.uk> wrote in message > news:hks4rg$3fu$1(a)fred.mathworks.com... > > Hi, > > > > How can I evaluate the following Taylor expansion in x=.01:.001:.01 so I > > can plot it. > > Thanks, > > > >>> syms x > >>> y=exp(x); > >>> taylor(y) > > > > ans = > > > > x^5/120 + x^4/24 + x^3/6 + x^2/2 + x + 1 > > Since this is a polynomial, and assuming you don't need to evaluate this in > greater-than-double precision, use SYM2POLY and then POLYVAL. [In any case, > you're going to need to convert the values to double at some point in order > to plot the function.] > > -- > Steve Lord > slord(a)mathworks.com > comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ > |