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:
fricas
n := 4;
We define an abbreviation: let SM
be the ring of quadratic matrices with rational functions as entries:
fricas
SM ==> SquareMatrix(n, FRAC POLY INT)
Type: Void
Let M
be a generic matrix:
fricas
M: SM := matrix [[a[i,j] for j in 1..n] for i in 1..n]
Type: SquareMatrix
?(4,
Fraction(Polynomial(Integer)))
Compute the characteristis polynomial of 'M':
fricas
P := determinant (M - x * 1);
Type: Fraction(Polynomial(Integer))
We now interpret P
as univariate polynomial in x
, coefficients being from the matrices. The double colon performs this coercion:
fricas
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:
fricas
Q M
Type: SquareMatrix
?(4,
Fraction(Polynomial(Integer)))
Some matrix computations under OldTeXmacs?.
Notice the hierarchical editing capabilities of OldTeXmacs?.
Some more complicated computations:
fricas
)cl all
All user variables and function definitions have been cleared.
Word := OrderedFreeMonoid(Symbol)
Type: Type
fricas
poly:= XPR(Integer,Word)
Type: Type
fricas
p:poly := 2 * x - 3 * y + 1
Type: XPolynomialRing
?(Integer,
OrderedFreeMonoid
?(Symbol))
fricas
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
Type: XPolynomialRing
?(Integer,
OrderedFreeMonoid
?(Symbol))
fricas
p + q
Type: XPolynomialRing
?(Integer,
OrderedFreeMonoid
?(Symbol))
fricas
p * q
Type: XPolynomialRing
?(Integer,
OrderedFreeMonoid
?(Symbol))
fricas
(p +q)^2 -p^2 -q^2 - 2*p*q
Type: XPolynomialRing
?(Integer,
OrderedFreeMonoid
?(Symbol))
fricas
M := SquareMatrix(2,Fraction Integer)
Type: Type
fricas
poly1:= XPR(M,Word)
Type: Type
fricas
m1:M := matrix [[i*j**2 for i in 1..2] for j in 1..2]
There are no library operations named **
Use HyperDoc Browse or issue
)what op **
to learn if there is any operation containing " ** " in its name.
Cannot find a definition or applicable library operation named **
with argument type(s)
PositiveInteger
PositiveInteger
Perhaps you should use "@" to indicate the required return type,
or "$" to specify which version of the function you need.
FriCAS will attempt to step through and interpret the code.
There are no library operations named **
Use HyperDoc Browse or issue
)what op **
to learn if there is any operation containing " ** " in its name.
Cannot find a definition or applicable library operation named **
with argument type(s)
PositiveInteger
PositiveInteger
Perhaps you should use "@" to indicate the required return type,
or "$" to specify which version of the function you need.
m2:M := m1 - 5/4
m1 is declared as being in SquareMatrix(2,Fraction(Integer)) but has
not been given a value.
m3: M := m2**2
m2 is declared as being in SquareMatrix(2,Fraction(Integer)) but has
not been given a value.
pm:poly1 := m1*x + m2*y + m3*z - 2/3
Type: XPolynomialRing
?(SquareMatrix
?(2,
Fraction(Integer)),
OrderedFreeMonoid
?(Symbol))
fricas
qm:poly1 := pm - m1*x
Type: XPolynomialRing
?(SquareMatrix
?(2,
Fraction(Integer)),
OrderedFreeMonoid
?(Symbol))
fricas
qm**3
There are no library operations named **
Use HyperDoc Browse or issue
)what op **
to learn if there is any operation containing " ** " in its name.
Cannot find a definition or applicable library operation named **
with argument type(s)
XPolynomialRing(SquareMatrix(2,Fraction(Integer)),OrderedFreeMonoid(Symbol))
PositiveInteger
Perhaps you should use "@" to indicate the required return type,
or "$" to specify which version of the function you need.