Dom::ExpressionField
--
the domains of expressions forming a fieldDom::ExpressionField
(Normal, IsZero)
creates a domain of expressions forming a field, where the functions
Normal
and IsZero
are used to normalize
expressions and test for zero.
Dom::ExpressionField( <Normal <,
IsZero>>)
Normal |
- | a function used to normalize the expressions of the
domain; default is id . |
IsZero |
- | a function used to test the expressions of the domain
for zero; default is iszero @ Normal . |
Dom::ExpressionField
(Normal, IsZero)
creates a domain which is supposed to be a field, where the field
elements are represented as expressions. The function
Normal
is used to normalize the expressions representing
the elements, the function IsZero
is used to test the
expressions for zero. It is assumed that the field has characteristic
0.id
and
iszero
does not yield a
field really, but it is often convenient and sensible to use the
resulting structure as a field.Normal
must be a function which takes an expression
representing a domain element and returns the normalized expression.
Normal
should return FAIL
if the expression is not
valid.Normal
is not given, then the system function
id
is used, i.e., only the
kernel simplifier is used to normalize expressions.id
is given, it is assumed that this
functions returns a normal form where the zero element is uniquely
represented by the constant 0
.IsZero
must be a function which takes an expression
representing a domain element and returns TRUE
if the expression represents zero
and FALSE
otherwise.IsZero
is not given, then iszero @
Normal
is used for zero testing. If Normal
is equal
to id
this functional
expression is simplified to iszero
.Normal
is equal to id
and IsZero
is equal to
iszero
, a faēcade
domain is created, i.e., the domain elements are simply expressions and
are not explicitly created by new
.
Otherwise the elements of the domain are explicitly created by
new
. Each such element has
one operand, which is the expression representing the domain element.
The element expressions are normalized after each operation using the
function Normal
.
Cat::Field
Dom::ExpressionField
(Normal, IsZero)(e)
creates a field element represented by the expression
e
.
Dom::ExpressionField
(Normal,
IsZero)(e)
e |
- | an expression representing a field element. |
Dom::ExpressionField
(Normal, IsZero)(e)
creates a field element represented by the expression e
.
The expression is normalized using the function
Normal
.Normal
returns FAIL
, it is assumed that the expression
does not represent a valid field element. If this test is not fully
implemented the domain cannot decide if the expression represents a
valid field element. In this case it is up to the user to enter only
valid expressions as field elements.Normal
is equal to id
and IsZero
is equal to
iszero
, the domain is
only a faēcade domain. In this case the expression e
is
returned after being simplified by the built-in kernel simplifier.The characteristic of the fields created by this constructor is
assumed to be 0
.
The element represented by the expression 1
is assumed
to be a neutral element w.r.t. "_mult"
.
The element represented by the expression 0
is assumed
to be a neutral element w.r.t. "_plus"
.
_divide(dom x, dom
y)
x/y
by dividing the expressions representing
x
and y
._divide
, thus may be called via
x/y
or _divide(x, y)
.equal(dom x, dom
y)
x
is mathematically equal to y
.
This is implemented by testing if x-y
is zero.intmult(dom x, DOM_INT n)
x*n
by multiplying the
expression representing x
by n
._invert(dom x)
1/x
of x
by computing
the inverse of the expression representing x
._invert
, thus may be called via
1/x
or _invert(x)
.iszero(dom x)
x
is zero by calling IsZero
with
the expression representing x
as argument.iszero
, thus may be called via
iszero(x)
._leequal(dom x, dom
y)
x
is less than or equal to y
by
mapping the function _leequal
to the arguments._leequal
can only test numbers (in
a syntactical sense), but not constant expressions like PI
or sqrt(2)
._leequal
, thus may be called via
x <= y
, y >= x
or _leequal(x,
y)
._less(dom x, dom
y)
_mult(dom x, ...)
coerce
), the product of the
expressions representing the arguments is calculated using the function
_mult
.
If one of the arguments cannot be coerced, the arguments up to the
offending one are multiplied and then the method "_mult"
of the domain of the offending argument is called to multiply the
remaining arguments.
_mult
, thus may be called via
x*...
or _mult(x,...)
._negate(dom x)
-x
of x
by computing
the negative of the expression representing x
._negate
, thus may be called via
-x
or _negate(x)
.norm(dom x)
x
as the absolute value of the
expression representing x
. See the function abs
for details.norm
, thus may be called via
norm(x)
.norm
, applied to an expression,
computes the norm of that expression interpreted as a polynomial
expression and not the absolute value of the expression. This
may be regarded as an inconsistency.normal(dom x)
x
by applying the function
Normal
to the expression representing x
.normal
, thus may be called via
normal(x)
._plus(
"dom" x, ...)coerce
) the sum of the expressions
representing the arguments is calculated using the function _plus
.
If one of the arguments cannot be coerced the arguments up to the
offending one are added and then the method "_plus"
of the
domain of the offending argument is called to add the remaining
arguments.
_plus
, thus may be called via
x+...
or _plus(x,...)
._power(dom x, any
y)
_power(any x, dom
y)
x
to the power of y
._power
to the expressions
representing the arguments.
If one of the arguments is not of this domain it is coerced to this domain, then the power is computed. If the coercion fails an error is raised.
Note that it is assumed that at least one of the arguments is of this domain.
_power
, thus may be called via
x^y
or _power(x, y)
.random()
Normal
.polylib::randpoly
for details
about creating random polynomials.solve(dom x <, a, ...>)
x = 0
using the standard
solver function solve
.
Maps solve
to the
expression representing x
and the additional arguments and
directly returns the result of solve
.solve
for details
about results and optional additional arguments.solve
, thus may be called via
solve(x,...)
.sqrfree(dom x)
x
by mapping
polylib::sqrfree
to
the expression representing x
.polylib::sqrfree
, thus may be
called via polylib::sqrfree(x)
._subtract(dom x, dom
y)
x-y
by subtracting the expressions
representing x
and y
._subtract
, thus may be called via
x-y
or _subtract(x, y)
.convert(any x)
x
to an element of this domain:
x
is from a domain defined by
Dom::ExpressionField
the expression representing
x
is used as the expression representing the new element
of this domain.x
is converted to an expression using the
function expr
and the
resulting expression is used to represent the new element.FAIL
if the
conversion fails.convert_to(dom x, DOM_DOMAIN T)
x
to an element of the domain
T
:
T
is defined by Dom::ExpressionField
the expression representing x
is used as the expression
representing the new element of T
."convert"
of T
is
called with the expression representing x
as
argument.FAIL
if the
conversion fails.new(any x)
x
:
First the method "convert"
of this domain and then, if
this fails, the method "convert_to"
of the domain of
x
is called. If both methods fail an error is raised.F(x)
where F
is this domain.op(dom x)
x
. The operands are converted to elements of
this domain.op(dom x, NonNegInt
i)
i
of the expression
representing x
. If i
is 0
then
the operator of the expression is returned, which usually is not an
element of this domain. The other operands are converted to elements of
this domain.op
when an element of this domain is
contained, as a subexpression, in the first argument of op
. Operand ranges and paths are handled
by op
and need not be
handled by this method. See op
for details.subs(dom x, equation
e, ...)
x
as specified by the substitution equations
e...
. The equations must be of the form o =
n
, where o
is the original subexpression to replace
and n
is the new value that is inserted instead.subs
to the
expression representing x
. The resulting expression is
converted to an element of this domain.subs
when an element of this domain is
contained, as a subexpression, in the first argument of subs
. See subs
for details.subsex(dom x, equation e, ...)
x
as specified by the substitution equations
e...
. The equations must be of the form o =
n
, where o
is the original partial subexpression to
replace and n
is the new value that is inserted
instead.subsex
to the
expression representing x
. The resulting expression is
converted to an element of this domain.subsex
when an element of this domain
is contained, as a subexpression, in the first argument of subsex
. See subsex
for details.subsop(dom x, equation e)
x
the
operand given by the substitution equation e
. The equation
must be of the form i = v
, where i
is the
index of the operand and v
is its new value.
Maps subsop
to the
expression representing x
. The resulting expression is
converted to an element of this domain.
subsop
when an element of this domain
is contained, as a subexpression, in the first argument of subsop
. Operand ranges and
pathes are handled by subsop
and need not be handled by
this method. See subsop
for details.rationalize(dom x <, a,
...>)
x
by rational numbers. Maps the function numeric::rationalize
to the
expression representing x
. See numeric::rationalize
for
details and additional optional arguments.rationalize
from
the standard library package, but the function numeric::rationalize
from the
numeric
package
instead. Thus the method may be called via
numeric::rationalize(x,...)
.pivotSize(dom x)
length
of
the expression representing x
.Normal
= id
then
Ax::efficientOperation
("_divide")
,
Ax::efficientOperation
("_mult")
,
Ax::efficientOperation
("_invert")
,
Dom::ExpressionField(normal)
creates a
field of rational expressions over the rationals. The expressions
representing the field elements are allways normalized by normal
:
>> Fn := Dom::ExpressionField(normal): a := Fn((x^2 - 1)/(x - 1))
x + 1
The field elements are explicit elements of the domain:
>> domtype(a)
Dom::ExpressionField(normal, iszero@normal)
In the domain Dom::ExpressionField(id,
iszero@normal)
the expressions representing the elements are
normalized by the kernel simplifier only:
>> Fi := Dom::ExpressionField(id, iszero@normal): a := Fi((x^2 - 1)/(x - 1))
2 x - 1 ------ x - 1
The elements of this domain are not normalized (when
viewed as rational expressions over the rationals), thus the domain
does not have the axiom Ax::normalRep
:
>> b := a/Fi(x + 1) - Fi(1)
2 x - 1 --------------- - 1 (x - 1) (x + 1)
But nevertheless this domain also represents the field
of rational expressions over the rationals, because zero is detected
correctly by the function iszero @ normal
:
>> iszero(b)
TRUE
"sign"
, "convert_to"
,
"_less"
, "_leequal"
,
"rationalize"
, "solve"
, "int"
and "limit"
were implemented."Factor"
disappeared. The methods
"factor"
and "sqrfree"
now return objects of
the domain type Factored
."equal"
can return
UNKNOWN
.Normal = id
, then Dom::ExpressionField
has the axiom Ax::efficientOperation
for
division, multiplication and inversion of elements.Dom::ExpressionField(id,iszero)
is printed
as Dom::ExpressionField()
.