Numerical Methods: cram pack

Formula sheets, the key method steps for every topic and 8 practice problems, with full solutions at the back.

New problemsBack to the course

In the print window, choose “Save as PDF” to keep a copy on your device.

1Formulas and methods

Numerical methods

Bisection
c = (a + b)/2, width after n steps (b − a)/2ⁿ
Newton–Raphson
xn+1 = xₙ − f(xₙ)/f′(xₙ)
Linear interpolation
y = y₁ + (y₂ − y₁)(x − x₁)/(x₂ − x₁)
Trapezoid rule
T = (h/2)[f₀ + 2f₁ + … + 2fn−1 + fₙ], h = (b − a)/n
Simpson’s rule (n even)
S = (h/3)[f₀ + 4f₁ + 2f₂ + … + 4fn−1 + fₙ]
Trapezoid error bound
|E| ≤ (b − a)h²M/12, M = max|f″|
Euler
yn+1 = yₙ + h·f(tₙ, yₙ)
Heun
yn+1 = yₙ + (h/2)(k₁ + k₂), k₂ = f(tₙ + h, yₙ + hk₁)
RK4
yn+1 = yₙ + (h/6)(k₁ + 2k₂ + 2k₃ + k₄)

Method

  1. For a root: check the sign change for bisection, or compute f and f′ for Newton, and keep six or more digits in a table of iterates.
  2. For a table value: interpolate linearly between the two neighbouring points.
  3. For an integral: find h = (b − a)/n, list f at every node, apply the weights (1, 2, …, 2, 1 for trapezoid; 1, 4, 2, …, 4, 1 for Simpson with even n) and multiply by h/2 or h/3.
  4. For an ODE: step from t₀ with yₙ₊₁ = yₙ + h·f(tₙ, yₙ) (Euler) or the averaged slope (Heun), one row per step, until you reach the requested t.

Sequences & series

Arithmetic sequence
aₙ = a₁ + (n − 1)d, Sₙ = n(a₁ + aₙ)/2
Geometric sequence
aₙ = a₁rⁿ⁻¹, Sₙ = a₁(1 − rⁿ)/(1 − r)
Infinite geometric series
S = a₁/(1 − r), |r| < 1
p-series
Σ1/kᵖ converges only for p > 1
Ratio test
L = lim |ak+1/ak|: L < 1 converges, L > 1 diverges
Radius of convergence
R = lim |ck/ck+1|
Taylor polynomial
Pₙ(x) = Σ f⁽ᵏ⁾(a)(x − a)ᵏ/k!
Maclaurin series
eˣ = Σxᵏ/k!, sin x = x − x³/3! + …, cos x = 1 − x²/2! + …, ln(1 + x) = x − x²/2 + …
Lagrange error bound
|Rₙ| ≤ M·|x − a|ⁿ⁺¹/(n + 1)!

Method

  1. Identify the type: arithmetic (constant difference), geometric (constant ratio), a standard series, a power series or a Taylor polynomial.
  2. For sums use Sₙ = n(a₁ + aₙ)/2, Sₙ = a₁(1 − rⁿ)/(1 − r), or S = a₁/(1 − r) when |r| < 1, with a₁ the first term of the sum.
  3. For convergence: n-th term test first, then compare with Σ1/kᵖ or a geometric series, and use the ratio or root test for factorials and k-th powers.
  4. For Taylor polynomials list f(a), f′(a), f″(a), …, divide the k-th derivative by k!, and bound the error with M·|x − a|ⁿ⁺¹/(n + 1)!.

Matrices & determinants

2×2 determinant
det = ad − bc
2×2 inverse
A⁻¹ = (1/det)·[d −b; −c a]
Product
(AB)ij = Σk AikBkj
Eigenvalues
det(A − λI) = 0
Cramer’s rule
xi = det(Ai)/det(A)

Differential equations

Exponential growth/decay
dy/dt = ky → y = y0ekt
Half-life
k = ln 2 / t½
Newton's law of cooling
T(t) = Ta + (T0 − Ta)e−kt
Integrating factor
y′ + p(x)y = q(x): μ = e∫p dx, (μy)′ = μq
Mixing tank
dm/dt = r·c − (r/V)·m

2Practice problems

1.Numerical methodsMedium

The trapezoid rule is used for ∫02 eˣ dx. The error is at most (b − a)³·M/(12n²) with M = max|f″| on [0, 2]. Find the smallest number of strips n that guarantees an error below 0.001.

