PROGRAMMING WARMUP AND BASIC ERROR ANALYSIS

CHEN 2450
H
OMEWORK 1
P
ROGRAMMING WARMUP AND BASIC ERROR ANALYSIS
For problems 3 and 4 below, please put all your results into a single Jupyter notebook along with a discussion. Download
the Jupyter notebook as ipynb from the file menu (file->Download as) and upload that to Canvas. No exceptions.
Problem 1 (10 pts)
Fill out this survey: https://goo.gl/forms/NTEurMg28u5X4UI22. You do not need to submit anything beyond the survey for
this problem.
Problem 2 (10 pts)
Go through the EasyPy slides online www.github.com/saadtony/chempy and attempt to replicate those in your own python
notebook. You don’t need to submit anything for this question. Note that, if you do not have a local installation of Python
(via Anaconda), then feel free to use: notebook.chpc.utah.edu. Use your UNID and password to access the service.
Problem 3 (40 pts)
The second derivative of a function f (x) can be approximated numerically as
f 00(x) = f (x +h) 2 f (x)+ f (x h)
h2 (1)
where
h is a value set by the user that determines the accuracy of the derivative. Larger values in h are expected to produce
large errors while smaller values of
h will produce consistently smaller errors.
For the function
f (x) = sin2x:
1. Compute the true error in
f 00(2) using h = 0:1 and h = 0:01 and comment on the results.
2. Compute the relative true error in
f 00(2) using h = 0:1 and h = 0:01 and comment on the results. Report the results in
percent. HINT: Take the absolute value of the errors.
To access the sine function in Python, type:
from math import sin. Then use sin as needed.
Problem 4 (40 pts)
The following gas stations were cited for irregular dispensation by the Department of Agriculture with the following data

Gas Station Gasoline Reading at Pump (Gallons) Actual Gasoline Dispensed (Gallons)
A 10.00 9.90
B 20.00 19.90
C 30.00 29.80
D 30.00 29.95

Table 1: Data for gas stations cited by the Department of Agriculture.
1

1. If you are trying to find out which gas station cheated you the most, which type of error should you look at, absolute or
relative error?
2. Compte the error you chose in the previous question for each gas station.
3. Which gas station cheated you the most?
2