Search code examples
matlabsymbolic-mathcomputer-algebra-systemsmupad

Tidy up expression after differentiating


The equations I am working with in this problem contain exponentials. For this reason, after differentiating they appear again pretty much unchanged apart from additional constants and other factors. I was wondering if it might be possible to collect those exponentials back into the name of the expression they where part of. Here is an example:

Given this function definition

f:= x -> A*exp(B/x)

After differentiating, one would get

A*exp(B/x)*(-B/x^2)

And it would be great if I could somehow convert it to

f(x)*(-B/x^2)

Is this possible with MuPad or any other CAS package?


Solution

  • It's easy in MAPLE, use general substitution command algsubs

    > f:= x -> A*exp(B/x)
    > g := diff(f(x), x)
    > algsubs(A*exp(B/x) = F, g)
    

    For more complex expressions, try collect