 Domains - Maple Programming Help

Home : Support : Online Help : Programming : Domains : Domains/evaldomains

Domains

 evaldomains
 evaluation of Maple-expressions in a Domains domain

 Calling Sequence evaldomains[D](expr)

Parameters

 expr - Maple-expression D - Domains domain

Description

 • evaldomains[D](expr) evaluates the Maple-expression expr in the Domains domain D and returns a Maple-expression. evaldomains provides a Maple-like user-interface, data-encapsulation and type-checking for the arguments of Domains-functions. It is intended to simplify interactive use of Domains and is not intended to be used as a coding tool for writing Domains programs.
 • domain-Input/Output functions are implicitly applied during evaluation of the expression, hiding the data-representation of domain-elements. The type of arguments passed to domain-operations is checked against the signatures of the operations. The signatures of the domain operations are accessible through the command show(D, operations).
 • All the operations within expr are assumed to be operations in the specified Domains-domain D.
 • The following example shows the difference at the user-interface level:
 > domain := DenseUnivariatePolynomial (Zmod(7), x):
 Using Domains syntax:
 > domain[Output](domain[*](domain[Input](x^2-3*x+1),domain[Input](2*x^3-4)));
 Using the more familiar Maple syntax:
 > evaldomains[domain]((x^2-3*x+1)*(2*x^3-4));
 • If evaluations of several expressions in one domain are to be performed, it is often preferable to create a domain-evaluator with the use of aliases:
 > alias (dup = evaldomains[domain]):
 • Since the expression passed to evaldomains is first processed by the Maple parser, the user has to be aware of the built-in simplifications, reordering of operands and evaluation of top-level functions. Hence, the following is always simplified to 0.
 > evaldomains[domain] (Random() - Random());
 • An example for evaluation of top-level functions within the call of evaldomains can be obtained by the following
 > galoisfield := GaloisField (13, 2):
 > evaldomains[galoisfield](order(Random()));
 • which results in an error, since order is a builtin top-level function which will be evaluated before the expression is passed to evaldomains. In order to prevent such behavior, the user is advised to use forward quotes where necessary.
 > evaldomains[galoisfield]('order'(Random())); ...
 • Furthermore, if the domain has non-commutative multiplication or addition, the &-version of the operator has to be used in order to prevent reordering of the operands, e.g.
 > Sm := SquareMatrix (2, Z): alias (sm = evaldomains[Sm]):
 > A := sm (Random());
 ${A}{≔}\left[\left[{-85}{,}{-55}\right]{,}\left[{-37}{,}{-35}\right]\right]$ (1)
 > sm (A &* (A + 1));
 $\left[\left[{9175}{,}{6545}\right]{,}\left[{4403}{,}{3225}\right]\right]$ (2)
 • evaldomains is only available after performing the command with(Domains).

Examples

 > $\mathrm{with}\left(\mathrm{Domains}\right):$
 ---------------------- Domains version 1.0 --------------------- Initially defined domains are Z and Q the integers and rationals Abbreviations, e.g. DUP for DenseUnivariatePolynomial, also made
 > $\mathrm{Dup}≔\mathrm{DUP}\left(\mathrm{Zmod}\left(7\right),x\right):$

Create a Dup-evaluator using the alias statement

 > $\mathrm{alias}\left(\mathrm{dup}=\mathrm{evaldomains}\left[\mathrm{Dup}\right]\right):$
 > $\mathrm{dup}\left(\mathrm{Rem}\left(-{x}^{7}+4{x}^{3}-2,{x}^{3}+3x\right)\left({x}^{3}+x-6\right)\right)$
 ${{x}}^{{4}}{+}{5}{}{{x}}^{{3}}{+}{{x}}^{{2}}{+}{6}{}{x}{+}{5}$ (3)

evaldomains outputs even compound data-structures and ...

 > $\mathrm{dup}\left(\mathrm{Factor}\left({x}^{7}+3{x}^{4}+6{x}^{3}+6{x}^{5}+{x}^{2}+x+2{x}^{6}+1\right)\right)$
 $\left[{1}{,}\left[\left[{x}{+}{6}{,}{1}\right]{,}\left[{x}{+}{2}{,}{1}\right]{,}\left[{{x}}^{{4}}{+}{5}{}{x}{+}{3}{,}{1}\right]{,}\left[{x}{+}{1}{,}{1}\right]\right]\right]$ (4)

call-by-name parameters nicely (ie. not in their internal representation)

 > $\mathrm{dup}\left(\mathrm{Gcdex}\left(3{x}^{2}-x-3,2{x}^{3}+2{x}^{2}+3x+5,'u','v'\right)\right)$
 ${5}{+}{x}$ (5)
 > $u,v$
 ${5}{+}{2}{}{x}{,}{4}$ (6)
 > $\mathrm{Gi}≔\mathrm{Gaussian}\left(\mathrm{Zmod}\left(5\right)\right):$
 > $\mathrm{alias}\left(\mathrm{gi}=\mathrm{evaldomains}\left[\mathrm{Gi}\right]\right):$
 > $a≔\mathrm{gi}\left(2+3I\right);$$b≔\mathrm{gi}\left(2-I\right)$
 ${a}{≔}{2}{+}{3}{}{\mathrm{_i}}$
 ${b}{≔}{2}{+}{4}{}{\mathrm{_i}}$ (7)
 > $c≔\mathrm{gi}\left(a+ab\right);$$\mathrm{cc}≔\mathrm{gi}\left(\mathrm{Conj}\left(a+ab\right)\right)$
 ${c}{≔}{4}{+}{2}{}{\mathrm{_i}}$
 ${\mathrm{cc}}{≔}{4}{+}{3}{}{\mathrm{_i}}$ (8)

Re and Im are also top-level Maple functions which must be quoted in order to prevent evaluation by the Maple parser

 > $\mathrm{gi}\left(c\mathrm{cc}={\mathrm{Coerce}\left('\mathrm{\Re }'\left(c\right)\right)}^{2}+{\mathrm{Coerce}\left('\mathrm{\Im }'\left(c\right)\right)}^{2}\right)$
 ${\mathrm{true}}$ (9)