# FullSimplify, Assumptions: Replacing Complex expressions by Simpler Ones as per Leaf Count [duplicate]

I have been trying to simplify equations using Mathematica of the following basic form: $$\text{FullSimplify}\left[x^2+y^2,\text{Assumptions}\to x^2+y^2==c^2\right]$$ With the output being, $$x^2+y^2$$

FullSimplify[x^2 + y^2, Assumptions -> x^2 + y^2 == c^2]


However, if $$c$$ were a number, the expected result is obtained ie. $$c^{2}$$. I would like to know how to make Mathematica replace the more complex(as per Leaf count) LHS with the simpler RHS.

• Convert the assumption to a replacement rule, e.g., expr /. y^2 :> c^2 - x^2 Commented Jan 27, 2022 at 17:27
• My example was a representative of the complex. In general, I'm not sure how this will work. For example, say I have $ab+cd==ef+gh$. Then, I would expect $ab+cd$ to remain unchanged. However, say if it were $ab+cd+ef==gh$, then I would expect $ab+cd+ef$ to be replaced. Commented Jan 27, 2022 at 17:31
• @Gattu A replacement will work for the example you gave. Perhaps you could show a more representative example. Maybe you could use an intermediate value: Simplify[x^2 + y^2, Assumptions -> x^2 + y^2 == m] returns m and then you could replace m with c^2 in the resulting expression. Commented Jan 27, 2022 at 18:18
• Alternatively, use the rule as a replacement-function for the TransformationFunction option like so: FullSimplify[x^2+y^2,TransformationFunctions->{(#/.(x^2+y^2)->c^2)&}] Commented Jan 27, 2022 at 20:29
• @MarcoB's solution is explained, somewhat, here Commented Feb 8, 2022 at 21:42