lhs, rhs -- the left,
respectively right hand side of equations, inequalities, relations and
ranges
Introductionlhs(f) returns the left hand side of
f.
rhs(f) returns the right hand side of
f.
Call(s)lhs(f)
rhs(f)
Parametersf |
- | an equation x = y, an inequality x
<> y, a relation x < y, a relation x
<= y, or a range x..y |
Returnsf
Related
Functions
Detailslhs(f) and rhs(f) are
equivalent to the direct calls op(f, 1) and op(f,
2), respectively, of the operand function op.
Example
1We extract the left and right hand sides of various objects:
>> lhs(x = sin(2)), lhs(3.14 <> PI), lhs(x + 3 < 2*y), rhs(a <= b), rhs(m-1..n+1)
x, 3.14, x + 3, b, n + 1
The operands of an expression depend on its internal representation. In particular, a ``greater'' relation is always converted to the corresponding ``less'' relation:
>> y > -infinity; lhs(y > -infinity)
-infinity < y
-infinity
>> y >= 4; rhs(y >= 4)
4 <= y
y
Example
2We extract the left and right hand sides of the solution of the following system:
>> s := solve({x + y = 1, 2*x - 3*y = 2})
{[x = 1, y = 0]}
>> map(op(s), lhs) = map(op(s), rhs)
[x, y] = [1, 0]
Calls to lhs and rhs may be
easier to read than the equivalent calls to the operand function
op:
>> map(op(s), op, 1) = map(op(s), op, 2)
[x, y] = [1, 0]
However, direct calls to op should be preferred inside procedures
for higher efficiency.
>> delete s:
lhs and rhs are new functions.