From symbolic to proper differentiation in Maxima

134 Views Asked by At

I'm struggling to find a way to switch from a symbolic declaration of the differential operator to its implementation

I give you an example.

F: (10-'diff(x(t),t)^2 -2*x(t)*'diff(x(t),t) -5*x(t)^2)*%e^(-t);

E: ratsimp(diff(F, x(t)) - diff(diff(F, 'diff(x(t),t)), t));

sol: ode2(E, x(t), t);
sol: ev(sol, [%k1 = C1, %k2=C2]);

trans_cond: diff(F, 'diff(x(t), t));
trans_cond: ev(trans_cond, sol);
trans_cond: at(trans_cond, [t=1]);

The corresponding output maintains the symbolic notation whereas I would like to evaluate the diff() obtained after the last substitution.

Giving the result:

% 4*C1-C2^(-2)
2

There are 2 best solutions below

0
Robert Dodier On BEST ANSWER

Another solution. The nouns option for ev causes the evaluation of symbolic derivatives, and also any other noun expressions such as symbolic integrals, symbolic summations, etc.

(%i2) 'diff(4*x^2, x);
                            d      2
(%o2)                       -- (4 x )
                            dx
(%i3) ev (%o2, nouns);
(%o3)                          8 x

A shorter form of ev(..., nouns) is recognized by the interactive console. You can input ..., nouns instead.

(%i5) %o2, nouns;
(%o5)                          8 x

Here is ev(..., nouns) applied to symbolic integral:

(%i6) 'integrate (x^2, x);
                             /
                             [  2
(%o6)                        I x  dx
                             ]
                             /
(%i7) %, nouns;
                                3
                               x
(%o7)                          --
                               3

and here, to a symbolic summation:

(%i8) 'sum (f(k), k, 1, 3);
                            3
                           ====
                           \
(%o8)                       >    f(k)
                           /
                           ====
                           k = 1
(%i9) %, nouns;
(%o9)                  f(3) + f(2) + f(1)
0
Marco Repetto On

Found the answer, ev() carries the option diff which solves all the symbolic differentiation in the expression.