Description
Problem 1: We saw in class how Taylor series/roundoff errors fight against
each other when deciding how big a step size to use when calculating numerical
derivatives. If we allow ourselves to evaluate our function f at four points (x±δ
and x ± 2δ),
a) what should our estimate of the first derivative at x be? Rather than doing
a complicated fit, I suggest thinking about how to combine the derivative from
x ± δ with the derivative from x ± 2δ to cancel the next term in the Taylor
series.
b) Now that you have your operator for the derivative, what should δ be in
terms of the machine precision and various properties of the function? Show for
f(x) = exp(x) and f(x) = exp(0.01x) that your estimate of the optimal δ is at
least roughly correct.
Problem 2: Lakeshore 670 diodes (successors to the venerable Lakeshore
470) are temperature-sensitive diodes used for a range of cryogenic temperature
measurements. They are fed with a constant 10 µA current, and the voltage is
read out. Lakeshore provides a chart that converts voltage to temperature, available at https://www.lakeshore.com/products/categories/specification/temperatureproducts/cryogenic-temperature-sensors/dt-670-silicon-diodes, or you can look
at the text file I’ve helpfully copied and pasted (lakeshore.txt).
Write a routine
that will take an arbitrary voltage and interpolate to return a temperature. You
should also make some sort of quantitative (but possibly rough) estimate of the
error in your interpolation as well (this is a common situation where you have
been presented with data and have to figure out some idea of how to get error
estimates).
Problem 3: Take cos(x) between −π/2 and π/2. Compare the accuracy of
polynomial, cubic spline, and rational function interpolation given some modest
number of points, but for fairness each method should use the same points. Now
try using a Lorentzian 1/(1 + x
2
) between -1 and 1.
What should the error be for the Lorentzian from the rational function fit?
Does what you got agree with your expectations when the order is higher (say
n=4, m=5)? What happens if you switch from np.linalg.inv to np.linalg.pinv
(which tries to deal with singular matrices)? Can you understand what has
happened by looking at p and q?¡
Problem 4: One can work out the electric field from an infinitessimally
thin spherical shell of charge with radius R by working out the field from a ring
along its central axis, and integrating those rings to form a spherical shell. Use
both your integrator and scipy.integrate.quad to plot the electric field from the
shell as a function of distance from the center of the sphere. Make sure the
range of your plot covers regions with z < R and z > R. Make sure one of your
1
z values is R.
Is there a singularity in the integral? Does quad care? Does your
integrator? Note – if you get stuck setting up the problem, you may be able to
find solutions to Griffiths problem 2.7, which sets up the integral.
2