A package to change variables in symbolic (differential) equations in Mathematica.
Example: x df(x,y)/dx
and transform x->r
with the definition r(x) = 1/x
:
ChangeVariables[x D[f[x,y],x], x, r, (1/# &)]
Output:
{-r (f^(1,0))[r,y]}
You can find examples in UseChangeVariables.wls
or in Tests/TestChangeVariables.wls
.
- Either load the package with
Get[absoluteFilePathToPackageFile]
, where the file path is toChangeVariables.wl
- Or install the package by clicking
file
->install
.
- In some
equation
change the variablea
to the variableb
with definitiontoVarDef
(Lambda/Pure function):ChangeVariables[equation, a, b, toVarDef]
. - the functions in equation can have an arbitrary amount of arguments, e.g.
f[x,y,z,a,b]
- arbitrary amounts of derivatives
D[f[x,y], {x,1337}, {y, 42}]
. - If your definition
toVarDef
has a non-unique inverse, e.g.x
->y=Cos[x]
, thenx=ArcCos[y]+2 Pi c
, wherec
is an integer.The output will show this.
- I had to blacklist internal functions like
Plus
andTimes
in order to not transform them. If your expression contains a function like that that I have not thought of, then you might get nonsense. I would appreciate a quick note if you have encountered such an example. ChangeVariables[Cos[x] f[x, y], x, u, (Cos[#] &)]
still has a conditional statement as output withc
an integer, but there is actually no ambiguity left.
- Convert more than one function at a time.
- Option for explicitly stating a function that should be blacklisted, see Known Bugs.
- Option to give inverse function as argument, e.g. if
x
->y=Log[x]
you could giveExp[#]&
instead and let Mathematica invert. - Clean up source code such that it is actually readable.
- Tests.
Marco Knipfer
University of Alabama