Dear Maxima Maintainers,
try to double differentiate a function into a total differential:
(I hope that the pretty printed results are well readable)
(%i1) depends(f, [x, y]);
(%o1) [f(x, y)]
(%i2) Df : diff(f);
df df
(%o2) -- del(y) + -- del(x)
dy dx
(%i3) D2f : diff(Df);
2 2
d f d f df d
(%o3) (--- del(y) + ----- del(x) + -- (-- (del(y)))) del(y)
2 dx dy dy dy
dy
2 2
d f d f df d
+ (----- del(y) + --- del(x) + -- (-- (del(x)))) del(x)
dx dy 2 dx dx
dx
/*
expected was something like this:
d/dx (df/dx) del(x)^2 + 2 d/dx (df/dy) del(x) del(y) + d/dy (df/dy) del(y)^2
*/
Maxima does not reduce d/dx (del(x)) any further. It should be equal to one, shouldn't it? Or there should be a chance to tell Maxima, that it should be one, such that
diff(del(x), x);
would yield 1.
Trying to tell maxima, that y only depends on y, will get Maxima crashing:
(%i4) depends(y, [y]); /* depends(y, 1) does not work*/
(%o4) [y(y)]
(%i5) D2f : diff(Df);
*** - Lisp stack overflow. RESET
[../src/eval.d:573] reset() found no driver frame (sp=0x7fff0552c7e0-0x7fff055261f0)
Exiting on signal 6
-------------------------------------------------------------
Maxima version: "5.38.1"
Maxima build date: "2016-10-19 00:27:24"
Host type: "x86_64-suse-linux-gnu"
Lisp implementation type: "CLISP"
Lisp implementation version: "2.49 (2010-07-07) (built on cloud112 [127.0.0.1])"
-------------------------------------------------------------
Maybe I am wrong, but how could one get the expected result?
Thank you for your great work
Best regards
T. Finke
You need to tell maxima that diff(del(x),x)=0. Here is one way:
Demonstration:
You can see that %o6 is the Hessian of f in the notation of differential forms.
Declaring
will lead to a circular rule in differentiating y, which causes a stack overflow as you saw.
Dear Leo,
that is a smart and simple solution - very useful!
Thank you very much and
best regards
Torsten
Closing this report since it appears the problem is resolved, thanks to L. Butler.