might be useful

• To: mathgroup at smc.vnet.net
• Subject: [mg110293] might be useful
• From: Peter Pein <petsie at dordos.net>
• Date: Sat, 12 Jun 2010 05:31:33 -0400 (EDT)

```As apology for my silly question, I'd like to provide a code snippet I
wrote a while ago.
Sometimes the problem arises to solve an equation/a set of equations
not for a variable, but for an expression. Examples:

In[1]:= Isolate[eqn:(_Equal|{_Equal ..}),expr_,elim_:{}]:=
Block[{tmp},
Solve[GroebnerBasis[Subtract@@@Flatten[{eqn,tmp==expr}],tmp,
Flatten[{First[Variables[expr]],elim}]]==0,tmp][[1]]/.{Rule->Equal,tmp->expr}]
In[2]:= Isolate[{x^2+3y^2==1,y-x==1/2},2x+y]
Out[2]= {2 x+y==1/8 (-5-3 Sqrt[13])}
In[3]:= Isolate[x^2+3y^2==1,2x+y]
Out[3]= {2 x+y==y-2 Sqrt[1-3 y^2]}
In[4]:= Isolate[{x^2+y^2+z^2==1,r Cos[t]+r Sin[t]==1},x+y,{r,t}]
Out[4]= {x+y==y-Sqrt[1-y^2-z^2]}
or
Isolate[{x^2+y^2+z^2==1,3z-(x+y)^2/2==0},x+y,z]
eliminates z but the answer is a bit lengthy.

If one or some of you want to improve it (and do this successfully),