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; |
| > | Factor(p) mod 7; # to factor over Z_7 |
| > | factor(p); # to factor over the rational numbers |
| > | Factor(p) mod 11; |
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); |
| > | % mod 11; |
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)); |
| > | y := subs(x=alpha,p); |
| > | evala(y); |
The command evala evaluates with algebraic numbers.
| > | q := p/(x-alpha); |
| > | f2 := simplify(q); |
| > | r := (x-alpha)*(x-6*alpha-4); |
The roots of the polynomial p are alpha and 4 + 6*alpha.
| > | p = Expand(r) mod 7; |
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; |
| > | c := -b mod 7; |
| > | 1/c mod 7; |
| > | evala(%) mod 7; |
| > | d := Expand(1/c) mod 7; |
| > | Expand(d*c) mod 7; |
2. Complex Numbers
Because of their importance, we have special facilities to deal with complex numbers.
| > | I^2; # I is sqrt(-1) |
| > | z := 3 + 7*I; |
| > | polar_z := abs(z)*exp(I*argument(z)); |
| > | abs(z); # length of the number or modulus |
| > | argument(z); # argument of the number |
To evaluate complex functions at complex arguments, we use evalc:
| > | sin(z); |
| > | evalc(sin(z)); |
The problem with complex numbers is that the sqrt is multivalued:
| > | sqrt(x^2); |
| > | simplify(%); |
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; |
| > | sqrt(a); sqrt(b); |
The -1+I and the 1-I are the two square roots of -2*I.
| > | r1 := RootOf(x^2 - a, index=1); # first root |
| > | r2 := RootOf(x^2 - a, index=2); # second root |
| > | evalf(r1); evalf(r2); |
The sqrt over the complex numbers takes two values. It is a multivalued function.