f(x) = eˣ[a, b] = [0, 2]ε = 0.001
n =
2.Numerical methodsHard
00.10.20.30.42.62.83ty(0, 3)

Solve y′ = −2ty, y(0) = 3 with Euler's method and step h = 0.1 up to t = 0.4. The exact solution is y = y₀e−t². Find the global error |E| = |y(0.4) − y4|.

y′ = −2tyy(0) = 3h = 0.1
|E| =
3.Sequences & seriesMedium
k|aₖ₊₁/aₖ|123456789101112

Apply the ratio test to Σk=1∞ 2ᵏ·k!/kᵏ. Find L = lim |ak+1/ak|.

ak = 2ᵏ·k!/kᵏ
L =
4.Sequences & seriesHard

f(x) = sin x is approximated by its Maclaurin polynomial of degree 5 at x = 0.3. Use the Lagrange error bound M·|x|ⁿ⁺¹/(n + 1)! with M = 1 to find the largest possible error |R₅|.

f(x) = sin xn = 5x = 0.3M = 1
|R₅| =
5.Matrices & determinantsMedium
A =−6056B =6−132

Let C = AB for the matrices shown. Find the entry c21 (row 2, column 1).

A = [−6 0; 5 6]B = [6 −1; 3 2]
c21 =
6.Matrices & determinantsHard
A =−51−42b =−63

Solve the system −5x + y = −6 and −4x + 2y = 3. Find x.

−5x + y = −6−4x + 2y = 3
x =
7.Differential equationsMedium
t (min)T (°C)28Ta​T = ?

A can of soda at 3 °C is taken out of the fridge into a room at 28 °C. It follows Newton's law of cooling, dT/dt = −k·(T − Tₐ). With k = 0.09 min⁻¹, find its temperature T after 28 min.

T0 = 3 °CTa = 28 °Ck = 0.09 min⁻¹t = 28 min
T = °C
8.Differential equationsHard
t (min)m (kg)t = ?30 kg

A tank holds 200 L of pure water. Brine with 0.25 kg of salt per litre flows in at 4 L/min, and the well-mixed solution flows out at the same rate. After how many minutes t does the tank contain 30 kg of salt?

V = 200 Lm0 = 0 kgc = 0.25 kg/Lr = 4 L/min
t = min

3Solutions

1.Numerical methods

Answer: n = 71

Numerical integration: split [a, b] into n strips of width h = (b − a)/n with nodes x₀ … xₙ. Trapezoid rule: T = (h/2)[f₀ + 2f₁ + 2f₂ + … + 2fn−1 + fₙ]. Simpson's rule (n even): S = (h/3)[f₀ + 4f₁ + 2f₂ + 4f₃ + … + 4fn−1 + fₙ]. The trapezoid error shrinks like h² (bound (b − a)h²·M/12 with M = max|f″|), Simpson's like h⁴, so Simpson is usually far more accurate for the same nodes.

Second derivative bound

M = e2 = 7.389

Solve for n

n² > 8·7.389/(12·0.001) = 4926
n > 70.19 → n = 71

Answer

n = 71
2.Numerical methods

Answer: |E| = 0.09662

Numerical solution of y′ = f(t, y): Euler's method steps along the slope at the start of each step: yn+1 = yₙ + h·f(tₙ, yₙ). Heun's method (improved Euler) averages the slope at the start and at an Euler prediction: k₁ = f(tₙ, yₙ), k₂ = f(tₙ + h, yₙ + h·k₁), yn+1 = yₙ + (h/2)(k₁ + k₂). The classical Runge–Kutta method (RK4) combines four slopes: yn+1 = yₙ + (h/6)(k₁ + 2k₂ + 2k₃ + k₄). The global error of Euler is proportional to h, Heun's to h², RK4's to h⁴.

ntₙyₙf(tₙ, yₙ)yₙ₊₁0030310.13−0.62.9420.22.94−1.1762.822430.32.8224−1.693442.653056

Euler steps

y4 = 2.653056

Exact value

y(0.4) = 2.556431

Global error

|E| = |2.556431 − 2.653056| = 0.09662
00.10.20.30.42.62.83ty

Graph

Answer

|E| = 0.09662

Halving h roughly halves the error of Euler's method.

3.Sequences & series

Answer: L = 0.7358

