10/16/2018 PrairieLearn
https://prairielearn.engr.illinois.edu/pl/course_instance/10920/instance_question/22830127/ 1/1
HW7.13. Estimate Digits
Estimating Number of Correct Digits
Do you know how accurate your solutions are? The ability to print a solution to digits does
not imply that we actually have an answer that is accurate to that precision. For this problem,
you must solve a linear system and indicate how many accurate digits you have in your
solution.
You may use functions from numpy.linalg for this problem. numpy.linalg.solve and
numpy.linalg.cond may be particularly useful.
If I run the same code several times, sometimes my solution is correct and sometimes it is
not. What is going on?
One possibility is that you are rounding incorrectly. Think about this: If I have 4.9 accurate
digits, should I say that five of my digits are accurate, or four of my digits are accurate?
The setup code gives the following variables:
Name Type Description
A numpy array A matrix
b numpy vector b vector
Your code snippet should define the following variables:
Name Type Description
correct_digitsinteger indicates how many meaningful digits there are in x
x numpy arraythe x that solves