Replacing composite variables by a single variable
In order to simplify an given expression with several variables, I want to replace a subterm by a new variable. I tried to do the following with Mathematica:
myexpression := <variables, sums, products etc. here, something like a^2+b^2> subterm := <variables, sums, products etc. here, something like a^2> myexpression /. subterm -> newvar
For simple examples this works fine, but for my case it just returns the unchanged expression myexpression.
Can I be sure that the subterm can't be found in myexpression? Is there any good formal definition for "a subterm $t$ can't be found in expression $e$"? (of corse you could replace the first $t$ in $e -t + t = e$, but this is obviously not what we want...)
The code above is a simplified example, the Mathematica code for my specific problem looks like this:
Quit Ra[i_] := ((1 + P[i])/2)*Pa[i] + ((1 - P[i])/2)*Pb[i] Rb[i_] := ((1 - P[i])/2)*Pa[i] + ((1 + P[i])/2)*Pb[i] Rab[i_] := Pab[i] PXa := Ra*Ra + Ra*Rab + Rab*Ra PXab := Ra*Rb + Rb*Ra + Rab*Rab DX := PXa + ((PXab)/2) - (1 + P0)/2 DY[i_] := Pa[i] + ((Pab[i])/2) - (1 + (P0/P[i]))/2 DX /. DY -> DY1 DX /. DY -> DY2