login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

A short demonstration of Axiom

An important thing: all objects in Axiom have a type. This enables us to give a simple demonstration of the Cayley-Hamilton theorem.

Let n equal 4. The semicolon at the end of the input tells Axiom not to display the result. Thus, only its type is shown:

axiom
n := 4;

We define an abbreviation: let SM be the ring of quadratic LatexWiki Image matrices with rational functions as entries:

axiom
SM ==> SquareMatrix(n, FRAC POLY INT)
Type: Void

Let M be a generic LatexWiki Image matrix:

axiom
M: SM := matrix [[a[i,j] for j in 1..n] for i in 1..n]
LatexWiki Image(1)
Type: SquareMatrix?(4,Fraction Polynomial Integer)

Compute the characteristis polynomial of 'M':

axiom
P := determinant (M - x * 1);
Type: Fraction Polynomial Integer

We now interpret P as univariate polynomial in x, coefficients being from the LatexWiki Image matrices. The double colon performs this coercion:

axiom
Q := P::UP(x, SM);
Type: UnivariatePolynomial(x,SquareMatrix?(4,Fraction Polynomial Integer))

Finally we evaluate this polynomial with the original matrix as argument. In Axiom you do not need to use parenthesis if the function takes only one argument:

axiom
Q M
LatexWiki Image(2)
Type: SquareMatrix?(4,Fraction Polynomial Integer)

Some matrix computations under TeXmacs.

Notice the hierarchical editing capabilities of TeXmacs.

Some more complicated computations:

axiom
)cl all
All user variables and function definitions have been cleared. Word := OrderedFreeMonoid(Symbol)
LatexWiki Image(3)
Type: Domain
axiom
poly:= XPR(Integer,Word)
LatexWiki Image(4)
Type: Domain
axiom
p:poly := 2 * x - 3 * y + 1
LatexWiki Image(5)
Type: XPolynomialRing?(Integer,OrderedFreeMonoid? Symbol)
axiom
1 + 2x - 3y
Cannot find a definition or applicable library operation named 2 with argument type(s) Variable x
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need. q:poly := 2 * x + 1
LatexWiki Image(6)
Type: XPolynomialRing?(Integer,OrderedFreeMonoid? Symbol)
axiom
p + q
LatexWiki Image(7)
Type: XPolynomialRing?(Integer,OrderedFreeMonoid? Symbol)
axiom
p * q
LatexWiki Image(8)
Type: XPolynomialRing?(Integer,OrderedFreeMonoid? Symbol)
axiom
(p +q)^2 -p^2 -q^2 - 2*p*q
LatexWiki Image(9)
Type: XPolynomialRing?(Integer,OrderedFreeMonoid? Symbol)
axiom
M := SquareMatrix(2,Fraction Integer)
LatexWiki Image(10)
Type: Domain
axiom
poly1:= XPR(M,Word)
LatexWiki Image(11)
Type: Domain
axiom
m1:M := matrix [[i*j**2 for i in 1..2] for j in 1..2]
LatexWiki Image(12)
Type: SquareMatrix?(2,Fraction Integer)
axiom
m2:M := m1 - 5/4
LatexWiki Image(13)
Type: SquareMatrix?(2,Fraction Integer)
axiom
m3: M := m2**2
LatexWiki Image(14)
Type: SquareMatrix?(2,Fraction Integer)
axiom
pm:poly1   := m1*x + m2*y + m3*z - 2/3
LatexWiki Image(15)
Type: XPolynomialRing?(SquareMatrix?(2,Fraction Integer),OrderedFreeMonoid? Symbol)
axiom
qm:poly1 := pm - m1*x
LatexWiki Image(16)
Type: XPolynomialRing?(SquareMatrix?(2,Fraction Integer),OrderedFreeMonoid? Symbol)
axiom
qm**3
LatexWiki Image(17)
Type: XPolynomialRing?(SquareMatrix?(2,Fraction Integer),OrderedFreeMonoid? Symbol)




subject:
  ( 6 subscribers )  
Please rate this page: