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

## A short demonstration

An important thing: all objects in FriCAS 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 FriCAS not to display the result. Thus, only its type is shown:

fricas
n := 4;
Type: PositiveInteger?

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] (1)
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 FriCAS you do not need to use parenthesis if the function takes only one argument:

fricas
Q M (2)
Type: SquareMatrix?(4,Fraction(Polynomial(Integer)))

Some matrix computations under TeXmacs (this is old screenshot from Axiom era). Notice the hierarchical editing capabilities of TeXmacs (again this is old screenshot from Axiom era). Some more complicated computations:

fricas
)cl all
All user variables and function definitions have been cleared.
Word := FreeMonoid(Symbol) (3)
Type: Type
fricas
poly:= XPR(Integer,Word) (4)
Type: Type
fricas
p:poly := 2 * x - 3 * y + 1 (5)
Type: XPolynomialRing?(Integer,FreeMonoid(Symbol))
fricas
q:poly := 2 * x + 1 (6)
Type: XPolynomialRing?(Integer,FreeMonoid(Symbol))
fricas
p + q (7)
Type: XPolynomialRing?(Integer,FreeMonoid(Symbol))
fricas
p * q (8)
Type: XPolynomialRing?(Integer,FreeMonoid(Symbol))
fricas
(p +q)^2 -p^2 -q^2 - 2*p*q (9)
Type: XPolynomialRing?(Integer,FreeMonoid(Symbol))
fricas
M := SquareMatrix(2,Fraction Integer) (10)
Type: Type
fricas
poly1:= XPR(M,Word) (11)
Type: Type
fricas
m1:M := matrix [[i*j^2 for i in 1..2] for j in 1..2] (12)
Type: SquareMatrix?(2,Fraction(Integer))
fricas
m2:M := m1 - 5/4 (13)
Type: SquareMatrix?(2,Fraction(Integer))
fricas
m3: M := m2^2 (14)
Type: SquareMatrix?(2,Fraction(Integer))
fricas
pm:poly1   := m1*x + m2*y + m3*z - 2/3 (15)
Type: XPolynomialRing?(SquareMatrix?(2,Fraction(Integer)),FreeMonoid(Symbol))
fricas
qm:poly1 := pm - m1*x (16)
Type: XPolynomialRing?(SquareMatrix?(2,Fraction(Integer)),FreeMonoid(Symbol))
fricas
qm^3 (17)
Type: XPolynomialRing?(SquareMatrix?(2,Fraction(Integer)),FreeMonoid(Symbol))

 Subject:   Be Bold !! ( 15 subscribers )