lec4.mws

L-4 MCS 320 Monday 29 August 2005

> restart;

1. Algebraic Numbers

An algebraic number is a root of a polynomial.  First we need to see how to work over finite fields.  Consider for example, Z_7 = {0,1,2,3,4,5,6}.  We can do modulo arithmetic over Z_7:

> 4+8 mod 7;

> 4*8 mod 7;

> 4/8 mod 7;

Unlike the integers, in finite fields, we can divide by numbers and get again a number in the field.

The following commands show the multiplication table of Z_7:

> printf("* : 0 1 2 3 4 5 6\n"):

> for i from 0 to 6 do

>  printf("%d :",i);

>  for j from 0 to 6 do

>    printf("%2d", i*j mod 7);

>  end do;

>  printf("\n");

> end do;

* : 0 1 2 3 4 5 6

0 : 0 0 0 0 0 0 0

1 : 0 1 2 3 4 5 6

2 : 0 2 4 6 1 3 5

3 : 0 3 6 2 5 1 4

4 : 0 4 1 5 2 6 3

5 : 0 5 3 1 6 4 2

6 : 0 6 5 4 3 2 1

This execution group can be considered as one statement, it shows the multiplication table for the finite field Z_7.

We will add numbers to this field by considering roots of polynomials:

> p := x^2 + 3*x + 5;

p := x^2+3*x+5

> Factor(p) mod 7;  # to factor over Z_7

x^2+3*x+5

> factor(p);   # to factor over the rational numbers

x^2+3*x+5

> Factor(p) mod 11;

(x+7)^2

Over Z_7, p does not factor, but over Z_11, we can write p as a product of (x-4)^2.

> subs(x=4,p);

33

> % mod 11;

0

Notice, in order to have a field (where every number has an inverse), we must work with a prime number, like 7 and 11.

If we do not have a root of a polynomial, then we can formally declare alpha as a root:

> alias(alpha=RootOf(p));

alpha

> y := subs(x=alpha,p);

y := alpha^2+3*alpha+5

> evala(y);

0

The command evala evaluates with algebraic numbers.

> q := p/(x-alpha);

q := (x^2+3*x+5)/(x-alpha)

> f2 := simplify(q);

f2 := 3+x+alpha

> r := (x-alpha)*(x-6*alpha-4);

r := (x-alpha)*(x-6*alpha-4)

The roots of the polynomial p are alpha and 4 + 6*alpha.

> p = Expand(r) mod 7;

x^2+3*x+5 = x^2+3*x+5

We can now calculate with this field extension Z_7(alpha), just as we did in Z_7, using the evala or the Expand() mod 7:

> b := alpha+3;

b := alpha+3

> c := -b mod 7;

c := 6*alpha+4

> 1/c mod 7;

1/(6*alpha+4)

> evala(%) mod 7;

3*alpha

> d := Expand(1/c) mod 7;

d := 3*alpha

> Expand(d*c) mod 7;

1

2. Complex Numbers

Because of their importance, we have special facilities to deal with complex numbers.

> I^2;  # I is sqrt(-1)

-1

> z := 3 + 7*I;

z := 3+7*I

> polar_z := abs(z)*exp(I*argument(z));

polar_z := 3+7*I

> abs(z);  # length of the number or modulus

58^(1/2)

> argument(z); # argument of the number

arctan(7/3)

To evaluate complex functions at complex arguments, we use evalc:

> sin(z);

sin(3+7*I)

> evalc(sin(z));

sin(3)*cosh(7)+cos(3)*sinh(7)*I

The problem with complex numbers is that the sqrt is multivalued:

> sqrt(x^2);

(x^2)^(1/2)

> simplify(%);

csgn(x)*x

From this simplify, we see that sqrt(x^2) is not really equal to x when x is complex.

> a := (-1+I)^2; b := (1-I)^2;

a := -2*I

b := -2*I

> sqrt(a); sqrt(b);

1-I

1-I

The -1+I and the 1-I are the two square roots of -2*I.

> r1 := RootOf(x^2 - a, index=1); # first root

r1 := RootOf(_Z^2+2*I, index = 1)

> r2 := RootOf(x^2 - a, index=2); # second root

r2 := RootOf(_Z^2+2*I, index = 2)

> evalf(r1); evalf(r2);

1.0-1.000000000*I

-1.0+1.000000000*I

The sqrt over the complex numbers takes two values.  It is a multivalued function.