The Domains Package
This example worksheet demonstrates commands from the Domains package. The Domains package can be used to create domains of computation and then develop code for complicated algorithms.
>
|
|
>
|
|
---------------------- Domains version 1.0 ---------------------
Initially defined domains are Z and Q the integers and rationals
Abbreviations, e.g. DUP for DenseUnivariatePolynomial, also made
| |
|
Basic Examples Using Domains Z and Q
|
|
The domains Z (the integers) and Q (the rationals) have been defined. Let's do some operations.
>
|
|
| (1.1) |
>
|
|
| (1.2) |
What are the objects Z and Q? Z and Q are Maple tables
>
|
|
| (1.3) |
The table contains operations (Maple procedures) for computing in Z and Q. What operations are available?
>
|
|
` Signatures for constructor Z`
` note: operations prefixed by -- are not available`
` * : (Z,Z*) -> Z`
` * : (Integers,Z) -> Z`
` + : (Z,Z*) -> Z`
` - : Z -> Z`
` - : (Z,Z) -> Z`
` 0 : Z`
` 1 : Z`
` < : (Z,Z) -> Boolean`
` <= : (Z,Z) -> Boolean`
` <> : (Z,Z) -> Boolean`
` = : (Z,Z) -> Boolean`
` > : (Z,Z) -> Boolean`
` >= : (Z,Z) -> Boolean`
` Abs : Z -> Z`
` Characteristic : Integers`
` Coerce : Integers -> Z`
` Div : (Z,Z) -> Union(Z,FAIL)`
` EuclideanNorm : Z -> Integers`
` Factor : Z -> [Z,[[Z,Integers]*]]`
` Gcd : Z* -> Z`
` Gcdex : (Z,Z,Name) -> Z`
` Gcdex : (Z,Z,Name,Name) -> Z`
` Input : Expression -> Union(Z,FAIL)`
` Inv : Z -> Union(Z,FAIL)`
` Lcm : Z* -> Z`
` Max : (Z,Z*) -> Z`
` Min : (Z,Z*) -> Z`
` Modp : (Z,Z) -> Z`
` Mods : (Z,Z) -> Z`
` ModularHomomorphism : () -> (Z -> Z,Z)`
` Normal : Z -> Z`
` Output : Z -> Expression`
` Powmod : (Z,Integers,Z) -> Z`
` Prime : Z -> Boolean`
` Quo : (Z,Z) -> Z`
` Quo : (Z,Z,Name) -> Z`
` Random : () -> Z`
` RelativelyPrime : (Z,Z) -> Boolean`
` Rem : (Z,Z) -> Z`
` Rem : (Z,Z,Name) -> Z`
` Sign : Z -> UNION(1,-1,0)`
` SmallerEuclideanNorm : (Z,Z) -> Boolean`
` Sqrfree : Z -> [Z,[[Z,Integers]*]]`
` Type : Expression -> Boolean`
` Unit : Z -> Z`
` UnitNormal : Z -> [Z,Z,Z]`
` Zero : Z -> Boolean`
` ^ : (Z,Integers) -> Z`
| |
|
|
Creating Domains
|
|
Let's do some operations in Q[x], i.e. univariate polynomials over Q. First we have to create the domain Q[x]; let's call it C.
>
|
|
The name DenseUnivariatePolynomial indicates that the data structure being used is a dense one. Let's input a polynomial.
>
|
|
| (2.1) |
What can we do with the polynomial m?
>
|
|
| (2.2) |
>
|
|
| (2.3) |
What other operations are there for univariate polynomials? A list of the operations is given by show(C,operations);
>
|
|
| (2.4) |
Every Domains domain has a Random function which returns a randomly generated element from a domain, which is useful for writing documentation examples! Domains can also compute with matrices and other objects. Let's compute the inverse of a 3 by 3 Hilbert matrix using Domains. First, we must create the matrix domain.
>
|
|
>
|
|
| (2.5) |
>
|
|
| (2.6) |
>
|
|
| (2.7) |
Let's now compute with matrices of polynomials in Q[x]. Let's use 2 by 2 matrices to keep the examples small.
>
|
|
>
|
|
| (2.8) |
>
|
|
| (2.9) |
>
|
|
Error, (in Domains:-notImplemented) operation is not implemented
| |
That's right, you can't compute the inverse of a matrix of polynomials, because the result is in general a rational function. Now let us demonstrate the power of Domains by doing the same Matrix problems with a Matrix of different entries, this time algebraic numbers. For example, suppose we want to compute with the roots of the polynomial . In Maple one uses the RootOf function as follows
>
|
|
>
|
|
| (2.10) |
In Domains, we will create a simple algebraic extension using the polynomial as the minimal polynomial thus
>
|
|
>
|
|
| (2.11) |
>
|
|
| (2.12) |
Domains generalizes very naturally to compute over F
>
|
|
>
|
|
| (2.13) |
>
|
|
| (2.14) |
>
|
|
| (2.15) |
|
|
Examples with Univariate Power Series
|
|
For our last examples, some calculations with univariate power series. First let's create a univariate power series domain in x over Q.
>
|
|
` Signatures for constructor PS`
` note: operations prefixed by -- are not available`
` * : (PS,PS*) -> PS`
` * : (Integers,PS) -> PS`
` + : (PS,PS*) -> PS`
` - : PS -> PS`
` - : (PS,PS) -> PS`
` / : (PS,PS) -> PS`
` / : (PS,Integers) -> PS`
` 0 : PS`
` 1 : PS`
` <> : (PS,PS) -> Boolean`
` = : (PS,PS) -> Boolean`
` -- AbsoluteDegree : Integers`
` Characteristic : Integers`
` Coeff : (PS,Integers) -> Q`
` CoefficientRing : Ring`
` Coerce : Integers -> PS`
` Constant : Q -> PS`
` Cos : PS -> Union(PS,FAIL)`
` Cosh : PS -> Union(PS,FAIL)`
` Diff : PS -> PS`
` Div : (PS,PS) -> Union(PS,FAIL)`
` EuclideanNorm : PS -> Integers`
` Exp : PS -> Union(PS,FAIL)`
` Factor : PS -> [PS,[[PS,Integers]*]]`
` Gcd : PS* -> PS`
` Gcdex : (PS,PS,Name) -> PS`
` Gcdex : (PS,PS,Name,Name) -> PS`
` Input : Expression -> Union(PS,FAIL)`
` Integrate : PS -> Union(PS,FAIL)`
` Inv : PS -> PS`
` Lcm : PS* -> PS`
` Ln : PS -> Union(PS,FAIL)`
` Log : PS -> Union(PS,FAIL)`
` Lorder : PS -> Integers`
` Monomial : () -> PS`
` Monomial : Integers -> PS`
` Normal : PS -> PS`
` Output : PS -> Expression`
` Powmod : (PS,Integers,PS) -> PS`
` Prime : PS -> Boolean`
` Quo : (PS,PS) -> PS`
` Quo : (PS,PS,Name) -> PS`
` R* : (Q,PS) -> PS`
` R/ : (PS,Q) -> PS`
` Random : () -> PS`
` RelativelyPrime : (PS,PS) -> Boolean`
` Rem : (PS,PS) -> PS`
` Rem : (PS,PS,Name) -> PS`
` Series : [[Q,Integers]] -> PS`
` Shift : (PS,Integers) -> PS`
` Sin : PS -> Union(PS,FAIL)`
` Sinh : PS -> Union(PS,FAIL)`
` SmallerEuclideanNorm : (PS,PS) -> Boolean`
` Sqrfree : PS -> [PS,[[PS,Integers]*]]`
` Tan : PS -> Union(PS,FAIL)`
` Tanh : PS -> Union(PS,FAIL)`
` Type : Expression -> Boolean`
` Unit : PS -> PS`
` UnitNormal : PS -> [PS,PS,PS]`
` Variable : Name`
` ^ : (PS,PS) -> PS`
` ^ : (PS,Integers) -> PS`
` ^ : (PS,Rationals) -> PS`
` order : PS -> Integers`
| |
Let's compute the series for
>
|
|
| (3.1) |
>
|
|
| (3.2) |
>
|
|
| (3.3) |
Lazy univariate power series are "lazy" which means coefficients are computed on demand; that is, we can compute a series to higher order without having to recompute any previously computed coefficients.
>
|
|
| (3.4) |
Here are the Legendre polynomials computed from their generating function:
First create the domain: LUPS == LazyUnivariatePowerSeries
>
|
|
| (3.5) |
>
|
|
| (3.6) |
Compare the output from Domains with that from Maple
>
|
|
| (3.7) |
>
|
|
|
Return to Index for Example Worksheets
|