Chapter 6: Problem 11
The program src/basic/lnsum.py produces, among other things, this output: $$ \begin{aligned} &\text { epsilon: } 1 e-04, \text { exact error: } 8.18 \mathrm{e}-04, \mathrm{n}=55 \\ &\text { epsilon: } 1 \mathrm{e}-06, \text { exact error: } 9.02 \mathrm{e}-06, \mathrm{n}=97 \\ &\text { epsilon: } 1 \mathrm{e}-08, \text { exact error: } 8.70 \mathrm{e}-08, \mathrm{n}=142 \\ &\text { epsilon: } 1 \mathrm{e}-10, \text { exact error: } 9.20 \mathrm{e}-10, \mathrm{n}=187 \\ &\text { epsilon: } 1 \mathrm{e}-12, \text { exact error: } 9.31 \mathrm{e}-12, \mathrm{n}=233 \end{aligned} $$ Redirect the output to a file. Write a Python program that reads the file and extracts the numbers corresponding to epsilon, exact error, and \(\mathrm{n}\). Store the numbers in three arrays and plot epsilon and the exact error versus \(\mathrm{n}\). Use a logarithmic scale on the \(y\) axis, which is enabled by the \(\log =\) ' \(\mathrm{y}\) ' keyword argument to the plot function. Name of program file: read_error.py.
Short Answer
Step by step solution
Key Concepts
These are the key concepts you need to understand to accurately answer the question.