Section9.19

]>
Book Contents Previous Section 9.18 EqTable Next Section 9.20 Exit Book Index

## 9.19 Equation

The Equation domain provides equations as mathematical objects. These are used, for example, as the input to various solvesolveTransSolvePackage operations.

Equations are created using the equals symbol, =.

eq1 := 3*x + 4*y = 5

4 y+3 x=5

Type: Equation Polynomial Integer
eq2 := 2*x + 2*y = 3

2 y+2 x=3

Type: Equation Polynomial Integer

The left- and right-hand sides of an equation are accessible using the operations lhslhsEquation and rhsrhsEquation.

lhs eq1

4 y+3 x

Type: Polynomial Integer
rhs eq1

5

Type: Polynomial Integer

Arithmetic operations are supported and operate on both sides of the equation.

eq1 + eq2

6 y+5 x=8

Type: Equation Polynomial Integer
eq1 * eq2

8 y 2+14 x y+6 x 2=15

Type: Equation Polynomial Integer
2*eq2 - eq1

x=1

Type: Equation Polynomial Integer

Equations may be created for any type so the arithmetic operations will be defined only when they make sense. For example, exponentiation is not defined for equations involving non-square matrices.

eq1**2

16 y 2+24 x y+9 x 2=25

Type: Equation Polynomial Integer

Note that an equals symbol is also used to test for equality of values in certain contexts. For example, x+1 and y are unequal as polynomials.

if x+1 = y then "equal" else "unequal"

"unequal"

Type: String
eqpol := x+1 = y

x+1=y

Type: Equation Polynomial Integer

If an equation is used where a Boolean value is required, then it is evaluated using the equality test from the operand type.

if eqpol then "equal" else "unequal"

"unequal"

Type: String

If one wants a Boolean value rather than an equation, all one has to do is ask!

eqpol::Boolean

false

Type: Boolean
Book Contents Previous Section 9.18 EqTable Next Section 9.20 Exit Book Index