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
4y+3x=5 |
Type: Equation Polynomial Integer
eq2 := 2*x + 2*y = 3
2y+2x=3 |
Type: Equation Polynomial Integer
The left- and right-hand sides of an equation are accessible using the operations lhslhsEquation and rhsrhsEquation.
lhs eq1
4y+3x |
Type: Polynomial Integer
rhs eq1
5 |
Type: Polynomial Integer
Arithmetic operations are supported and operate on both sides of the equation.
eq1 + eq2
6y+5x=8 |
Type: Equation Polynomial Integer
eq1 * eq2
8y2+14xy+6x2=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
16y2+24xy+9x2=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