Search code examples
diffconstantsmaxima

Maxima simplify expression with diff


Let's assume a is a constant and x is my variable with respect to time, so basically x(t).

Then in Maxima , what is the best way to replace 'diff(a*x,t) with a*'diff(x,t) automatically without use subst command.

The reason I don't to use subst is that I have many variables and higher order derivatives. It is not efficient to use subst to replace all the occurrences.

Thanks.

UPDATE

I have tried with depends(x,t) command, but it only works with the simple case. Here is an minimal example of my situation.

depends([x,y],t);
eq1:diff(x,t)-b=c;
eq2:subst([x=a*y],eq1);
sol_dy=solve(eq2,diff(y,t))

Of course here a,b,c are constants and x, y are variables on t. Maxima can not solve diff(y,t) directly. How do deal with it?


Solution

  • I see that 'diff(...) (i.e. derivative noun expression) isn't linear (doesn't distribute over + and doesn't factor out constants) but diff(...) (verb expression) is linear. That's a misfeature, at least.

    I was going to suggest declare(nounify(diff), linear) but that makes derivatives come out as 0 in your example ... this is probably a bug, I'll have to think more about it.

    Try ev(eq2, nouns); to re-evaluate the derivatives as verbs -- I think that should cause the constant to factor out.