tholy
tholy

Reputation: 12179

Simplification of expressions involving abstract derivatives in maxima

I'm trying to get maxima to perform some "abstract" Taylor series expansions, and I'm running into a simplification issue. A prototype of the problem might be the finite-difference analog of the gradient,

g(x1,dx1) := (f(x1+dx1) - f(x1))/dx1;  /* dx1 is small */
taylor(g(x1,dx1), [dx1], [0], 0);

for which maxima returns

enter image description here

So far so good. But now try the finite-difference analog of the second derivative (Hessian),

h(x1,dx1) := (f(x1+dx1) - 2*f(x1) + f(x1-dx1))/dx1^2;
taylor(h(x1,dx1), dx1, 0, 0);

for which I get

enter image description here

which is not nearly as helpful.

A prototype of the "real" problem I want to solve is to compute the low-order errors of the finite-difference approximation to ∂^2 f/(∂x1 ∂x2),

(f(x1+dx1, x2+dx2) - f(x1+dx1, x2) - f(x1, x2+dx2) + f(x1, x2))/(dx1*dx2)

and to collect the terms up to second order (which involves up to 4th derivatives of f). Without reasonably effective simplification I suspect it will be easier to do by hand than by computer algebra, so I am wondering what can be done to coax maxima into doing the simplification for me.

Upvotes: 3

Views: 195

Answers (1)

slitvinov
slitvinov

Reputation: 5768

Consider this example. It uses Barton Willis' pdiff package. I simplified notation a bit: moved center to [0, 0] and introduced notation for partial derivatives.

(%i1) load("pdiff") $
(%i2) matchdeclare([n, m], integerp) $
(%i3) tellsimpafter(f(0, 0), 'f00) $
(%i4) tellsimpafter(pderivop(f,n,m)(0,0), concat('f, n, m)) $
(%i5) e: (f(dx, dy) - f(dx, -dy) - f(-dx, dy) + f(-dx, -dy))/(4*dx*dy)$
(%i6) taylor(e, [dx, dy], [0, 0], 3);
                                    2         2
                              f31 dx  + f13 dy
(%o6)/T/                f11 + ----------------- + . . .
                                      6

Upvotes: 1

Related Questions