problemAINumerics
Make Numerov find the decaying solution
Numerov's method integrates outward from , , aiming at the decaying solution . By it is off by a factor of 30, and by by . Rewrite decaying so that it follows to Numerov's own accuracy, within , on both intervals.
Open in the workbenchDownload .vivOutputs below are from the site build’s run; Run all runs it again in your browser.
Look inside this program
- Atlas
The program’s map: every function and which calls which.
There’s no recorded run of this program yet.
Numerov's method is the standard way to integrate , which is the form of the radial Schrödinger equation. For on a grid of spacing it is the three-term recurrence
accurate to fourth order in . The equation has two solutions, and , and the recurrence carries both. The two starting values are never exactly on the decaying one (they differ from the recurrence's own decaying solution by its truncation error), so a little of is always mixed in. Going outward, that part grows by relative to the part you want. In the region where a bound state's wavefunction decays, every outward integration has this problem.
The function must return at , normalized to
. The tests compare it with at every point. Their
tolerances come from posts/refs/make-numerov-find-the-decaying-solution.py,
which runs the working method in numpy: its largest relative error is
for on , for
, and for on . The
tests allow about 1.5 times those. Halving divides the error by 15.9,
the factor 16 of a fourth-order method.
Your task
Write these 2 functions:
decaying(m, h)- The decaying solution of y'' = y at x_i = ih, i = 0, \ldots, m, with y_0 = 1. As written it runs Numerov outward from y_0 = 1, y_1 = e^{-h}.
max_rel_error(y: Arr, h)- The largest relative difference between y and e^{-x} on the grid of spacing h.
Make these tests pass 3 of 5 fail
- y(0) = 1 (passes)
- with h = 0.15 on [0, 9] every point is within 1.3e-5 of e^(-x), where numpy's inward run reaches 8.87e-6 assert_lt: 29.6647 >= 1.3e-05 (fails)
- with h = 0.075 on [0, 9] every point is within 8e-7, where numpy reaches 5.58e-7 assert_lt: 2.00539 >= 8e-07 (fails)
- with h = 0.15 on [0, 18], where outward is off by 2e9, every point is within 2.7e-5 (numpy reaches 1.84e-5) assert_lt: 1.9478e+09 >= 2.7e-05 (fails)
- halving h divides the error by 12 to 20, as a fourth-order method's should (numpy: 15.9) (passes)
Printed