> with(linalg):

Here we study computations in the field Q(a=sqrt(2),b=sqrt(3)). Let M be the submodule spanned by

1, a and N that spanned by 1, b. Then MN is spanned by 1, a, b, ab. First we write the matrices

corresponding to the action of a and b respectively on this generating set.

a:=matrix(4,4,[[0,1,0,0],[2,0,0,0],[0,0,0,1],[0,0,2,0]]);

a := matrix([[0, 1, 0, 0], [2, 0, 0, 0], [0, 0, 0, ...

> b:=matrix(4,4,[[0,0,1,0],[0,0,0,1],[3,0,0,0],[0,3,0,0]]);

b := matrix([[0, 0, 1, 0], [0, 0, 0, 1], [3, 0, 0, ...

Now we can calculate the characteristic polynomial of the sum and product of a and b.

> evalm(a+b);

matrix([[0, 1, 1, 0], [2, 0, 0, 1], [3, 0, 0, 1], [...

>

>

> charpoly(%,x);

x^4-10*x^2+1

We can verify that this polynomial has a+b as a root:

> subs(x=sqrt(2)+sqrt(3),%);

(sqrt(2)+sqrt(3))^4-10*(sqrt(2)+sqrt(3))^2+1

> simplify(%);

0

Now we can work out the case of ab:

> multiply(a,b);

matrix([[0, 0, 0, 1], [0, 0, 2, 0], [0, 3, 0, 0], [...

> charpoly(%,t);

t^4-12*t^2+36

>

> subs(t=sqrt(6),%);

0