# Simplifying expressions using rules that span nonconsecutive terms

Suppose there is some function with the property

f[x,y] f[y,x^2] / f[x^3,y] == f[2x,y]


How can I simplify an arbitrary expression that contains the lhs of the above equation in a somewhat obscured way? Say as in

a f[x^3,y] b / (c f[y,x^2] d f[x,y] e)


I tried Simplify with TransformationFunctions but I only seem to be able to replace the three f when they're literally next to each other in the syntax tree. Any ideas on how to proceed?

-

## 1 Answer

In this specific case, evaluating expressions like these will work:

EX1 = (f[x, y] f[y, x^2]/f[x^3, y] == f[2 x, y]);
EX2 = a f[x^3, y] b/(c f[y, x^2] d f[x, y] e);
EX2 /. Solve[EX1, f[x, y]]


{(a b)/(c d e f[2 x, y])}

As a purely formal exercise you could name your expressions by introducing some new variables and eliminate the unneeded parts:

Eliminate[{
f[x, y] f[y, x^2]/f[x^3, y] == expr1,
f[2 x, y] == expr1,
a f[x^3, y] b/(c f[y, x^2] d f[x, y] e) == expr2}, {f[x, y],
f[y, x^2], f[x^3, y]}]


expr1 expr2 == (a b)/(c d e) && f[2 x, y] == expr1 && c != 0 && d != 0 && e != 0

which gives the needed connection between expr2 and expr1 with original lhs elimintaed.

Also you could evaluate:

Cases[Reduce[{
f[x, y] f[y, x^2]/f[x^3, y] == expr1,
f[2 x, y] == expr1,
a f[x^3, y] b/(c f[y, x^2] d f[x, y] e) == expr2}, expr2]
, expr2 == _]


{expr2 == (a b)/(c d e f[2 x, y])}

-