Menu

#3515 diff and del, Maxima crashes

None
closed
nobody
diff (20) del (2)
5
2019-01-21
2019-01-07
tnfnk
No

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

Discussion

  • Leo Butler

    Leo Butler - 2019-01-08

    You need to tell maxima that diff(del(x),x)=0. Here is one way:

    (%i2) gradef(del(t),0);
    (%o2) del(t)
    

    Demonstration:

    (%i3) depends(f,[x,y]);
    (%o3) [f(x,y)]
    (%i4) diff(f);
    
    (%o4) 'diff(f,y,1)*del(y)+'diff(f,x,1)*del(x)
    (%i5) diff(%);
    
    (%o5) ('diff(f,y,2)*del(y)+'diff(f,x,1,y,1)*del(x))*del(y)
     +('diff(f,x,1,y,1)*del(y)+'diff(f,x,2)*del(x))*del(x)
    (%i6) expand(%);
    
    (%o6) 2*'diff(f,x,1,y,1)*del(x)*del(y)+'diff(f,y,2)*del(y)^2+'diff(f,x,2)
                                                                 *del(x)^2
    

    You can see that %o6 is the Hessian of f in the notation of differential forms.

    Declaring

    depends(y,[y]);
    

    will lead to a circular rule in differentiating y, which causes a stack overflow as you saw.

     
    • tnfnk

      tnfnk - 2019-01-08

      Dear Leo,

      that is a smart and simple solution - very useful!

      Thank you very much and

      best regards

      Torsten

       
  • Robert Dodier

    Robert Dodier - 2019-01-21
    • labels: --> diff, del
    • status: open --> closed
     
  • Robert Dodier

    Robert Dodier - 2019-01-21

    Closing this report since it appears the problem is resolved, thanks to L. Butler.

     

Log in to post a comment.

MongoDB Logo MongoDB