Previous Page Next Page Contents

lhs, rhs -- the left, respectively right hand side of equations, inequalities, relations and ranges

Introduction

lhs(f) returns the left hand side of f.

rhs(f) returns the right hand side of f.

Call(s)

lhs(f)
rhs(f)

Parameters

f - an equation x = y, an inequality x <> y, a relation x < y, a relation x <= y, or a range x..y

Returns

an arithmetical expression.

Overloadable:

f

Related Functions

op

Details

Example 1

We 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 2

We 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:

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000