Re: MuPad 3.0 Calculus of Variations - syntax

From: Ralf Hillebrand (tonner_at_mupad.de)
Date: 11/02/04


Date: Tue, 02 Nov 2004 10:41:04 +0100

Brad Cooper wrote:
> Here is a simple Calculus of Variations problem....
>
> Which curves can give an extremum of the functional
>
> v(y(x)) = integral from 0 to 1 of ((y')^2+12xy)dx, y(0)=0, y(1)=1 ?
>
> The answer is y=x^3
>
> Let's try to solve this....
>
> L := (diff(y(x),x))^2 + 12*x*y(x);
> res := detools::euler(L, [x], y);
>
> This gives the Euler equation 2.y([x,x])-12x (equation #1)
>
> Now to check x^3 is the solution to equation #1
>
> y := x -> x^3;
> op(res,1)+op(res,2);
>
> This gives Error: Illegal operand [_power] during evaluation of y
>
> 2*diff(y(x),x,x)-12*x; //gives 0 as expected.
>
> This is a simple case, but I would like to be able to do this type of
> verification of the Euler equation in more complicated cases without having
> to type in the output from detools::euler.

I forwarded your news article to Werner Seiler
(werner.seiler@iwr.uni-heidelberg.de) the developer of the detools
library (he has no news access). He asked me to post this reply:

        The reason for the described problem is very simple. The notation
`y([x,x])' appearing in the output is a shorthand for derivatives that is
only used by the methods in the DETools library. The MuPAD kernel knows
nothing about it and hence substituting some function for y will lead to
the described error.

        In principle, a simple option in the call of `detools::euler'
should have the effect that the output is not in this abbreviated form but
in the standard `diff' notation of MuPAD. Unfortunately I had to discover
that currently there is a bug preventing the proper recognition of this
option. This will be corrected in the next release of MuPAD (and the
option will be described in the manual).

        Thus for the moment the only solution of the problem is a little
hack using some internal data of the DETools library. If the following
procedure is applied to the output of `detools::euler' (before any other
call to a method in the library is performed!), then the output is
transformed in the standard `diff' format and the verification works as
the user intends.

makeDiff := proc(r) local DF; begin DF := detools::data["DFout"];
                DF::convert_to(DF(r),"diff"); end_proc;

Applied on your example:

>> L := (diff(y(x),x))^2 + 12*x*y(x);

                                                  2
                         12 x y(x) + diff(y(x), x)
>> res := makeDiff(detools::euler(L, [x], y));

                          2 diff(y(x), x, x) - 12 x
>> y := x -> x^3;

                                  x -> x^3
>> res

                                      0

-- 
     *---*         MuPAD -- The Open Computer Algebra System
    *---*|
    |*--|*             Ralf Hillebrand (tonner@mupad.de)
    *---*