# How to simplify expressions utilizing known relations between functions

If I have some long expressions in terms of an arbitrary functions, and their derivatives, say, is it possible to ask Mathematica to simplify that expression utilizing known relations between the functions?

For example, suppose I have a function $f[x,y]\in \mathbb{R^3}$ and I define some quantity $$G[x,y]=\frac{1}{|\partial f / \partial y|^3}\frac{\partial^5 f}{\partial x^4 \partial y} -(|\frac{\partial f}{\partial x}|^2 + f\cdot \frac{ \partial f}{\partial x}) f$$ (or whatever). Suppose I know moreover that $f$ satisfies the relations $$(1) \hskip5pt \frac{\partial ^2 f}{\partial x^2}+\frac{\partial ^2 f}{\partial y^2}=0$$ $$(2) \hskip5pt \frac{\partial f}{\partial x} \cdot \frac{\partial f}{\partial y}=0$$

Then is there a way to ask Mathematica to simplify long expressions such as $\frac{\partial^2 G}{\partial x^2}+\frac{\partial^2 G}{\partial y^2}$ making use of the relations (1) and (2)?

Even more adventurously, would it be possible to ask Mathematica to look for relations (i.e. a differential equation) satisfied by $G$, given the relations (1) and (2)?

Update: I tried doing this using FullSimplify with an Assumption, but this appears to be really lousy, as a toy example I looked at the expression $g=\xi_x -(\xi_{xx}-\xi_{yy})^2$ where $\xi$ solves the wave equation $\xi_{xx}-\xi_{yy}=0$. Mathematica could then simplify the first derivatives of $g$, but couldn't manage even its second derivatives, let alone more complicated stuff!

Does anyone know any better methods?

• Please provide copy/pasteable Mathematica code! – Carl Woll Dec 12 '17 at 2:55

You can differentiate your constraints to generate additional constraints in order to canonicalize your expression. Here is one attempt:

order[expr_] := Max @ Cases[
expr,
Derivative[a__][_][__] :> Total[{a}],
{0, Infinity}
]

canon[expr_, {eqns__Equal}, v_] := Module[
{
exprOrder = order[expr],
eqnOrders = order /@ {eqns},
assumptions
},
NestList[D[#, {v}]&, #1, Max[exprOrder - #2, 0]]&,
{{eqns}, eqnOrders}
];
Simplify[expr, assumptions]
]
canon[expr_, eqn_Equal, v_] := canon[expr, {eqn}, v]


On your initial example, this is what I get:

canon[
1/D[f[x,y], y]^3 D[f[x,y], {x, 4}, y] - (D[f[x,y],x]^2 + f[x,y] D[f[x, y], x])f[x,y],
{
D[f[x,y], x, x] + D[f[x,y], y, y] == 0,
D[f[x,y], x] D[f[x,y], y] == 0
},
{x,y}
] //TeXForm


$\frac{f^{(4,1)}(x,y)}{f^{(0,1)}(x,y)^3}$

It seems that Simplify must be using Together, causing the latter term to become zero.

g[x_, y_] := D[ξ[x, y], x] - (D[ξ[x,y], x, x] - D[ξ[x, y], y, y])^2

eqn = D[ξ[x, y], x, x] - D[ξ[x, y], y, y] == 0;

expr = D[g[x, y], x];
expr //TeXForm


$\xi ^{(2,0)}(x,y)-2 \left(\xi ^{(2,0)}(x,y)-\xi ^{(0,2)}(x,y)\right) \left(\xi ^{(3,0)}(x,y)-\xi ^{(1,2)}(x,y)\right)$

After canonicalization we get:

canon[expr, eqn, {x, y}] //TeXForm


$\xi ^{(2,0)}(x,y)$

For the second update example:

expr = D[g[x, y], x, x, x, x, x, x, x, x];
expr //TeXForm


$-70 \left(\xi ^{(6,0)}(x,y)-\xi ^{(4,2)}(x,y)\right)^2-112 \left(\xi ^{(5,0)}(x,y)-\xi ^{(3,2)}(x,y)\right) \left(\xi ^{(7,0)}(x,y)-\xi ^{(5,2)}(x,y)\right)-56 \left(\xi ^{(4,0)}(x,y)-\xi ^{(2,2)}(x,y)\right) \left(\xi ^{(8,0)}(x,y)-\xi ^{(6,2)}(x,y)\right)+\xi ^{(9,0)}(x,y)-16 \left(\xi ^{(3,0)}(x,y)-\xi ^{(1,2)}(x,y)\right) \left(\xi ^{(9,0)}(x,y)-\xi ^{(7,2)}(x,y)\right)-2 \left(\xi ^{(2,0)}(x,y)-\xi ^{(0,2)}(x,y)\right) \left(\xi ^{(10,0)}(x,y)-\xi ^{(8,2)}(x,y)\right)$

And after canonicalization:

canon[expr, eqn, {x, y}] //TeXForm


$\xi ^{(9,0)}(x,y)$

• Thanks that code seems to work a bit of magic :) (still not actually managed to pull out any nice identities for my specific problem, but that was always a long shot and it simplified the equations by a bit anyway!) – Aerinmund Fagelson Dec 12 '17 at 15:09
• have you got any ideas for the more ambitious problem, where one might write a program to 'look for simplified expressions'. I.e, it might try to look for a differential equation satisfied by $G$? – Aerinmund Fagelson Dec 12 '17 at 15:11