Method 1 (easier to see)
eq1 = (Sin[x] + Cos[x])^2 + 4/(2 + 3*x) == x;
eq1[[1]]
4/(2 + 3*x) + (Cos[x] + Sin[x])^2
eq1[[2]]
x
Method 2 (more in the spirit of Mathematica and pattern matching)
eq1
4/(2 + 3*x) + (Cos[x] + Sin[x])^2 == x
eq1/.(x_ == y__)->x
4/(2 + 3*x) + (Cos[x] + Sin[x])^2
eq1/.(x_ == y_)->y
x
Kevin
----- Original Message -----
From: David P. Johnson <joh...@ae.msstate.edu>
Subject: [mg16853] extracting lhs or rhs of equations
> Let's say I have an expression like:
>
> In[1]:= eq1= Sin[x] == x;
>
> Is there a way to get just the left-hand side or right-hand side of the
> equation? Something like:
>
> In[2]:= LHS[eq1]
> Out[2]:= Sin[x]
>
> TIA.
>
> --
> David
> ->(Signature continues here)
>
>
Hope this helps,
****************************************
Jean-Marie THOMAS
mailto:jmth...@agat.net
Conseil et Audit en Ingenierie de Calcul
Strasbourg, France
http://www.agat.net
****************************************
>Let's say I have an expression like:
>
> In[1]:= eq1= Sin[x] == x;
>
>Is there a way to get just the left-hand side or right-hand side of the
>equation? Something like:
>
> In[2]:= LHS[eq1]
> Out[2]:= Sin[x]
>
David,
eq1= Sin[x] == x;
You can use Part to extract the LHS or RHS.
eq1[[1]]
Sin[x]
First[eq1]
Sin[x]
eq1[[2]]
x
Last[eq1]
x
For more complex expressions, you can use Part to extract any specific part
eqn2 = a*x^2 + b*x + c == 0;
eqn2[[1]]
c + b*x + a*x^2
Table[eqn2[[1,k]], {k, 3}]
{c, b*x, a*x^2}
Table[eqn2[[1,3, k]], {k, 2}]
{a, x^2}
Table[eqn2[[1,3, 2, k]], {k, 2}]
{x, 2}
Bob Hanlon