Lecture 44: Third Review

The question on the third review focus on the number system and basic data structures. This review corresponds to the first review, to prepare for the first midterm exam.

Our First Steps

  1. Explain the difference between RDF and RR. Illustrate with an example.

  2. Give a list of ten rational approximations for \(\sqrt{3}\), accurate with 2, 3, up to 11 decimal places.

  3. Consider \({\mathbb Z}_{31}\).

    1. What is the multiplicative inverse of 7?

    2. Show that \(15 x^5 + 4 x^4 + 23 x^3 + 26 x^2 + 6 x + 1\) is irreducible over \({\mathbb Z}_{31}\).

  4. Expand exp(I*2*Pi/k) as cos(2*Pi/k) + I*sin(2*Pi/k).

  5. Consider \(q = \cos(x^3 - 1) + 3 \sin(y) - z^7\). Draw the expression tree of \(q\).

  6. Save a random matrix to file, destroy its reference, and load then the saved matrix back into SageMath.

  7. Generate optimized code to evaluate \(p = 79 x^{298} + 56 x^{205} + 49 x^{164} + 63 x^{121} + 57 x^{119} - 59 x^{42}\).

    1. How many operations are needed to evaluate \(p\)?

    2. Compare with the cost of a direct evaluation of \(p\).

  8. Consider the right hand side of

    \[\int_1^2 \frac{1}{x} dx \approx \frac{1}{2n} \left( 1 + \frac{1}{2} \right) + \frac{1}{n} \sum_{k=1}^n \left( \frac{1}{1 + k/n} \right).\]
  1. Write a Python function P to define the evaluation of the right hand side of the above sum, for any value for \(n\) which is the input parameter to the function P.

    Compare the value of P(10000) with the exact value of the integral.

    Time the execution of the function for \(n = 10,000\).

  2. Use vectorization to define a more efficient function F which computes the same sum as P, and which also takes \(n\) as an input parameter.

    Compare the value of F(10000) with the exact value of the integral.

    Time the execution of the function for \(n = 10,000\).

Compare the result of the timings.

Polynomials and Rational Expressions

  1. Draw the internal representation of \(x y (x-y)\).

  2. Consider \(p = x^3 - x - 2\) and give all commands for an exact, numeric, and symbolic factorization. In particular, answer the following questions.

    1. How can you write \(p\) as an exact product of linear factors, with exact complex numbers?

    2. Compute a numerical factorization of \(p\) over the complex numbers.

    3. Define a symbolic (i.e.: formal) factorization of \(p\), declaring sufficiently many roots.

    4. Compute a symbolic-numeric factorization, extending the field of rational numbers with complex intervals.

  3. Give all commands to transform \((x-y) (x+y)\) into \((x+y) x - (x+y) y\).

  4. Consider \({\displaystyle r = \frac{79 x^5 + 56 x^4 + 49 x^3 + 63 x^2 + 57 x - 59}{45 x^5 - 8 x^4 - 93 x^2 + 43 x - 62}}\).

    1. Convert \(r\) into a form which is more efficient to evaluate.

      Compare the number of arithmetical operations needed to evaluate \(r\) in this more efficient form with the number of arithmetical operations to evaluate \(r\) in its given form.

    2. Compare this number of operations with the Horner forms of numerator and denominator for \(r\).

  5. Explain why normal forms are so important to symbolic computation.

    What can we do if a normal form is too expensive to compute? Illustrate with a good example.