Use the pdiff package:
(%i1) load("pdiff")$
(%i2) taylor(f(x+h),h,0,2) - taylor(f(x-h),h,0,2);
(%o2) 2*f[(1)](x)*h+...
( f[(1)](x) is the first derivative of f ).
Andrej
On 5/10/06, Fabio Subba <fabio.subba at polito.it> wrote:
> Dear everybody,
> I just installed maxima, which a want to use primarily to do some
> numerical analysis.
> I am trying to get a classical forward and backward taylor expansion:
>
> f(x+h) = f(x) + (df(x+h) / dx) | h=0 * h + (d2f(x+h) / dx2) | h=0 *
> h^2/2 + ...
> f(x-h) = f(x) + (df(x-h) / dx) | h=0 * h + (d2f(x-h) / dx2) |
> h=0 * h^2/2 + ...
>
> Now here is the problem:
> apparently I can get the two truncated series with the taylor
> command, but I found no way to sum them up in a user-friendly way.
> I tried:
>
> taylor(f(x+h),h,0,2) - taylor(f(x-h),h,0,2)
>
> then, in the first order term, i get:
>
> df(x+h)/dh | h=0 - df(x-h)/dh | h=0
>
> and I found no way to tell maxima that this term should simplify to
> zero. I guess this is because maxima assumes that my function could
> in principle have a discontinuous derivative... how can I solve the
> problem? Any help would be very appreciated.
> Thank you
> Fabio
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>