EGR 103/Spring 2020/Lab 6
Contents
Introduction
Some of the problems ask about norms and condition numbers. You will need to read Chapra 11.2 (pp. 292-297) to learn about norms and condition numbers. The summary version is:
- A norm gives you a measure of the size of the entries in a vector or matrix.
- For 1-D arrays (vectors in the text), you need to know how 1, 2, p, and \(\infty\) norms are calculated and be able to calculate them by hand.
np.linalg.norm()
understands these. - For 2-D arrays (matrices in the text), you need to know how 1, f (Frobenius), and \(\infty\) norms are calculated and be able to calculate them by hand. The calculation of a matrix 2-norm by hand is beyond the scope of this class but Python can do it.
np.linalg.norm()
understands these too.
- For 1-D arrays (vectors in the text), you need to know how 1, 2, p, and \(\infty\) norms are calculated and be able to calculate them by hand.
- A condition number of a matrix gives an idea of the sensitivity of the solution relative to the sensitivity of the measurements. The larger the condition number, the more difficult the geometry and thus the more prone to error the results are to measurement errors. The rule of thumb is that your final answer will have as many digits of precision as the number of digits in your measurements minus the base-10 logarithm of the condition number.
- For instance, if you take measurements to 5 significant figures and your system has a condition number of 100, you expectation is that your solution is accurate to \(5-\log_{10}(100)=5-2=3\) digits.
- You generally report ranges of digits if the condition number is not an integer power of 10. For instance, if you know your measurements to 9 figures and your condition number of 485, \(\log_{10}(485)=2.69\) so you will lose between 2 and 3 digits of precision meaning you know your final answers to within 6-7 digits (9 minus 2 or 3).
np.linalg.cond()
can calculate condition numbers andnp.log10()
can calculate log10 of a number.
Specific Problems
Chapra 8.3
This one is pretty straightforward - just be sure your A and b variables are 2-D arrays.
Chapra 8.10
There are many (correct) ways to re-write the equations in matrix form. One example for the first equation is shown in the handout and in the skeleton. Be sure to read the section on how the format() command works (or doesn't) with arrays.
Chapra 8.16
Carefully note that the function should not do any plotting - in fact, there is no reason to have matplotlib.pyplot in your chapra_08_16.py file!
Sweeps
Make sure you understand the first two examples at Python:Linear_Algebra#Sweeping_a_Parameter before starting these. You can ignore Python:Linear_Algebra#Multiple_solution_vectors_simultaneously.