Convergence: if the terms do not tend to 0 the series diverges (n-th term test). Σ1/kᵖ converges only for p > 1, and Σrᵏ only for |r| < 1. Compare a series with one of these when its terms behave like them for large k. Ratio test: L = lim |ak+1/ak|; root test: L = lim |ak|1/k. L < 1 converges, L > 1 diverges, L = 1 decides nothing. A power series Σck(x − x₀)ᵏ converges for |x − x₀| < R with R = lim |ck/ck+1|; an alternating series with terms decreasing to 0 converges.

Ratio of consecutive terms

|ak+1/ak| = 2·(k/(k + 1))ᵏ = 2/(1 + 1/k)ᵏ → 2/e

Conclusion

L = 0.7358 < 1

Answer

L = 0.7358

L < 1, so the series converges.

4.Sequences & series

Answer: |R₅| = 1.012 × 10⁻⁶

Taylor polynomials: near x = a a smooth function is approximated by Pₙ(x) = f(a) + f′(a)(x − a) + f″(a)(x − a)²/2! + … + f⁽ⁿ⁾(a)(x − a)ⁿ/n!; for a = 0 this is the Maclaurin polynomial. Standard series: eˣ = Σxᵏ/k!, sin x = x − x³/3! + x⁵/5! − …, cos x = 1 − x²/2! + x⁴/4! − …, ln(1 + x) = x − x²/2 + x³/3 − …, 1/(1 − x) = Σxᵏ. Lagrange error bound: |f(x) − Pₙ(x)| ≤ M·|x − a|ⁿ⁺¹/(n + 1)!, where M is the largest value of |f⁽ⁿ⁺¹⁾| between a and x.

Bound on the derivative

M = 1

Lagrange bound

|R₅| ≤ 1·0.3⁶/6! = 1.012 × 10⁻⁶

Answer

|R₅| = 1.012 × 10⁻⁶

The true error is smaller: |f(0.3) − P₅(0.3)| = 4.334 × 10⁻⁸.

5.Matrices & determinants

Answer: c21 = 48

Matrices: the determinant of a 2×2 matrix is ad − bc. For 3×3, expand along a row: each entry times the determinant of the 2×2 matrix left after removing its row and column, with alternating signs + − +. Eigenvalues λ solve det(A − λI) = 0; for 2×2 that is λ² − (trace)·λ + det = 0.

Row times column

c21 = 5·6 + 6·3 = 48

Answer

c21 = 48
6.Matrices & determinants

Answer: x = 2.5

Matrices: the determinant of a 2×2 matrix is ad − bc. For 3×3, expand along a row: each entry times the determinant of the 2×2 matrix left after removing its row and column, with alternating signs + − +. Eigenvalues λ solve det(A − λI) = 0; for 2×2 that is λ² − (trace)·λ + det = 0.

Determinant of the coefficient matrix

det A = (−5)·2 − 1·(−4) = −6

Replace the x column

det Aₓ = (−6)·2 − 1·3 = −15
x = −15/(−6) = 2.5

Answer

x = 2.5
y = 6.5
7.Differential equations

Answer: T = 25.99 °C

First-order differential equations: dy/dt = k·y has the solution y = y₀·ekt (growth for k > 0, decay for k < 0); a half-life T gives k = ln 2/T. Newton's law of cooling, dT/dt = −k·(T − Tₐ), gives T(t) = Tₐ + (T₀ − Tₐ)·e−kt. A linear equation y′ + p(x)·y = q(x) is solved with the integrating factor μ = e∫p dx: (μy)′ = μq, so μy = ∫μq dx + C.

Solution of the cooling law

T(t) = 28 + (−25)·e−0.09t

Substitute t

T(28) = 28 + (−25)·0.08046 = 25.99 °C

Answer

T = 25.99 °C
8.Differential equations

Answer: t = 45.81 min

First-order differential equations: dy/dt = k·y has the solution y = y₀·ekt (growth for k > 0, decay for k < 0); a half-life T gives k = ln 2/T. Newton's law of cooling, dT/dt = −k·(T − Tₐ), gives T(t) = Tₐ + (T₀ − Tₐ)·e−kt. A linear equation y′ + p(x)·y = q(x) is solved with the integrating factor μ = e∫p dx: (μy)′ = μq, so μy = ∫μq dx + C.

Result

m(t) = 50 + (−50)·e−t/50

Solve for t

e−t/50 = (50 − 30)/(50 − 0) = 0.4
t = 50·ln(2.5) = 45.81 min

Answer

t = 45.81 min

ExamProblems · examproblems.com/courses/numerical-methods