Re: extracting lhs or rhs of equations
- To: mathgroup at smc.vnet.net
- Subject: [mg16889] Re: [mg16853] extracting lhs or rhs of equations
- From: BobHanlon at aol.com
- Date: Mon, 5 Apr 1999 02:24:25 -0400
- Sender: owner-wri-mathgroup at wolfram.com
In a message dated 4/2/99 4:24:32 AM, johnson at ae.msstate.edu writes:
>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