taylor expansion in 1D



On Mon, 21 Jul 2008, Barton Willis wrote:
>>Can I use taylor(...) with extra massaging to
>>generate a formal expansion like;
>>
>>f(x + e)  --> f(x)  + e* 'diff( f(x), x, 1)
>>                      + e^2 * 'diff( f(x), x, 2) / 2  + ...
>>
>>??  or can this be done with pdiff ?
>
>I think pdiff makes these kind of calculations nicer, but depending on what
>you need, maybe you don't need pdiff. Example:
>
> (%i1) taylor(f(x + e),e,0,2);
> (%o1)
> 
> f(x)+(at('diff(f(x+e),e,1),e=0))*e+((at('diff(f(x+e),e,2),e=0))*e^2)/2+...
>Substituting a value for 'e' gives an error (maybe atvalue allows you to
>do such things, I don't know).


On Mon, 21 Jul 2008, Richard Fateman wrote:
>try deftaylor(f(x),sum(a[i]*x^i,i,0,inf));
>taylor(f(x+e),x,0,4);

Thanks to Barton and Richard for the suggestions.
I am back from vacation and trying to read all
my back emails. I was in a rush to put in a couple of
really simple examples of what physicists
do with taylor series in  practice, and wanted to
post ch. 6 before I left on vacation.

I ended up with the two following examples
in ch. 6: (relevant to my email request)
(adapted to maxima list viewing here); in the second
example, "e" is supposed to be some small
dimensionless parameter, and an expansion in
that parameter is wanted.

(%i1) display2d:false$
(%i2) taylor(cos(x+dx),dx,0,4);
(%o2) cos(x)-sin(x)*dx-cos(x)*dx^2/2+sin(x)*dx^3/6+cos(x)*dx^4/24
(%i3) g : log(a/e + sqrt(1+(a/e)^2 ) )$
(%i4) taylor(g,e,0,2);
(%o4) -log(e)+log(2*a)+e^2/(4*a^2)

I haven't had time yet to explore the use of pdiff with
taylor series or the use of deftaylor with formal
taylor series expansions.  Ch. 6 is designed to
present the most basic uses with explicit expressions.
Perhaps when I revise ch. 6 next I will also include
more sophisticated uses of taylor.

Ted Woollett