For 2ab/(a+b). I would like to do a substitution, say I set z=a+b. I want the computer to know that a=z-b resulting in 2(z-b)b/z, then 2(bz-b^2)/z and so on.
Thanks
In[1]:= Solve[{f == 2 a b/(a + b), z == a + b}, f, a]
During evaluation of In[1]:= Solve::bdomv: Warning: a is not a valid domain specification. Mathematica is assuming it is a variable to eliminate. >> Out[1]= {{f -> (2 (-b^2 + b z))/z}}
another way
Clear[a, b] expr = 2 a b/(a + b); replace = z == a + b; expr /. a -> (a /. First@Solve[replace, a]) (* (2*b*(-b + z))/z *)