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

This page demonstrates some features of FriCAS.

Let's begin with the construction of a polynomial ring R in the indeterminate z with coefficients from the ring S of square matrices with entries that are polynomials P=F[x] where F is the Galois field with 3 elements.

fricas
F := PrimeField 3

\label{eq1}\hbox{\axiomType{PrimeField}\ } (3)(1)
Type: Type
fricas
P := UnivariatePolynomial(x, F)

\label{eq2}\hbox{\axiomType{UnivariatePolynomial}\ } (x , \hbox{\axiomType{PrimeField}\ } (3))(2)
Type: Type
fricas
S := SquareMatrix(2, P)

\label{eq3}\hbox{\axiomType{SquareMatrix}\ } (2, \hbox{\axiomType{UnivariatePolynomial}\ } (x , \hbox{\axiomType{PrimeField}\ } (3)))(3)
Type: Type
fricas
R := UnivariatePolynomial(z, S)

\label{eq4}\hbox{\axiomType{UnivariatePolynomial}\ } (z , \hbox{\axiomType{SquareMatrix}\ } (2, \hbox{\axiomType{UnivariatePolynomial}\ } (x , \hbox{\axiomType{PrimeField}\ } (3))))(4)
Type: Type

OK, now we have the type R. Let's construct an element. We start with constructing some coefficients first.

fricas
s1:S := matrix[[2*x +1 ,x^2-1],[0,x-1]]

\label{eq5}\left[ 
\begin{array}{cc}
{{2 \  x}+ 1}&{{{x}^{2}}+ 2}
\
0 &{x + 2}
(5)
Type: SquareMatrix?(2,UnivariatePolynomial(x,PrimeField?(3)))
fricas
s2 := transpose s1

\label{eq6}\left[ 
\begin{array}{cc}
{{2 \  x}+ 1}& 0 
\
{{{x}^{2}}+ 2}&{x + 2}
(6)
Type: SquareMatrix?(2,UnivariatePolynomial(x,PrimeField?(3)))

And now we build the polynomial.

fricas
r: R := z^2 + s1*z + s2

\label{eq7}\begin{array}{@{}l}
\displaystyle
{{z}^{2}}+{{\left[ 
\begin{array}{cc}
{{2 \  x}+ 1}&{{{x}^{2}}+ 2}
\
0 &{x + 2}
(7)
Type: UnivariatePolynomial(z,SquareMatrix?(2,UnivariatePolynomial(x,PrimeField?(3))))

Of course, since we work in characteristic 3, the following sum must be zero.

fricas
r+ 2*r

\label{eq8}0(8)
Type: UnivariatePolynomial(z,SquareMatrix?(2,UnivariatePolynomial(x,PrimeField?(3))))

Note that this is not the integer 0, but it is still a polynomial of type R.

Asking for the degree of r is no problem, because R is a univariate polynomial ring.

fricas
degree r

\label{eq9}2(9)
Type: PositiveInteger?

Let us add 1 to r.

fricas
r+1

\label{eq10}\begin{array}{@{}l}
\displaystyle
{{z}^{2}}+{{\left[ 
\begin{array}{cc}
{{2 \  x}+ 1}&{{{x}^{2}}+ 2}
\
0 &{x + 2}
(10)
Type: UnivariatePolynomial(z,SquareMatrix?(2,UnivariatePolynomial(x,PrimeField?(3))))

Oh, interesting, FriCAS figured out that by 1 we actually meant the polynomial 1 in R.

fricas
one: R := 1

\label{eq11}\left[ 
\begin{array}{cc}
1 & 0 
\
0 & 1 
(11)
Type: UnivariatePolynomial(z,SquareMatrix?(2,UnivariatePolynomial(x,PrimeField?(3))))

No no, it is not the unit square matrix. It is the unit square matrix multiplied by z^0. Look at the type.

So let's see what happens if we multiply r by itself.

fricas
r2 := r*r

\label{eq12}\begin{array}{@{}l}
\displaystyle
{{z}^{4}}+{{\left[ 
\begin{array}{cc}
{x + 2}&{{2 \ {{x}^{2}}}+ 1}
\
0 &{{2 \  x}+ 1}
(12)
Type: UnivariatePolynomial(z,SquareMatrix?(2,UnivariatePolynomial(x,PrimeField?(3))))

Well, of course there is a common factor of r_2 an r. Can FriCAS find it?

fricas
gcd(r2, r)
There are 4 exposed and 3 unexposed library operations named gcd having 2 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op gcd to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation.
Cannot find a definition or applicable library operation named gcd with argument type(s) UnivariatePolynomial(z,SquareMatrix(2,UnivariatePolynomial(x,PrimeField(3)))) UnivariatePolynomial(z,SquareMatrix(2,UnivariatePolynomial(x,PrimeField(3))))
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need.

Ooops. What does that say?:

  Cannot find a definition or applicable library operation named gcd.

Ah, of course, the coefficient ring of R is the matrix ring S and this is unfortunately not a field (not even an integral domain), so we cannot simply apply Euclid's algorithm. FriCAS simply stops by telling you that there is no applicable operation.

Of course, FriCAS can compute a gcd of univariate polynomials.

fricas
p1:=s1(1,1)

\label{eq13}{2 \  x}+ 1(13)
Type: UnivariatePolynomial(x,PrimeField?(3))
fricas
p2:=s1(1,2)

\label{eq14}{{x}^{2}}+ 2(14)
Type: UnivariatePolynomial(x,PrimeField?(3))
fricas
gcd(p1,p2)

\label{eq15}x + 2(15)
Type: UnivariatePolynomial(x,PrimeField?(3))

OK, let us do that again.

fricas
q1: UP(x, INT) := 2*x+1

\label{eq16}{2 \  x}+ 1(16)
Type: UnivariatePolynomial(x,Integer)
fricas
q2: UP(x, INT) := x^2+2

\label{eq17}{{x}^{2}}+ 2(17)
Type: UnivariatePolynomial(x,Integer)
fricas
gcd(q1,q2)

\label{eq18}1(18)
Type: UnivariatePolynomial(x,Integer)

Nice! Depending on where I compute these polynomials either have a common factor or are coprime.

Well, all depends on the underlying ring, of course.




  Subject:   Be Bold !!
  ( 14 subscribers )  
Please rate this page: