78.1 KB · commit a9602da
| title | ECE 2213 · 2020 Exam Style Answers |
|---|
RUET · ECE Dept · B.Sc. Engineering 2nd Year Even Semester Examination, 2020 Full Marks: 96 · Time: 03 Hours
Why we need them. Most engineering problems have no closed-form answer.
Sources of error. Two families, both of which must be tracked.
| Error | What it is | Where it comes from | How to fight it |
|---|---|---|---|
| Truncation | The method is not exact | Replacing a derivative by a finite difference, or cutting an infinite series | Use a higher-order formula, or a smaller h |
| Round off | Digits are lost | Floating point is finite, and each operation adds a small error | Use higher precision, or reformulate to cancel less |
Truncation error in detail. For a central difference,
2hf(x+h)−f(x−h)=f′(x)+6h2f′′′(x)+⋯
Hence the error is O(h2): halving h reduces it by a factor of 4. For the trapezoid rule it is O(h2) too. For Euler's method it is only O(h), so halving h halves the error. The order of accuracy fixes the error for a given step size.
Round off error in detail. A number with p significant digits carries a relative uncertainty near 10−p. Every addition roughly doubles the absolute error of the operands, and every multiplication squares the relative error. With n sequential steps the errors accumulate, giving a growth like nϵ for additions.
Round off, truncation, and the optimal step size. The two errors pull in opposite directions.
The total is smallest where the two cross, and for a central difference that is near h≈ϵ1/3, about 6×10−6 in double precision. Below that, adding more points makes the answer worse. This is why a table like 2020 Q.3(b), whose y values are integers and so carry no rounding at all, permits a very small h with no penalty.
No closed form exists, the data are irregular, and design needs many repeated solvesDefinitions. Let vt be the true value and va the approximate value.
Absolute error. The size of the mistake, in the units of the quantity.
Ea=va−vtor∣Ea∣=∣va−vt∣
It is the only error directly measurable, and it carries the same units as the answer.
Relative error. The mistake as a fraction of the true value. It is dimensionless, so it can be compared across quantities of different size.
Er=vtva−vtpercentage relative error=vtva−vt×100
The denominator is the true value, not the approximate one. That choice is what makes the measure meaningful, and it is the point examiners check.
Now the numbers. va=9.05 Amp, vt=10 Amp.
Ea=9.05−10=−0.95 Amp,∣Ea∣=0.95 Amp Er=109.05−10=10−0.95=−0.095 percentage relative error=−0.095×100=−9.5%The sign says the approximation is low, which absolute error alone cannot give a quantity that can be reasoned about directly.
| Representation | Value | Units |
|---|---|---|
| Absolute error | 0.95 | Amp |
| Relative error | 0.095 | none |
| Percentage relative error | 9.5% | none |
Which is better, and why. Relative error is the better representation, for three reasons.
Where absolute error wins: when the quantity is itself an error, a tolerance, or a dimensional quantity where a fraction makes no sense, such as a length or a time. Reporting "the beam is off by 2 mm" beats "off by 0.4%".
∣Ea∣=0.95 Amp,Er=−0.095,percentage=−9.5%Root of an equation. A root of f(x)=0 is a value x∗ with f(x∗)=0. The graph of f crosses or touches the x-axis at x∗.
A root is simple if f′(x∗)=0, and multiple (or repeated) if f′(x∗)=0. The distinction matters because the methods below all assume a simple root; a repeated root makes their convergence much slower.
A root is explicit if it can be written in closed form, and implicit if it can only be found numerically. 2 is explicit. The root of x5−x−1=0 is implicit.
The four methods compared.
| Bisection | False position | Secant | Newton-Raphson | |
|---|---|---|---|---|
| Type | Bracketing | Bracketing | Open | Open |
| Needs f′ | No | No | No | Yes |
| Needs a sign change | Yes | Yes | No | No |
| Information used | Endpoints only | Endpoints, keeps one fixed | Last two points | Value and slope at one point |
| New point from | Midpoint | Chord crossing | Chord through last two | Tangent at last point |
| Convergence order | 1 (linear) | 1, often faster | 1.618 (golden ratio) | 2 (quadratic) |
| Starts from | a0 | a0 | x0,x1 | x0 only |
| Guaranteed | Yes, from any valid bracket | Yes | No | No |
| Function calls per step | 1 | 1 | 1 | 2 (value and derivative) |
| Weakness | Slow, and halves the interval | Stalls on one side for strong convexity | Can diverge, can lose the bracket | Sensitive to the start |
How they relate. They form a ladder from safest to fastest.
The practical rule. Keep a bracket. Try Newton. If a step leaves the bracket, take a bisection step instead. This hybrid keeps Newton's speed and bisection's guarantee, and it is what real root finders do. See the worked warning in 2021 Q.7(b) and 2023 Q.5(c) for what happens without it.
Bracketing methods are safe and slow; open methods are fast and unguaranteedStep 1. Set up.
f(I)=3I2−4I−4,f′(I)=6I−4Step 2. Choose a starting value. The paper prints none, so we pick one and say so. A current is a positive quantity, and
f(1)=3−4−4=−5<0,f(3)=27−12−4=11>0Hence a root lies in (1,3). Take the left end, I0=1.
Step 3. The iteration.
In+1=In−f′(In)f(In)=In−6In−43In2−4In−4Step 4. Three iterations.
At I0=1: f(1)=−5 and f′(1)=2.
I1=1−2−5=1+2.5=3.500000At I1=3.5: f(3.5)=3(12.25)−14−4=36.75−18=18.75 and f′(3.5)=21−4=17.
I2=3.5−1718.75=3.5−1.102941=2.397059At I2=2.397059: f=3(5.745893)−9.588236−4=17.237679−13.588236=3.649443 and f′=14.382354−4=10.382354.
I3=2.397059−10.3823543.649443=2.397059−0.351504=2.045555| n | In | f(In) | f′(In) |
|---|---|---|---|
| 0 | 1.000000 | −5.000000 | 2.000000 |
| 1 | 3.500000 | 18.750000 | 17.000000 |
| 2 | 2.397059 | 3.649443 | 10.382354 |
| 3 | 2.045555 | 0.370665 | 8.273329 |
Step 5. Check the exact root. The quadratic formula settles it:
I=64±16+48=64±8which gives I=2 and I=−32. Only I=2 is a physical current, and I3=2.045555 is closing on it.
The difference.
| Interpolation | Extrapolation | |
|---|---|---|
| Target x | Inside the data range, xmin≤x≤xmax | Outside it |
| What the curve is doing | Bridging a known span | Continuing past the last data point |
| Reliability | High, the data surround the target | Low, the polynomial is unsupported there |
| Typical error | Small | Grows rapidly with distance |
| What it assumes | The function is smooth in the region | The function stays smooth outside the region, which nothing guarantees |
The reason extrapolation is risky. A polynomial of degree n through n+1 points matches the data exactly and says nothing at all beyond the last node. The error term is
f(x)−Pn(x)=(n+1)!f(n+1)(ξ)i=0∏n(x−xi)and outside the range that product grows while the points give no control over f(n+1). A curve that is flat over the sampled region can turn over completely just beyond it.
Where interpolation is used. Reading a value off a mathematical function at an inconvenient argument. Values defined by interpolation in a standard, such as a density table or a steam table. Reproducing a signal between samples, for example a sine wave reconstructed from discrete samples.
Where extrapolation is used. Forecasting beyond the last observation, such as a population projection or a demand forecast. Continuing a trajectory in time from sampled position data, as in 2020 Q.3(b). Filling a small gap just past the edge of a measured range. Using a Taylor series about a known point.
The shared caution: interpolation needs the data to bracket the target, and extrapolation needs the underlying function to stay well behaved past the edge. Only the first is under control.
Interpolation fills a gap the data surround; extrapolation guesses past the edge| Year x | 1891 | 1901 | 1911 | 1921 | 1931 |
|---|---|---|---|---|---|
| Population y (thousands) | 46 | 66 | 81 | 93 | 101 |
Step 1. Both targets lie inside the data range [1891,1931].
Both problems are genuine interpolations (not extrapolations). We construct the difference table and apply each formula with its optimal base node.
Step 2. Difference table. Here h=10 years.
| x | 1891 | 1901 | 1911 | 1921 | 1931 |
|---|---|---|---|---|---|
| y | 46 | 66 | 81 | 93 | 101 |
| Δy | 20 | 15 | 12 | 8 | |
| Δ2y | −5 | −3 | −4 | ||
| Δ3y | 2 | −1 | |||
| Δ4y | −3 |
From the table:
Step 3. The formulas.
Newton's Forward Interpolation Formula (p=hx−x0): y(x)=y0+pΔy0+2!p(p−1)Δ2y0+3!p(p−1)(p−2)Δ3y0+4!p(p−1)(p−2)(p−3)Δ4y0
Newton's Backward Interpolation Formula (p=hx−xn): y(x)=yn+p∇yn+2!p(p+1)∇2yn+3!p(p+1)(p+2)∇3yn+4!p(p+1)(p+2)(p+3)∇4yn
Step 4. Part (i), the year 1895 (Newton's Forward Interpolation).
For x=1895, choose x0=1891 (beginning of table): p=101895−1891=+0.4
Using forward differences from x0=1891:
| Term | Working | Value | Running |
|---|---|---|---|
| y0 | 46 | 46.000000 | |
| pΔy0 | (0.4)(20) | +8.0 | 54.000000 |
| 2p(p−1)Δ2y0 | 2(0.4)(−0.6)(−5)=(−0.12)(−5) | +0.6 | 54.600000 |
| 6p(p−1)(p−2)Δ3y0 | 6(0.4)(−0.6)(−1.6)(2)=(0.064)(2) | +0.128 | 54.728000 |
| 24p(p−1)(p−2)(p−3)Δ4y0 | 24(0.4)(−0.6)(−1.6)(−2.6)(−3)=(−0.0416)(−3) | +0.1248 | 54.852800 |
(Note on alternative route: Applying Newton's backward difference formula from xn=1931 with p=101895−1931=−3.6 gives 101+(−3.6)(8)+2(−3.6)(−2.6)(−4)+6(−3.6)(−2.6)(−1.6)(−1)+24(−3.6)(−2.6)(−1.6)(−0.6)(−3)=101−28.8−18.72+2.496−1.1232=54.8528, identically matching the forward result).
Step 5. Part (ii), the year 1925 (Newton's Backward Interpolation).
For x=1925, choose xn=1931 (end of table): p=101925−1931=−0.6
Using backward differences from xn=1931:
| Term | Working | Value | Running |
|---|---|---|---|
| yn | 101 | 101.000000 | |
| p∇yn | (−0.6)(8) | −4.8 | 96.200000 |
| 2p(p+1)∇2yn | 2(−0.6)(0.4)(−4)=(−0.12)(−4) | +0.48 | 96.680000 |
| 6p(p+1)(p+2)∇3yn | 6(−0.6)(0.4)(1.4)(−1)=(−0.056)(−1) | +0.056 | 96.736000 |
| 24p(p+1)(p+2)(p+3)∇4yn | 24(−0.6)(0.4)(1.4)(2.4)(−3)=(−0.0336)(−3) | +0.1008 | 96.836800 |
Curve fitting. Finding the constants of a chosen function form so that it comes as close as possible to a set of data points. Unlike interpolation, the curve is not required to pass through the points. It is the right tool when the data carry measurement error, or when more points are given than a polynomial of the wanted degree needs.
Step 1. Linearise. The model y=aebx is nonlinear in the unknowns eb and a. Taking natural logarithms makes it linear:
lny=lna+bx
Let Y=lny, A=lna and B=b. Then Y=A+Bx, which is a straight line, and the method of least squares applies to the logarithms.
Step 2. Logarithms of the data.
| x | y | Y=lny | x2 | xY |
|---|---|---|---|---|
| 2 | 4.077 | 1.405361 | 4 | 2.810722 |
| 4 | 11.084 | 2.405503 | 16 | 9.622012 |
| 6 | 30.128 | 3.405455 | 36 | 20.432730 |
| 8 | 81.897 | 4.405462 | 64 | 35.243696 |
| 10 | 222.62 | 5.405466 | 100 | 54.054660 |
| Σ | 17.027248 | 220 | 122.163825 |
Step 3. Normal equations.
n=5,∑x=30,∑Y=17.027248,∑x2=220,∑xY=122.163825 b=n∑x2−(∑x)2n∑xY−∑x∑Y=5(220)−3025(122.163825)−30(17.027248)=1100−900610.819125−510.817440=200100.001694=0.500008 lna=n∑Y−b∑x=517.027248−15.000254=52.026994=0.405399 a=e0.405399=1.499900Step 4. The fitted curve.
b=0.5000,a=1.4999,y=1.4999e0.5000x≈1.5ex/2
Step 5. Check the residuals.
| x | y | Fitted y^ | lny−(A+Bx) |
|---|---|---|---|
| 2 | 4.077 | 4.077221 | −0.000054 |
| 4 | 11.084 | 11.083224 | +0.000070 |
| 6 | 30.128 | 30.127836 | +0.000005 |
| 8 | 81.897 | 81.897337 | −0.000004 |
| 10 | 222.62 | 222.623816 | −0.000017 |
Every residual is below 7×10−5 in log space, so the straight line in lny against x is an excellent description of the data.
The system. To solve
Ax=b,A=[aij]∈Rn×n
Direct methods produce the exact solution in a fixed number of steps, decided in advance by n. They do not iterate toward the answer, which is what distinguishes them from iterative methods.
The two families.
Everything else is a variant of one of these two ideas.
Described: Gaussian elimination with partial pivoting.
Write the augmented matrix [A∣b]. For column k, find the row p≥k with the largest ∣apk∣, and swap rows k and p. Then eliminate the entries below the pivot:
for i=k+1,…,n:mik=akkaik,rowi←rowi−mikrowk
This makes every entry below the diagonal of column k zero. Repeat for k=1,2,…,n−1. The result is upper triangular:
a110⋮0a12a220⋯⋯⋱⋯a1na2n⋮annx=cNow back-substitute from the bottom:
xn=anncn,xi=aii1(ci−j=i+1∑naijxj)
Worked micro-example. Solve 2x+y=5 and x−y=1.
[211−1∣∣51]Pivot in column 1 is 2; the row 2 entry is 1, so no swap is needed. m21=21, and row 2 becomes [0,−1−21∣1−25]=[0,−23∣−23].
Back-substitute: y=−3/2−3/2=1, then 2x=5−1=4 so x=2.
x=2,y=1Check: 2(2)+1=5 and 2−1=1. Both hold.
Why pivoting is not optional. The step divides by the pivot. A zero pivot stops the method dead. A tiny pivot is worse, because the multiplier mik=akkaik becomes huge, and subtracting large nearly equal numbers destroys most of the significant digits. The method still runs and returns a wrong answer, with no warning. Partial pivoting costs one comparison per candidate and no extra arithmetic, and it is the standard safeguard.
| Method | Work | Storage | Notes |
|---|---|---|---|
| Gaussian elimination | 32n3 | n2 | Triangular solve is O(n2) |
| Gauss-Jordan | n3 | n2 | Gives the inverse directly |
| LU factorisation | 32n3 | n2 | Reuse the factors for many right sides |
| Cholesky | 31n3 | 21n2 | Half the work, but needs A symmetric positive definite |
Direct against iterative. Direct methods cost O(n3) and are unbeatable for small and dense systems. But n3 becomes hopeless: at n=104 it is 1012 operations, and the matrix alone needs 8×107 entries. Large sparse systems, which is what discretised PDEs produce, are handled by iterative methods that touch only the non-zero entries. The iterative methods in Q.4(b) and Q.7(b) of this paper are the other side of that trade.
Eliminate to upper triangular form, pivot to stay safe, then back-substitute
Figure 2020 Q4(b): three-mesh DC circuit with an independent voltage source and an independent current source (Source: Page 1, Q.4(b))
Step 1. Deal with the current source first. Mesh 3 is bounded on the right by an ideal 10 A current source and on the left by the 100 Ω resistor shared with mesh 2. A current source fixes the branch current, so the clockwise mesh current is
I3=10 A
This is the step that trips people up. A current source in a branch forces I3 to equal it, full stop, and it drops out of the system entirely.
Step 2. Mesh 1, KVL. Going clockwise around the left loop: rise 400 V through the source, drop across the 20 Ω, then across the shared 40 Ω which carries I1−I2 because I2 returns through it.
−400+20I1+40(I1−I2)=0
60I1−40I2=400
Step 3. Mesh 2, KVL. The 40 Ω carries I2−I1, the 10 Ω carries I2 alone, and the 100 Ω carries I2−I3.
40(I2−I1)+10I2+100(I2−I3)=0
−40I1+150I2=100I3=1000
Step 4. The system to iterate. Three equations, but I3 is already known, so two unknowns remain:
{60I1−40I2=400−40I1+150I2=1000
Solve each for its own variable, newest value first:
⎩⎨⎧I1=6040I2+400I2=1501000+40I1
Step 5. Gauss-Seidel. Use the value just computed, never the previous iteration's. Start from I1(0)=I2(0)=0.
| k | I1 | I2 |
|---|---|---|
| 0 | 0.000000 | 0.000000 |
| 1 | 6.666667 | 8.444444 |
| 2 | 12.296296 | 9.945679 |
| 3 | 13.297119 | 10.212565 |
| 4 | 13.475043 | 10.260012 |
| 5 | 13.506674 | 10.268447 |
| 6 | 13.512298 | 10.269946 |
| 7 | 13.513297 | 10.270213 |
| 8 | 13.513475 | 10.270260 |
| 9 | 13.513507 | 10.270268 |
| 10 | 13.513512 | 10.270270 |
Iteration 1: I1(1)=6040(0)+400=6.666667, then I2(1)=1501000+40(6.666667)=1501000+266.6667=8.444444.
Step 6. Answer.
I1=13.5135 A,I2=10.2703 A,I3=10.0000 AThe result.
yn(x)=y0+pΔy0+2!p(p−1)Δ2y0+3!p(p−1)(p−2)Δ3y0+⋯+n!p(p−1)(p−2)⋯(p−n+1)Δny0
with p=hx−x0 and h the common spacing.
Derivation.
Step 1. Set up. Take n+1 equally spaced points xi=x0+ih, with yi=f(xi) and h=x1−x0. Write the target as x=x0+ph so p=hx−x0.
Step 2. Newton's general form. For arbitrary nodes the interpolating polynomial is the Newton form
Pn(x)=f[x0]+f[x0,x1](x−x0)+f[x0,x1,x2](x−x0)(x−x1)+⋯
where f[xi,…,xi+k] is a divided difference, defined recursively by f[xi]=f(xi) and
f[xi,…,xi+k]=xi+k−xif[xi+1,…,xi+k]−f[xi,…,xi+k−1]
Step 3. The special case of equal spacing. When the nodes are equally spaced the divided differences collapse onto ordinary finite differences:
f[xi,xi+1,…,xi+k]=k!hkΔkyiThis is the key identity. To see why, the first divided difference on equal steps is hyi+1−yi=hΔyi. Each further divided difference divides the difference of two k!hk multiples by one more h and by k+1, giving (k+1)!hk+1. Induction finishes it.
Step 4. Substitute into the Newton form.
Pn(x)=y0+1!hΔy0(x−x0)+2!h2Δ2y0(x−x0)(x−x1)+3!h3Δ3y0(x−x0)(x−x1)(x−x2)+⋯
Step 5. Factor out the h. Since x−xi=(p−i)h, the product (x−x0)(x−x1)⋯(x−xi−1)=(p)(p−1)⋯(p−i+1)hi. Substituting, the hi in the numerator cancels the hi in the denominator:
Pn(x)=y0+pΔy0+2!p(p−1)Δ2y0+3!p(p−1)(p−2)Δ3y0+⋯Step 6. The final form, which is the box above.
Another way to see it. Expand f in a Taylor series about x0 and replace each derivative by a finite difference, using f(k)(x0)=hkΔky0:
f(x)=f(x0)+phf′(x0)+2!p2h2f′′(x0)+3!p3h3f′′′(x0)+⋯
The h's cancel immediately, giving y0+pΔy0+2!p2Δ2y0+⋯. The only difference from the standard formula is that the p2 has become p(p−1) and the p3 has become p(p−1)(p−2). That substitution is not a trick: the finite differences already carry the effect of the lower-order terms, and replacing rising powers by falling products is what avoids double counting.
Validity. Accurate for 0≤p≤n, that is inside the table. Near the far end use backward differences instead, and outside the table the result is an extrapolation with the risks listed in Q.3(a). Part (b) applies this to unequally spaced data, where divided differences are used instead.
| t | 0.5 | 0.2 | 1.4 | 2.2 | 3.0 |
|---|---|---|---|---|---|
| s(t) | −10.25 | −3.768 | 5.976 | 28.972 | 79.0 |
Step 1. Build the divided difference table. Each entry divides by the x-difference of the two nodes it spans.
| Order | Values |
|---|---|
| s(ti) | −10.250000, −3.768000, 5.976000, 28.972000, 79.000000 |
| 1st | −21.606667, 8.120000, 28.745000, 62.535000 |
| 2nd | 33.029630, 10.312500, 21.118750 |
| 3rd | −13.363017, 3.859375 |
| 4th | 6.888957 |
Worked entries, so nothing is asserted on trust:
f[x0,x1]=0.2−0.5−3.768−(−10.25)=−0.36.482=−21.606667 f[x1,x2]=1.4−0.25.976−(−3.768)=1.29.744=8.12 f[x0,x1,x2]=1.4−0.58.12−(−21.606667)=0.929.726667=33.029630 f[x1,x2,x3]=2.2−0.2f[x2,x3]−f[x1,x2],f[x2,x3]=2.2−1.428.972−5.976=0.822.996=28.745 f[x1,x2,x3]=2.028.745−8.12=10.3125,f[x0,x1,x2,x3]=2.2−0.510.3125−33.029630=1.7−22.717130=−13.363017 f[x2,x3,x4]=3.0−1.4f[x3,x4]−f[x2,x3],f[x3,x4]=3.0−2.279.0−28.972=0.850.028=62.535 f[x2,x3,x4]=1.662.535−28.745=21.11875,f[x1,x2,x3,x4]=3.0−0.221.11875−10.3125=2.810.80625=3.859375 f[x0,x1,x2,x3,x4]=3.0−0.53.859375−(−13.363017)=2.517.222392=6.888957Step 2. Write the polynomial. The leading diagonal is −10.25, −21.606667, 33.029630, −13.363017, 6.888957.
s(t)=−10.25+(−21.606667)(t−0.5)+(33.029630)(t−0.5)(t−0.2)+(−13.363017)(t−0.5)(t−0.2)(t−1.4)+(6.888957)(t−0.5)(t−0.2)(t−1.4)(t−2.2)Step 3. Evaluate at t=2.25. The factors are 1.75, 2.05, 0.85, 0.05.
| Term | Working | Value | Running |
|---|---|---|---|
| s0 | −10.250000 | −10.250000 | |
| f[x0,x1](t−x0) | (−21.606667)(1.75) | −37.811667 | −48.061667 |
| f[x0,x1,x2](t−x0)(t−x1) | (33.029630)(1.75)(2.05)=(33.029630)(3.5875) | +118.494 | +70.432 |
| f[x0..x3](⋅)(⋅)(⋅) | (−13.363017)(1.75)(2.05)(0.85)=(−13.363017)(3.049375) | −40.749 | 29.683 |
| f[x0..x4](⋅)(⋅)(⋅)(⋅) | (6.888957)(1.75)(2.05)(0.85)(0.05)=(6.888957)(0.15246875) | +1.050 | 30.734 |
Both are Newton-Cotes rules: they fit a polynomial through the data at equally spaced nodes and integrate that polynomial exactly over the panel. They differ in how many nodes each panel uses and therefore in which interval counts each admits.
| Simpson's 1/3 | Simpson's 3/8 | |
|---|---|---|
| Subintervals per panel | 2 | 3 |
| Nodes per panel | 3 | 4 |
| Weights | 1, 4, 1 | 1, 3, 3, 1 |
| Prefactor | 3h | 83h |
| Panel interval count | Must be even | Must be a multiple of 3 |
| Total intervals n | Even | Multiple of 3 |
| Order of accuracy | 4 | 4 |
| Leading error term | −90h5f(4) | −803h5f(4) |
| Error constant | 901=0.0111 | 803=0.0375 |
Both are fourth order, so both need a function with f(4) continuous over the range. Neither is fourth order on a function with a discontinuous fourth derivative, and neither is safe near a vertical asymptote or a jump.
The accuracy difference. With the same h, Simpson's 3/8 has a leading error constant 3.375 times larger than 1/3. So for equal h, 1/3 is more accurate, and 1/3 is the default choice.
The one place 3/8 wins. When the total interval count is odd, 1/3 is inapplicable while 3/8 can still be used, provided the count is a multiple of 3. Five intervals is the standard case: 1/3 is stuck, 3/8 takes three of them and something else takes two. That exact situation is in Q.6(b) below, and it is why the rule is worth knowing.
Standard mixed strategy for an odd n not divisible by 3, for example n=5: apply 3/8 to the last three intervals and 1/3 to the remaining two, or apply 1/3 to the largest even block and the trapezoid rule to the leftover one interval. Both appear in Q.6(b).
Why the error behaves as it does. A 3-node panel interpolates a quadratic, whose integration error involves f′′. A 4-node panel interpolates a cubic, involving f(4). Symmetry about the panel centre cancels the odd-order terms in both cases, which is why both reach fourth order rather than third.
Both are fourth order; 1/3 is more accurate at equal h but needs an even interval count| t | 0 | 0.25 | 0.50 | 0.75 | 1.00 | 1.25 |
|---|---|---|---|---|---|---|
| vi(t) | 1 | 0.9793 | 0.9195 | 0.8261 | 0.7081 | 0.6201 |
Step 1. The constant.
RC=(10×103)(1×10−6)=10−2 s=0.01 s,RC1=100 s−1
Step 2. The integral. Take h=0.25 s. The largest even block is t=0 to t=1.00, four intervals, and the leftover interval t=1.00 to 1.25 goes to the trapezoid rule.
Simpson's 1/3 on 0 to 1.00, with weights 1,4,2,4,1:
I1/3=3h[v0+4v1+2v2+4v3+v4]=30.25[1+4(0.9793)+2(0.9195)+4(0.8261)+0.7081] =30.25[1+3.9172+1.8390+3.3044+0.7081]=30.25(10.7687)=0.89739167Trapezoid on 1.00 to 1.25:
IT=2h(v4+v5)=20.25(0.7081+0.6201)=0.125(1.3282)=0.166025Total:
I=0.89739167+0.166025=1.06341667Step 3. The output voltage. The leading minus sign comes from the inverting amplifier that realises the equation, and it must be carried through.
v0=−RC1I=−100(1.06341667)=−106.341667 v0(1.25)=−106.34 V| t | 0 | 0.02 | 0.04 | 0.06 | 0.08 | 0.10 | 0.12 |
|---|---|---|---|---|---|---|---|
| θ | 0.052 | 0.105 | 0.168 | 0.242 | 0.327 | 0.408 | 0.489 |
Step 1. Angular velocity is the derivative. ω=dtdθ, so this is numerical differentiation of a table with h=0.02 s.
Step 2. t=0.06 is an interior node. Data exist on both sides, at 0.04 and 0.08, so the three-point central formula applies and is both the most accurate of the three-point formulas and the natural one here.
dtdθ0.06≈2hθ0.08−θ0.04=2(0.02)0.327−0.168=0.040.159=3.975 dtdθt=0.06≈3.975 rad/sStep 3. The other available formulas, for comparison.
| Formula | Nodes needed | Value at t=0.06 |
|---|---|---|
| Three-point central | 0.04,0.06,0.08 | 3.975 |
| Five-point central | 0.02 to 0.10 | 4.0375 |
| Three-point forward | 0.06,0.08,0.10 | 4.350 |
| Three-point backward | 0.02,0.04,0.06 | 3.975 |
The five-point central formula is available here, because 0.06−2h=0.02 is in the table:
dtdθ0.06≈12hθ0.02−8θ0.04+8θ0.08−θ0.10=0.240.105−8(0.168)+8(0.327)−0.408 =0.240.105−1.344+2.616−0.408=0.240.969=4.0375Euler's method, for reference. For dxdy=f(x,y) with y(x0)=y0 and step h,
yn+1=yn+hf(xn,yn)
It takes the slope at the left endpoint of the interval and assumes it holds across the whole interval. The local truncation error is O(h2) and the global error is O(h), so the method is first order.
Step 1. The idea of the modification. Euler's weakness is that it uses only one slope per step and that slope is at the wrong end. Average two slopes, one at each end of the interval, and the error drops by a whole order.
Step 2. Compute the slope at the left end. Predict with plain Euler:
yp=yn+hf(xn,yn)
Step 3. Compute the slope at the right end, using that predicted value:
fn+1=f(xn+h,yp)
Step 4. Average the two slopes and take the step.
yn+1=yn+2h[f(xn,yn)+f(xn+h,yn+hf(xn,yn))]This is Heun's method, also called the improved Euler method or the trapezoidal method. Another name for it is the two-stage second-order Runge-Kutta method, since the k values below reproduce it exactly.
Step 5. The Runge-Kutta form, to show where it comes from. With k1=hf(xn,yn) and k2=hf(xn+h,yn+k1),
yn+1=yn+21(k1+k2)
Step 6. Accuracy. The two-slope average cancels the leading local error term, so the local truncation error becomes O(h3) and the global error becomes O(h2). The method is now second order: halving h cuts the error by 4 instead of 2. The cost is one extra function evaluation per step, so roughly double the work for one extra order of accuracy. That is nearly always worth it.
The major limitation of Euler's method.
Euler's method is first order accurate, so it needs far too many steps for the accuracy usually wanted, and it goes unstable when h exceeds a stability limit.
Two parts, and the second is the serious one.
Low order. Global error O(h). Reaching four correct digits with h=10−4 means 104 steps, and the accumulated round off grows with the step count, so the gain flattens out.
Conditional stability. For the test equation y′=λy with λ<0, Euler gives yn+1=(1+hλ)yn. Stability needs ∣1+hλ∣<1, that is h<∣λ∣2 and for a stiff system ∣λ∣ is enormous, so h must be tiny. Meanwhile the truncation error wants h small too, so the two demands are compatible but expensive, and any step-size increase blows the solution up with no warning.
Practical note. Heun's method is not unconditionally stable either. For y′=λy it gives yn+1=(1+z+z2/2)yn with z=hλ, and stability needs ∣1+z+z2/2∣<1, which allows −2<z<0, a range of 2 against Euler's 2. It is modestly better, not a cure. Real stiff solvers use the backward or implicit trapezoidal methods, which have unbounded stable regions.
yn+1=yn+2h[f(xn,yn)+f(xn+h,yn+hf(xn,yn))],second orderStep 1. The method. With f(x,y)=x+y and h=0.2,
yn+1=yn+0.2(xn+yn),xn+1=xn+0.2
Start at x0=0, y0=0.
Step 2. Three steps.
| Step | xn | yn | Slope xn+yn | yn+1=yn+0.2×slope |
|---|---|---|---|---|
| 1 | 0.0 | 0.000000 | 0.0+0.0=0.0 | 0.0+0.2(0)=0.000000 |
| 2 | 0.2 | 0.000000 | 0.2+0.0=0.2 | 0.0+0.2(0.2)=0.040000 |
| 3 | 0.4 | 0.040000 | 0.4+0.04=0.44 | 0.04+0.2(0.44)=0.128000 |
Step 1 in full: the slope at x=0 is 0+0=0, so y1=0+0.2(0)=0. The curve leaves the origin horizontally, which is correct since y′=x+y is zero at the origin.
Step 2: y2=0.04. Step 3: y3=0.128.
y(0.4)=0.0400,y(0.6)=0.1280(h=0.2)Step 1. The method. For dxdy=f(x,y) with y(x0)=y0 and step h, the second-order Runge-Kutta method is
k1=hf(xn,yn),k2=hf(xn+h,yn+k1),yn+1=yn+21(k1+k2)Here f(x,y)=y−x and the paper gives no step size. Two steps are needed to reach 0.2, so take h=0.1, which also matches the requested output points. Start at x0=0, y0=2.
Step 2. Step 1: x0=0 to x1=0.1.
k1=0.1f(0,2)=0.1(2−0)=0.2
k2=0.1f(0+0.1,2+0.2)=0.1(2.2−0.1)=0.1(2.1)=0.21
y1=2+20.2+0.21=2+0.205=2.205000
Step 3. Step 2: x1=0.1 to x2=0.2.
k1=0.1f(0.1,2.205)=0.1(2.205−0.1)=0.1(2.105)=0.2105
k2=0.1f(0.1+0.1,2.205+0.2105)=0.1(2.4155−0.2)=0.1(2.2155)=0.22155
y2=2.205+20.2105+0.22155=2.205+0.216025=2.421025
| Step | xn | yn | k1 | k2 | yn+1 |
|---|---|---|---|---|---|
| 1 | 0.0 | 2.000000 | 0.200000 | 0.210000 | 2.205000 |
| 2 | 0.1 | 2.205000 | 0.210500 | 0.221550 | 2.421025 |
A partial differential equation involves partial derivatives with respect to two or more independent variables. The four classical types depend on the order of the highest derivatives.
1. Laplace equation. No time or reaction term, steady state.
∂x2∂2u+∂y2∂2u=0
Physical meaning: steady-state heat conduction, electrostatics, incompressible irrotational flow, torsional rigidity. Boundaries are prescribed values of u on the edges of a region. Solved by Q.8(b) of this paper.
2. Poisson equation. Laplace with a source term.
∇2u=−f(x,y)
Physical meaning: steady heat conduction with internal heat generation, electrostatics with a charge density, potential flow with sources. Same boundary condition type as Laplace. Solved by 2021 Q.6(c).
3. Wave equation. Time-dependent, second order in both space and time.
∂t2∂2u=c2∇2u
Physical meaning: vibrating string, sound in air, water waves, electromagnetic waves. c is the wave speed. Needs an initial condition u(x,0)=f(x), ∂t∂u(x,0)=g(x), plus boundary conditions.
4. Heat equation, or diffusion equation. Time-dependent, second order in space, first order in time.
∂t∂u=α∇2u
Physical meaning: heat conduction in a solid, diffusion of a solute, spread of an epidemic. α=ρck is the thermal diffusivity. Needs an initial condition u(x,y,0)=f(x,y) plus boundary conditions.
The deciding test. For a linear second-order PDE Auxx+2Buxy+Cuyy+⋯=0, compute the discriminant B2−AC:
| Sign of B2−AC | Type | Example |
|---|---|---|
| <0 | Elliptic | Laplace, Poisson |
| =0 | Parabolic | Heat equation |
| >0 | Hyperbolic | Wave equation |
The solved example: the heat equation by an iterative numerical technique.
∂t∂u=α(∂x2∂2u+∂y2∂2u)
Step 1. Discretise the grid. Divide the region into a mesh of spacing h in space and Δt in time. The stability condition is the key practical result:
αh2Δt≤41in two dimensions
Step 2. Replace the second derivative by its central difference.
Δtui,jn+1−ui,jn=αh2ui+1,jn−2ui,jn+ui−1,jn
Step 3. Rearrange into the update formula with λ=h2αΔt:
ui,jn+1=λui+1,jn+λui−1,jn+λui,j+1n+λui,j−1n+(1−4λ)ui,jn
Each new value is a weighted average of the four neighbours plus the old centre. The weights are all non-negative as long as λ≤41, which is the stability condition.
Step 4. The explicit scheme above is one choice. The two alternatives are the implicit (backward Euler) scheme, which writes the same update at time n+1 instead of n and is unconditionally stable but needs a linear solve each step, and the Crank-Nicolson scheme, which averages the explicit and implicit forms and is second order in time while still unconditionally stable.
Step 5. March in time. The scheme is explicit, so each time level follows directly from the previous one. Start from the initial condition, apply the boundary values at every level, and step forward until the desired time.
Why iterative methods are used at all. The same problem in the Laplace or Poisson form gives a large linear system at every instant. A finite difference discretisation of a 100×100 mesh gives over 104 unknowns, and solving it directly at every time step is wasteful when the change between steps is small. The iterative methods trade a little work per step for a much cheaper step, and for the elliptic case they converge to the steady state directly.
The iterative method used in this paper. For an elliptic equation, time does not appear, so instead of marching one marches the iteration count. Replacing each interior node by the average of its four neighbours and repeating is exactly the Liebmann method, and the averaging weights of 41 are the same as above with λ=41. Q.8(b) works it through.
| Explicit | Implicit | Crank-Nicolson | |
|---|---|---|---|
| Stability | Needs λ≤41 | Unconditional | Unconditional |
| Work per step | Very low | Linear solve | Linear solve |
| Order in time | 1 | 1 | 2 |
| When to use | Short runs, small λ | Stiff problems | Accuracy needed |
Figure 2020 Q8(b): square domain with Dirichlet boundary values and four interior nodes for the Laplace equation (Source: Page 2, Q.8(b))
Step 1. Set up the grid. The domain is a square with Δx=Δy=h and four interior nodes. The boundary values are 1 along the top edge and 0 along the bottom, left and right edges.
Step 2. The Liebmann update. The five-point formula for Laplace's equation with equal spacing is
Ei,j=41(Ei−1,j+Ei+1,j+Ei,j−1+Ei,j+1)
Each interior node takes the average of its four neighbours. The moment a node's new value is computed, it replaces the old one, which is what makes the method Liebmann rather than Jacobi.
Step 3. Write the four update equations, reading the boundary values off the figure.
E1=41(0+E2+0+E4)=4E2+E4
E2=41(E1+0+0+E3)=4E1+E3
E3=41(E4+0+E2+1)=4E4+E2+1
E4=41(0+E3+E1+1)=4E3+E1+1
Each boundary neighbour contributes its known value, which is why the +1 appears in E3 and E4 and nowhere else: those are the two nodes touching the top edge. This is the step where the boundary values enter, and getting the figure's node labelling wrong puts the +1 in the wrong two equations.
Step 4. Iterate. Start from E1=E2=E3=E4=0 and sweep E1,E2,E3,E4 in that order, using the newest value available.
| k | E1 | E2 | E3 | E4 |
|---|---|---|---|---|
| 0 | 0.000000 | 0.000000 | 0.000000 | 0.000000 |
| 1 | 0.000000 | 0.000000 | 0.250000 | 0.312500 |
| 2 | 0.078125 | 0.082031 | 0.348633 | 0.356689 |
| 3 | 0.109680 | 0.114578 | 0.367817 | 0.369374 |
| 4 | 0.120988 | 0.122201 | 0.372894 | 0.373471 |
| 5 | 0.123918 | 0.124203 | 0.374418 | 0.374584 |
| 6 | 0.124697 | 0.124779 | 0.374841 | 0.374884 |
| 7 | 0.124916 | 0.124939 | 0.374956 | 0.374968 |
| 8 | 0.124977 | 0.124983 | 0.374988 | 0.374991 |
| 9 | 0.124994 | 0.124995 | 0.374997 | 0.374998 |
| 10 | 0.124998 | 0.124999 | 0.374999 | 0.374999 |
Iteration 1 in full: E1=0 since it depends only on the zero boundary and on other unknowns still at 0. E2=0 likewise. E3=40+0+0+1=0.25, then E4=40+0.25+0+1=0.3125.
Step 5. Answer.
E1=0.125,E2=0.125,E3=0.375,E4=0.375Convergence to four decimal places is reached at iteration 8, and by iteration 10 every value is correct to six decimals.