CZ3106, final exam 2003

1.

x = 1; y = x; x = 2; y

x = 1; y := x;  x = 2;  y

1/2

8^(1/3)

{a, b} c

Plus  @@  {a, b}

Map[#^2 &, {a}]

Map[f, h[a, b]]

Apply[Sqrt,  {4}]

Head[{}]

Head[I]

Clear[x, y]

{x, y}  /.  {x -> y, y -> x}

{x, x,  x}  /.  {z_,  y__}  ->  z

Clear[x, y, z]

{{1, 2}, {2, 3}} . {a, b}

If[i == j, 1, 2, 3]

Union[{a, a, b}]

{a}~Join~{b}

1/3  //  N

f @ x

MatchQ[x, c_. *x]

MatchQ[x, y_]

Solve[x + a == 0, x]

D[Sin[x], {x, 2}]

Integrate[x, x]

Nest[f, x, 2]

Last[f[a, b]]

2.

(a)

integ[f_ + g_,  x_]  :=  integ[f, x] + integ[g, x];
integ[c_*f_, x_]  :=  c * integ[f, x]  /;  FreeQ[c, x]; 
    integ[x_^n_. ,  x_]  :=  (x^(n + 1))/(n + 1)  /;  
        IntegerQ[n]  &&  n  ≥ 0;
integ[c_, x_]  :=  c*x  /;  FreeQ[c, x];
integ[Exp[c_. *x_], x_]  :=  (1/c) *Exp[c*x];
integ[g_ * Exp[c_. *x_], x_]  :=  
      g*Exp[c*x]/c  -  integ[D[g, x]*Exp[c*x], x]/c

integ[x^4*Exp[x], x]

integ[1 + x + 3  x*Exp[2  x], x]  //  Simplify

(b)

Clearly, we can integrate any polynomials with arbitrary coefficients:

integ[a0  +  a1*x  +  a6*x^6, x]

Or sum of polynomial times an exponential   Σ (Subscript[a, n]) (x^n) exp((Subscript[c, n]) x).  This is the general form of functions.

integ[a0  +  a1*x  +  b2*x^2*Exp[3  x], x]

(c)

The set of integrable functions form an integral domain.

3.

(a)

Addition Table 
           (Subscript[Z, 3])+ |	0	1	2
           ---------------------
           0	      |	0	1	2
           1	      |	1	2	0   
           2	      |	2	0	1

Multiplication Table
            (Subscript[Z, 3])* |	0	1	2
           ---------------------
           0	      |	0	0	0
           1	      |	0	1	2   
           2	      |	0	2	1

(b)

Additive inverse    of      0     is   0,
                                             1     is   2,
                                             2     is   1.

(c)

Multiplicative inverse  of   0   is  none (no inverse)
                                                  1   is    1,
                                                  2   is    2.

(d)

PolynomialGCD[1 + x + x^3, 1 - x, Modulus -> 3]

\(TraditionalForm\`\(\(\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \)\(\(2\ x\^2\ \ \  + \ 2  x\ \ \ \  + \ 1\)\(
\)
    \(\ \)\(2  x + 
      1\ \ \@\(x\^3\ \  + \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ x\ \ \ \  + \ 1\)\)\(
\)
    \(\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \)\(x\^3\ \ \ \  + \ \ 2 
         x\^2\)\(
\)
    \(\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \)\(___  ___  ___  ___  ___  ___\)\(
\)
    \(\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \)\(x\^2\ \ \ \  + \ \ \ \ x\)\(\ \ \ \ \ \ \)\(
\)
    \(\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \)\(x\^2\ \ \  + \ 2  x\)\(
\)
    \(\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \)\(\(--\(--\(--\(--\(-
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 2\)\)\)\)\)\ x\ \ \ \  + \ 1\)\(
\)
    \(\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \)\(2\ x\ \ \ \  + \ 1\)\(
\)
    \(\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \)\(___  ___  ___\)\(
\)
    \(\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \)\(0\)\(
\)
    \(\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \)\)\)\)

Since 1 - x ≡ 2  x + 1 divides 1 + x + (x^3)  exactly, so GCD(1 + x + (x^3), 1 - x) = 2  x + 1.

(e)

We could have used Extended Euclidean algorithm, but let us compute inverse first by finding a and b such that:
(a + b x) (1 - x)  ≡  
        1   mod (1 + (x^2))   or
a  - 
          b (x^2)  +  (b - a) x  ≡   a + 
          b  +  (b - a) x   ≡  1,  so a + b  ≡ 1,   b - a ≡ 
        0.   We note that (x^2) ≡  -1 mod (1 + (x^2)).  We have a = b, and 2  a = 1,  or a = b = (2^(-1)) ≡ 2.     So (((1 - x))^(-1))  =  2  x + 2.    Thus the final results for the product is:
(1 + 
              x) (((1 - x))^(-1)) ≡  (1 + x) (2  x + 
              2)  ≡  2 - 2 + (2 + 2) x  ≡  
        x.

(f)

Condition for square -free is that GCD(a(x),  a' (x)) is a unit.   Compute: GCD (1 + x + (x^2),  1 + 2  x)

\(TraditionalForm\`\(\(\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \)\(2  
          x\ \  + 1

      2  x + 1\ \ \@\(x\^2\ \  + \ \ \ \ x\ \ \  + \ 1\)

      \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ x\^2\  + \ \ \ 2  
          x

      \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(--\(--\(--\(--\(-
\ \ \ \ \ 2\)\)\)\)\) x\  + \ 1\ 

      \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 2  
          x\ \  + \ 1

      \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(--\(--\(--
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0\)\)\)\)\)\)

GCD (1 + x + (x^2),  1 + 2  x)  =  
        2  x + 1.   Since this is not a unit, the polynomial 1 + x + (x^2) is not square-free.  The above result also means that 2  x + 1 is a factor of 1 + x + (x^2), since the quotient is also 2  x + 1,  we must have (((2  x + 1))^2) =  1 + x + (x^2).   Without going through the square-free factorization algorithm, we find the factorization is (((2  x + 1))^2) ≡  (((x + 2))^2).

Factor[1 + x + x^2,  Modulus -> 3]

4.

Solve[{5  x + 2  y == 7, 2  x + y == 1}, {x, y}]

matd = {{5, 2}, {2, 1}}

Det[matd]

Given the above results, the answer can be checked:

mod  p                x                y               d              (Subscript[d, x])                  (Subscript[d, y])
          2                1                1                1              1                     1
          3                2                0                1              2                     0
          5                0                1                1              0                     1
          7                5                5                1              5                     5
         ∞               5              -9               1               5                  -9       (that is, Z)