You can step a differential equation forward in time with Euler or Runge-Kutta and control the error.
Weeks 13-14
Numerical Methods course units
Work in order for a complete course, or jump directly to the unit you need for an upcoming assessment.
01
Floating-point error
Weeks 1-2
You can explain why a computer's answer differs from the exact one and estimate how big the gap is. You can also rewrite a formula to dodge a dangerous subtraction.
Compute both absolute and relative error for a rounded value.
Spot catastrophic cancellation when two nearly equal numbers are subtracted.
Rewrite the quadratic formula to keep the small root accurate.
Worked example
True value 2.71828, computed value 2.718. Find the relative error.
Absolute error = 0.00028
Divide by the true value: 0.00028 / 2.71828
AnswerAbout 0.0103%
Most common mistakeQuoting the absolute error 0.00028 as if it were the relative error: the same gap is negligible near 2.7 and enormous near 0.001.
You can build a curve that passes exactly through given points and use it to fill in gaps. You can also explain why a high-degree fit wiggles badly at the edges.
Interpolate linearly between two table entries.
Write a Lagrange polynomial through three points.
Prefer splines when a high-degree polynomial starts oscillating.
Worked example
f(2) = 5 and f(6) = 13. Estimate f(3.5) by linear interpolation.
Slope = (13 - 5)/(6 - 2) = 2
f(3.5) is about 5 + 2(3.5 - 2)
Answer8
Most common mistakeAveraging the two endpoint values: reporting (5 + 13)/2 = 9, which is the estimate at x = 4, not at x = 3.5.
You can estimate a derivative from data points and pick a step size that balances two competing errors. You can also explain why an extremely small step makes things worse.
Use the central difference formula with a step h.
Compare the accuracy of forward and central differences.
Explain why rounding error grows as the step shrinks.
Worked example
Estimate the derivative of x squared at x = 3 by central difference with h = 0.1
(f(3.1) - f(2.9)) / 0.2 = (9.61 - 8.41)/0.2
1.20 / 0.2
Answer6.0, which is exactly right here
Most common mistakeDividing by h rather than 2h in the central formula: reporting 12, exactly double the true derivative of 6.
You can approximate an integral with the trapezoid rule or Simpson's rule and put a bound on the error. You can also decide how many slices you actually need.
Apply the trapezoid rule with a small number of subintervals.
Use Simpson's rule, which needs an even number of subintervals.
Estimate the error from the error-bound formula.
Worked example
Trapezoid rule for the integral of x squared from 0 to 2, with 2 slices
(h/2)[f(0) + 2f(1) + f(2)] with h = 1
(1/2)[0 + 2 + 4]
Answer3, against an exact value of about 2.667
Most common mistakeForgetting to double the interior value: computing (1/2)[0 + 1 + 4] = 2.5, which lands below the exact answer instead of above it.
You can solve large systems with LU factorization or iteration and tell when a system is fragile. You can also use pivoting to keep rounding errors small.
Use partial pivoting to avoid dividing by a tiny pivot.
Factor a matrix into L and U so many right-hand sides reuse the work.
Read a large condition number as a warning about accuracy.
Worked example
Solve 0.0001x + y = 1 and x + y = 2 with pivoting
Swap the rows so the pivot is 1 rather than 0.0001
From x + y = 2 and the other row: 0.9999y = 0.9998
Answery is about 0.9999 and x is about 1.0001
Most common mistakeKeeping 0.0001 as the pivot: the multiplier of 10,000 blows up rounding error and can return x = 0 in low precision.
You can step a differential equation forward in time with Euler or Runge-Kutta and control the error. You can also recognise a stiff problem that forces tiny steps.
Take one Euler step with a step size of 0.1.
Compare Euler's first-order error with the fourth-order error of RK4.
Spot instability when the numeric solution blows up as steps get larger.
Worked example
y' = y with y(0) = 1. Take one Euler step with h = 0.1.
y1 = y0 + h times f(t0, y0)
y1 = 1 + 0.1(1)
Answer1.1, against a true value of about 1.1052
Most common mistakeUsing the new value inside the same step: computing 1 + 0.1(1.1) = 1.11 is the implicit method, not the explicit Euler step that was asked for.
Before timing yourself, check whether you can explain Floating-point error from a blank page. Then connect it to Root finding. If either explanation depends on copying a formula, review the unit first and complete two untimed examples.
Use tools to verify, not to choose the method for you
The Scientific calculator can test calculations and representations used in Numerical Methods. Make the setup yourself, predict the sign or scale, and compare the tool result with that prediction. Use the formula library to check conditions as well as notation.
Know when to move to the full test
Move from Numerical Methods practice to the complete course test after you can correct a missed problem without reopening the worked answer. Record the earliest wrong decision—not only the final score—so the next study session has a precise target.
Before and after the syllabus
Learn the ideas, then practise them
The unit list tells you what is covered. These two pages are where the method is explained and where you find out whether it stuck.
Start with Floating-point error if you are following the full sequence. If that unit feels automatic, open the Numerical Methods practice page, choose mixed review, and let the first errors identify the earliest prerequisite to revisit.
How do I know I am ready for the course test?
You are ready when you can choose a method without a hint, show the governing steps, and explain why the result is reasonable. Use the complete Numerical Methods test only after you can correct practice errors from a blank page.
Which calculator supports this course?
The Scientific calculator supports the calculations and representations used in this course. Use it to test or visualize a result after making your own setup.