66.6 KB · commit a9602da
| title | ECE 2213 · 2021 Exam Style Answers |
|---|
RUET · ECE Dept · B.Sc. Engineering 2nd Year Even Semester Examination, 2021 Full Marks: 72 (97 total paper marks) · Time: 03:00 Hours · CLO-mapped
Analytical method. Manipulates symbols to reduce the problem to a closed form. The answer is exact and valid at every point of the domain.
Numerical method. Approximates the problem by a form that can be evaluated digit by digit. The answer is a pair of numbers, valid near the point computed.
| Analytical | Numerical | |
|---|---|---|
| Result | Closed form, exact | Approximate |
| Domain of validity | Whole domain | Local, near one point |
| Problem size it can handle | Small | Grows nearly linearly with effort |
| Round off error | None | Present at every operation |
| Effect of changing data | Instant re-evaluation | Full recomputation |
| Structure it reveals | Conservation laws, invariants | Hides them |
Why ECE engineers need numerical methods.
Derivation. Let x∗ be the root of f(x)=0. Start at x0 and follow the tangent to the curve at that point.
For small h the tangent meets the x-axis at x0+h. By the first-order mean value form of the Taylor series,
0=f(x∗)=f(x0+h)≈f(x0)+hf′(x0)Solving for h and writing x1=x0+h,
x1=x0−f′(x0)f(x0)Iterating,
xn+1=xn−f′(xn)f(xn)Second order accuracy. Taking the Taylor expansion to second order,
0=f(xn)+f′(xn)Δx+2f′′(ξ)Δx2Substituting Δx=−f/f′ shows en+1≈2f′(x∗)f′′(x∗)en2. The error is squared each step, so the last iteration typically delivers every digit the machine can hold.
Problems and fixes
| Problem | Cause | Fix |
|---|---|---|
| Diverges or oscillates | Start too far from the root | Bracket first, start inside, or switch to bisection |
| Division by zero | f′(xn)=0 | Choose another start, or use the secant method |
| Cycles between two points | Overshoot from a poor start | Damp the step, or fall back to bisection on repeat |
| False convergence | f(xn)=0 but f′(xn)≈0 | Test ∣f(xn)∣, not only ∣xn+1−xn∣ |
| Slow at a repeated root | Squaring needs a simple root | Use xn+1=xn−mf′(xn)f(xn) with m the multiplicity |
| No tangent information | Step-like function such as signum | Bisection, which needs only a sign change |
| f′ unavailable | Only f is given | Secant method, or finite-difference derivative |
The general safeguard. Keep a bracket [a,b] with f(a)f(b)<0. If a Newton step leaves the bracket, take a bisection step instead. This hybrid keeps Newton's speed and bisection's guarantee, and it is what production root finders do.
Step 1. Choose a series that converges. The familiar expansion
ln(1+x)=x−2x2+3x3−⋯converges only for ∣x∣<1. Here 3=1+2, so x=2 and the series diverges. Substituting x=2 and adding terms gives a number that drifts away from ln3 forever.
Step 2. Use the hyperbolic form instead. Write
ln1−y1+y=2(y+3y3+5y5+⋯),∣y∣<1Set 1−y1+y=3. Then 1+y=3−3y, so 4y=2 and
y=3+13−1=21which satisfies ∣y∣<1.
Step 3. Expand.
ln3=2[21+8×31+32×51+128×71+512×91+2048×111+8192×131+⋯]Step 4. Add terms until the error is below 21×10−5.
| Terms | Partial sum | Error |
|---|---|---|
| 5 | 1.0984995040 | 1.13×10−4 |
| 6 | 1.0985882824 | 2.40×10−5 |
| 7 | 1.0986070624 | 5.23×10−6 |
| 8 | 1.0986111314 | 1.16×10−6 |
Seven terms give an error of 5.23×10−6, still above 2110−5. Eight terms give 1.16×10−6, comfortably inside, so eight terms are required.
Step 5. Round.
ln3=1.09861Definition. A bracketing method is an iterative root finder that begins with an interval [a,b] in which the function changes sign,
f(a)⋅f(b)<0By the intermediate value theorem a continuous f must have at least one root in (a,b). Each iteration picks a new point inside the current interval and retains the half that still shows a sign change, so the root is never lost.
Properties.
Examples.
| Method | New point | Rate |
|---|---|---|
| Bisection | Midpoint, 2a+b | Linear |
| Regula falsi | Chord, f(b)−f(a)af(b)−bf(a) | Superlinear, often |
| Illinois method | Regula falsi with a halved stale value | Superlinear, robust |
Step 1. Define the function and check the bracket.
f(x)=x2.2−69 f(5)=52.2−69=34.4932−69=−34.5068 f(8)=82.2−69=97.0059−69=+28.0059f(5)<0<f(8), so a root lies in (5,8). The function is continuous there since x2.2 is continuous for x>0.
Step 2. The formula. Draw the straight line joining the two endpoints. It cuts the x-axis at
x=f(b)−f(a)af(b)−bf(a)Step 3. Iterate. Keep whichever endpoint has the same sign as the new point and replace the other.
| Iteration | a | b | New point x | f(x) |
|---|---|---|---|---|
| 1 | 5.000000 | 8.000000 | 6.655990 | −4.27563 |
| 2 | 6.655990 | 8.000000 | 6.834002 | −0.40615 |
| 3 | 6.834002 | 8.000000 | 6.850670 | −0.03755 |
| 4 | 6.850670 | 8.000000 | 6.852209 | −0.00346 |
| 5 | 6.852209 | 8.000000 | 6.852351 | −0.00032 |
| 6 | 6.852351 | 8.000000 | 6.852364 | −0.00003 |
| 7 | 6.852364 | 8.000000 | 6.852365 | −0.000003 |
Working the first row in full:
x1=28.0059−(−34.5068)5(28.0059)−8(−34.5068)=62.5127140.0295+276.0544=62.5127416.0839=6.655990 x=6.85237(to five decimal places)Or to four places, x=6.8524.
Step 1. Locate the roots by sign changes. Evaluate at integer values:
| x | f(x) | Sign |
|---|---|---|
| 0 | −24 | − |
| 1 | 1−9+26−24=−6 | − |
| 2 | 8−36+52−24=0 | 0 |
| 3 | 27−81+78−24=0 | 0 |
| 4 | 64−144+104−24=0 | 0 |
| 5 | 125−225+130−24=6 | + |
Step 2. Recognise the factorisation. All of 2,3,4 are exact roots, and a cubic has at most three, so
f(x)=(x−2)(x−3)(x−4)Verification by expansion: (x−2)(x−3)=x2−5x+6, and (x2−5x+6)(x−4)=x3−4x2−5x2+20x+6x−24=x3−9x2+26x−24. Correct.
Step 3. Smallest root.
x=2Step 4. Confirm with a numerical method, since the question asks for root finding. Use Newton-Raphson with
f(x)=x3−9x2+26x−24,f′(x)=3x2−18x+26Start at x0=1.5, where f(1.5)=3.375−20.25+39−24=−1.875 and f′(1.5)=6.75−27+26=5.75:
| Iteration | xn | f(xn) | f′(xn) |
|---|---|---|---|
| 0 | 1.5000000 | −1.875000 | 5.750000 |
| 1 | 1.8260870 | −0.443823 | 3.134215 |
| 2 | 1.9676929 | −0.067779 | 2.196974 |
| 3 | 1.9985440 | −0.002918 | 2.008742 |
| 4 | 1.9999968 | −0.000006 | 2.000019 |
| 5 | 2.0000000 | 0 | 2.000000 |
Iteration 1: x1=1.5−5.750000−1.875=1.5+0.326087=1.826087. Iteration 2: x2=1.826087−3.134215−0.443823=1.826087+0.141606=1.967693.
The derivative column matters. Newton divides by f′(xn), and here f′ drifts from 5.75 to 2.00 across the five steps, so a value carried over from the previous row is visibly wrong. It settles at 2.00=f′(2), which is the self-consistency check at the root.
Apply interpolation when the data are exact and the target lies between the given points.
Two conditions must both hold:
Typical situations: a value read off a mathematical function, a quantity defined by interpolation in a standard, a small number of exact tabulated constants.
Apply curve fitting when the data carry measurement error, when the underlying trend is the object of interest rather than reproduction of every point, or when a lower-degree form is wanted from many noisy points.
Exact data and a target between the points: interpolate. Noisy data: fit.| Newton's interpolation | Lagrange's interpolation | |
|---|---|---|
| Form | Successive approximation, applied one point at a time | Single polynomial, all points at once |
| Basis | Divided differences or forward/backward differences | Products ∏j=ixi−xjx−xj |
| Adding a new point | Old result is retained; only a new term is added | Whole polynomial must be rebuilt |
| Equally spaced points | Forward/backward difference form is fastest | Works but ignores the equal spacing |
| Unequal spacing | Needs divided differences | Natural, no change needed |
| Cost per evaluation | O(n) after setup | O(n2) directly, O(n) with Neville |
| Near the table ends | Forward at the start, backward at the end | One formula for everywhere |
| Numerical stability | Better with the Neville form | Degrades with many points |
Newton gives an update rule, cheap when data arrive incrementally. Lagrange gives a construction, direct, and equally spaced points require no special case.
Newton updates and reuses; Lagrange rebuilds once and is spacing-agnosticSet up. Let the function y=f(x) take values y0,y1,y2,…,yn at n+1 equidistant points x0,x1,x2,…,xn with constant step size h, such that xi=x0+ih.
Assume the interpolating polynomial Pn(x) of degree n in the form:
Pn(x)=a0+a1(x−x0)+a2(x−x0)(x−x1)+a3(x−x0)(x−x1)(x−x2)+⋯+an(x−x0)(x−x1)⋯(x−xn−1)Step 1. Determine the coefficients a0,a1,a2,… successively.
At x=x0: y0=Pn(x0)=a0⟹a0=y0
At x=x1=x0+h: y1=Pn(x1)=a0+a1(x1−x0)=y0+a1h a1=hy1−y0=1!hΔy0
At x=x2=x0+2h: y2=Pn(x2)=a0+a1(x2−x0)+a2(x2−x0)(x2−x1)=y0+a1(2h)+a2(2h)(h) y2=y0+2Δy0+2h2a2 Since Δ2y0=y2−2y1+y0=y2−2(y0+Δy0)+y0=y2−y0−2Δy0: 2h2a2=Δ2y0⟹a2=2!h2Δ2y0
By induction, the general coefficient is: ak=k!hkΔky0,k=0,1,2,…,n
Step 2. Express in terms of the dimensionless variable p.
Let x=x0+ph, so that p=hx−x0. Then: x−x0=ph x−x1=x0+ph−(x0+h)=(p−1)h x−x2=(p−2)h,…,x−xk−1=(p−k+1)h
The product of factors becomes: (x−x0)(x−x1)⋯(x−xk−1)=(ph)((p−1)h)⋯((p−k+1)h)=p(p−1)⋯(p−k+1)hk
Step 3. Substitute ak and product factors into Pn(x).
ak(x−x0)(x−x1)⋯(x−xk−1)=k!hkΔky0⋅p(p−1)⋯(p−k+1)hk=k!p(p−1)⋯(p−k+1)Δky0
Cancelling hk term by term yields Newton's forward interpolation formula:
yn(x)=y0+pΔy0+2!p(p−1)Δ2y0+3!p(p−1)(p−2)Δ3y0+⋯+n!p(p−1)⋯(p−n+1)Δny0Validity range. The formula is accurate for 0≤p≤1, primarily near the beginning of equidistant tables. For values near the end, backward differences are used.
| x | 0 | 1 | 3 | 4 | 5 |
|---|---|---|---|---|---|
| y | 0 | 1 | 81 | 256 | 625 |
Step 1. The formula. With five points x0=0,x1=1,x2=3,x3=4,x4=5,
y(2)=i=0∑4yiLi(2),Li(2)=j=i∏xi−xj2−xjStep 2. Compute each weight, keeping numerator and denominator factors separate.
L0(2)=(0−1)(0−3)(0−4)(0−5)(2−1)(2−3)(2−4)(2−5)=(−1)(−3)(−4)(−5)(1)(−1)(−2)(−3)=60−6=−101 L1(2)=(1−0)(1−3)(1−4)(1−5)(2−0)(2−3)(2−4)(2−5)=(1)(−2)(−3)(−4)(2)(−1)(−2)(−3)=−24−12=21 L2(2)=(3−0)(3−1)(3−4)(3−5)(2−0)(2−1)(2−4)(2−5)=(3)(2)(−1)(−2)(2)(1)(−2)(−3)=1212=1 L3(2)=(4−0)(4−1)(4−3)(4−5)(2−0)(2−1)(2−3)(2−5)=(4)(3)(1)(−1)(2)(1)(−1)(−3)=−126=−21 L4(2)=(5−0)(5−1)(5−3)(5−4)(2−0)(2−1)(2−3)(2−4)=(5)(4)(2)(1)(2)(1)(−1)(−2)=404=101Check. The weights sum to 1: −101+21+1−21+101=1 ✓
This holds at any x, not only at a node, because interpolating the constant function 1 with a degree 4 polynomial must return 1.
Step 3. Assemble.
y(2)=(0)(−101)+(1)(21)+(81)(1)+(256)(−21)+(625)(101)=0+0.5+81−128+62.5=16 y(2)=16Calibrating a thermocouple.
A calibration certificate lists certified reference temperatures and the corresponding indicated voltages:
| Reference (∘C) | Indicated (mV) |
|---|---|
| 0 | 0.00 |
| 100 | 4.09 |
| 200 | 7.33 |
| 400 | 12.45 |
The readings carry thermal drift and instrument noise, so no curve passes exactly through all four. Fitting a polynomial by least squares finds the one that comes closest, and the fitted curve then calibrates the instrument: a raw reading of 9.20 mV converts to a temperature through the fit.
Second example: a load-extension test, where the raw data scatter because the specimen is not perfectly uniform, and the fitted line gives the engineering stress and stiffness.
Why fitting rather than interpolation. The four certified points are known only to about ±0.5∘C. Interpolating would force the curve through each one exactly, importing that uncertainty into every answer. Least squares smooths it and gives a usable law between and beyond the points.
Sensor calibration: noisy readings in, a best-fit law out, and predictions follow| x | 1.00 | 1.05 | 1.10 | 1.15 | 1.20 | 1.25 | 1.30 |
|---|---|---|---|---|---|---|---|
| ex | 2.7183 | 2.8577 | 3.0042 | 3.1582 | 3.3201 | 3.4903 | 3.6693 |
Step 1. Choose origin x0 and compute p. The target is x=1.17 and step size h=0.05. Gauss' forward formula is a central-difference formula designed for 0≤p≤1 (ideally 0≤p≤0.5). Choose origin x0=1.15. Then:
p=hx−x0=0.051.17−1.15=0.050.02=0.4Step 2. Difference table.
| x | 1.00 | 1.05 | 1.10 | 1.15 | 1.20 | 1.25 | 1.30 |
|---|---|---|---|---|---|---|---|
| y | 2.7183 | 2.8577 | 3.0042 | 3.1582 | 3.3201 | 3.4903 | 3.6693 |
| Δy | 0.1394 | 0.1465 | 0.1540 | 0.1619 | 0.1702 | 0.1790 | |
| Δ2y | 0.0071 | 0.0075 | 0.0079 | 0.0083 | 0.0088 | ||
| Δ3y | 0.0004 | 0.0004 | 0.0004 | 0.0005 | |||
| Δ4y | 0.0000 | 0.0000 | 0.0001 | ||||
| Δ5y | 0.0000 | 0.0001 | |||||
| Δ6y | 0.0001 |
Step 3. Collect the central path differences.
y0=3.1582,Δy0=0.1619,Δ2y−1=0.0079,Δ3y−1=0.0004,Δ4y−2=0.0000Step 4. Evaluate the terms (p=0.4).
Gauss' forward interpolation formula is:
yp=y0+pΔy0+2!p(p−1)Δ2y−1+3!(p+1)p(p−1)Δ3y−1+4!(p+1)p(p−1)(p−2)Δ4y−2+⋯| Term | Algebraic form | Working | Value | Running sum |
|---|---|---|---|---|
| T0 | y0 | 3.1582 | 3.1582000 | 3.1582000 |
| T1 | pΔy0 | 0.4(0.1619) | +0.0647600 | 3.2229600 |
| T2 | 2p(p−1)Δ2y−1 | 20.4(−0.6)(0.0079)=−0.12(0.0079) | −0.0009480 | 3.2220120 |
| T3 | 6(p+1)p(p−1)Δ3y−1 | 6(1.4)(0.4)(−0.6)(0.0004)=−0.056(0.0004) | −0.0000224 | 3.2219896 |
| T4 | 24(p+1)p(p−1)(p−2)Δ4y−2 | 24(1.4)(0.4)(−0.6)(−1.6)(0.0000) | 0 | 3.2219896 |
| t (s) | 1 | 3 | 5 | 7 | 9 |
|---|---|---|---|---|---|
| Value | 24 | 120 | 336 | 720 | 1200 |
Step 1. Difference table. Here h=2.
| t | 1 | 3 | 5 | 7 | 9 |
|---|---|---|---|---|---|
| y | 24 | 120 | 336 | 720 | 1200 |
| Δy | 96 | 216 | 384 | 480 | |
| Δ2y | 120 | 168 | 96 | ||
| Δ3y | 48 | −72 | |||
| Δ4y | −120 |
Step 2. Observe what the data really are. The first three differences of r3 are 3r2+3r+1, 6r+6, 6. Here Δy=96,216,384,480 grows by 120,168,96, not by a constant, so this is not a pure cubic in t.
Check the natural candidate: (t+1)(t+2)(t+3) gives 24,120,336,720 for t=1,3,5,7, exactly matching, but gives 1320 at t=9, not 1200.
The fifth point does not lie on the cubic that the first four define. This single fact determines which polynomial the question requires, and it is stated explicitly rather than resolved by silently choosing one interpretation.
Step 3(a). Using all five points, cubic through the first four plus one more. The unique quartic through all five points, evaluated by Newton's forward formula with p=210−1=4.5:
| Term | Working | Value |
|---|---|---|
| y0 | 24 | |
| pΔy0 | 4.5(96) | 432 |
| 2p(p−1)Δ2y0 | 24.5(3.5)(120)=7.875(120) | 945 |
| 6p(p−1)(p−2)Δ3y0 | 64.5(3.5)(2.5)(48)=6.5625(48) | 315 |
| 24p(p−1)(p−2)(p−3)Δ4y0 | 244.5(3.5)(2.5)(1.5)(−120)=2.4609375(−120) | −295.3125 |
Step 3(b). Using the four points that lie on a clean cubic. Newton's forward with the first four rows truncated at Δ3, p=4.5:
24+432+945+315=1716and the cubic through those four points is exactly
y=t3+6t2+11t+6=(t+1)(t+2)(t+3)which gives 1716 at t=10.
Five points (quartic): y(10)=1420.6875Four points (cubic): y(10)=1716Initial value problem (IVP). A differential equation together with conditions given at a single point, for example y(0)=1. The solution can be marched forward from that point because each new value depends only on the values already computed.
Boundary value problem (BVP). A differential equation together with conditions given at both ends of the interval, for example y(0)=0 and y(1)=1. No starting value is known, so the whole interval must be solved at once.
| IVP | BVP | |
|---|---|---|
| Conditions | At one end | At both ends |
| How it is solved | March forward step by step | Solve the full algebraic system |
| Resulting system | Lower triangular | Tridiagonal for a second-order ODE |
| Cost | Very low per step | Full linear solve |
| Sensitivity | Local; errors stay near the start | Global; a change anywhere moves the whole solution |
| Shooting method | Not applicable | Reduces it to an IVP by tuning the unknown start value |
Finite difference form for a second-order BVP. Discretise the interval into n+1 points, replace y′′ by the centred difference, and use the boundary conditions to replace the two unavailable end rows:
h2yi−1−2yi+yi+1+p(xi)yi+q(xi)yi=ri ⎩⎨⎧y0=given,yi−1−(2−p(xi)h2−q(xi)h4)yi+yi+1=rih2,1≤i≤n−1yn=given IVP: conditions at one end, march forward. BVP: conditions at both ends, solve together.Step 1. Discretise. With the centred difference for y′′,
h2yi−1−2yi+yi+1−yi=0Multiplying by h2,
yi−1−(2+h2)yi+yi+1=0The system is tridiagonal with diagonal −(2+h2) and off-diagonal 1. Note that the matrix is negatively diagonally dominant, since ∣2+h2∣>1+1, hence the solution is unique and the standard Thomas algorithm applies without pivoting.
Step 2. Solve with h=0.5. Then n=4 subintervals and 3 interior nodes at x=0.5,1.0,1.5. With y0=0 and y4=3.62686:
⎩⎨⎧−(2.25)y1+y2=0y1−(2.25)y2+y3=0y2−(2.25)y3=−3.62686From the first, y2=2.25y1. Substituting into the second,
y1−2.25(2.25y1)+y3=0⇒y3=4.0625y1The third then gives 2.25y1−2.25(4.0625y1)=−3.62686, that is 2.25y1(1−4.0625)=−3.62686, so −6.890625y1=−3.62686 and y1=0.526347.
y2=2.25(0.526347)=1.184281,y3=4.0625(0.526347)=2.138285| x | y (numerical, h=0.5) | Exact | Error |
|---|---|---|---|
| 0.5 | 0.526347 | 0.521095 | +0.005252 |
| 1.0 | 1.184281 | 1.175201 | +0.009080 |
| 1.5 | 2.138285 | 2.129279 | +0.009006 |
Step 3. Refine. Halving h should cut the error by about 4, since the scheme is second order.
| h | Interior nodes | Largest error |
|---|---|---|
| 1 | 1 | 0.03375 |
| 0.5 | 3 | 0.00908 |
| 0.25 | 7 | 0.00249 |
| 0.125 | 15 | 0.00063 |
The ratio 0.00908/0.00249=3.65 is close to the expected 4, confirming second-order accuracy.
y(0.5)=0.5263,y(1.0)=1.1843,y(1.5)=2.1383(h=0.5)Step 1. Set up the rate equation. Losing 4% of the remaining charge each second means the loss is proportional to the charge present, not a constant 4 C per second. If Q is the charge and t the time,
dtdQ=−0.04Q,Q(0)=100The negative sign is essential: the charge is decreasing.
Step 2. Solve by separation of variables.
QdQ=−0.04dtIntegrating,
lnQ=−0.04t+CAt t=0, ln100=C, so
Q(t)=100e−0.04tStep 3. Evaluate at t=10 s.
Q(10)=100e−0.4=100(0.670320046)=67.0320 Q(10)=67.03 CoulombVelocity and acceleration from position data.
A vehicle's position x(t) is logged by GPS, or a vibrating mass's displacement is recorded by an accelerometer. Neither instrument measures velocity directly, yet both are needed for control. The derivative is obtained from the finite difference
v(t)=2hx(t+h)−x(t−h)Accuracy is O(h2), and halving h cuts the truncation error by 4 while multiplying the round off error by 2, so the optimal h sits where the two cross, usually near the cube root of the machine epsilon.
Second application: finding the peak of a sampled signal, such as the peak acceleration in a crash test, where the maximum of the numerical derivative locates the maximum of the original.
GPS or accelerometer data gives position; the numerical derivative gives velocity and accelerationStep 1. Reduce to a root problem. An interior maximum of a smooth f satisfies f′(x)=0, so apply Newton to the derivative. Since
f′(x)=2cosx−5x,f′′(x)=−2sinx−51Newton's iteration for f′(x)=0 is
xn+1=xn−f′′(xn)f′(xn)=xn−−2sinxn−1/52cosxn−xn/5Step 2. Iterate from x0=2.5.
At x0=2.5: f′(2.5)=2cos2.5−0.5=−1.60229−0.5=−2.10229 and f′′(2.5)=−2sin2.5−0.2=−1.19694−0.2=−1.39694.
| Iteration | xn | f′(xn) | f(xn) |
|---|---|---|---|
| 0 | 2.5000000000 | −2.1022872 | 0.5719443 |
| 1 | 0.9950815513 | +0.8898527 | 1.5785880 |
| 2 | 1.4690107528 | −0.0905823 | 1.7738494 |
| 3 | 1.4276423210 | −0.0001973 | 1.7757256 |
| 4 | 1.4275517793 | −0.0000000 | 1.7757257 |
| 5 | 1.4275517788 | 0 | 1.7757257 |
Iteration 1: x1=2.5−−1.3969443−2.1022872=2.5−1.5049184=0.9950816.
xmax=1.42755,f(xmax)=1.77573Step 3. Confirm it is a maximum, not a minimum.
f′′(1.42755)=−2sin(1.42755)−0.2=−1.979516−0.2=−2.179516, which is negative, so f is concave there and the stationary point is a maximum. This check is not optional: Newton applied to f′=0 finds a critical point of either kind.
Figure 2021 Q6(c): square domain finite-difference grid with Dirichlet boundary conditions for Poisson's equation (Source: Page 2, Q6(c))
Step 1. The grid. The domain is 0≤x≤3, 0≤y≤3 with h=k=1, Here u=0 on all four sides. Four interior nodes:
| Node | Location |
|---|---|
| u1 | (1,1) |
| u2 | (2,1) |
| u3 | (1,2) |
| u4 | (2,2) |
Step 2. The five-point formula. With h=k=1,
ui+1,j+ui−1,j+ui,j+1+ui,j−1−4ui,j=−10(xi2+yj2+10)Step 3. Write one equation per interior node. All boundary values are zero, so those terms drop out.
At u1(1,1): −10(1+1+10)=−120
u2+0+u3+0−4u1=−120⇒−4u1+u2+u3=−120At u2(2,1): −10(4+1+10)=−150
0+u1+u4+0−4u2=−150⇒u1−4u2+u4=−150At u3(1,2): −10(1+4+10)=−150
u4+0+0+u1−4u3=−150⇒u1−4u3+u4=−150At u4(2,2): −10(4+4+10)=−180
0+u3+0+u2−4u4=−180⇒u2+u3−4u4=−180Step 4. The system.
−41101−40110−41011−4u1u2u3u4=−120−150−150−180Step 5. Exploit symmetry, then solve. The domain and the source −10(x2+y2+10) are symmetric under x↔y, and (2,1) maps to (1,2), so u2=u3. Let u2=u3=w. Then
⎩⎨⎧−4u1+2w=−120u1−4w+u4=−1502w−4u4=−180From the first, u1=42w+120=2w+30. From the third, u4=42w+180=2w+45. Substituting into the second,
2w+30−4w+2w+45=−150⇒−3w+75=−150⇒w=75Then u1=37.5+30=67.5 and u4=37.5+45=82.5.
u1=67.5,u2=75,u3=75,u4=82.5Step 6. Verify. Substituting back:
−4(67.5)+75+75=−270+150=−120✓ 67.5−4(75)+82.5=150−300=−150✓ 67.5−4(75)+82.5=−150✓ 75+75−4(82.5)=150−330=−180✓Unconstrained optimization. No restrictions. Choose x freely in the whole domain to maximise or minimise f(x).
minimise f(x1,x2,…,xn),x∈RnExample: fit y=a+bx to data by least squares. Nothing forbids any a or b, hence it is unconstrained.
Constrained optimization. Extra conditions must hold. Each restriction is written as g(x)≤0 or h(x)=0.
minimise f(x)subject to gi(x)≤0, i=1…m,hj(x)=0Example: minimise the weight of a truss subject to every member carrying at most its rated load, or maximise a portfolio return subject to total risk staying under a limit.
| Unconstrained | Constrained | |
|---|---|---|
| Restrictions | None | Equality and inequality conditions |
| Stationarity test | ∇f=0 | KKT multipliers: ∇f+∑μi∇gi+∑λj∇hj=0 |
| Lagrange multipliers | Not needed | Essential |
| Optimum may be at | An interior point | A point on the boundary |
| Feasible region | Whole space | A subset |
| Harder | Easier | Harder; more constraints mean more cases |
Why the distinction matters. The unconstrained case is solved by finding where the gradient vanishes. The constrained case must also satisfy every restriction, and the optimum frequently sits on a boundary, where the plain gradient test is useless. That is exactly why Lagrange multipliers exist.
Unconstrained: choose freely. Constrained: obey rules, solved with multipliersEvery elimination step divides by the pivot, the element chosen as divisor. Pivoting reorders rows or columns so that pivot is as large in magnitude as possible.
Two reasons.
Partial pivoting, the usual choice, selects the largest ∣aik∣ in column k below the diagonal and swaps it up. It costs one comparison per candidate and no extra arithmetic.
Important limit. Pivoting improves stability, not conditioning. The condition number κ(A) is a property of the problem and cannot be changed by reordering. If κ is large, the answer is unreliable no matter how carefully the elimination is done.
Pivoting avoids a zero or tiny divisor, which is where elimination accuracy is lost
Figure 2021 Q7(b): DC circuit with independent 30 V source, four resistors, and dependent voltage source 5I0 (Source: Page 2, Q7(b))
Step 1. Name the nodes. Take the bottom rail as reference, 0 V.
| Node | Voltage |
|---|---|
| Top rail | VT=30 V, held by the ideal source |
| Centre node C | VC |
| Right node R | VR |
Step 2. Express the controlling current.
I0=10VT−VC=1030−VCStep 3. Apply the dependent source. The 5I0 source sets the right node:
VR=5I0=5(1030−VC)=15−0.5VCRearranged, that is one equation ready for iteration:
VC+2VR=30Step 4. KCL at node C. Three branches leave it, toward the top rail, toward ground, and toward node R:
10VC−30+15VC−0+8VC−VR=0Multiplying by 120,
12(VC−30)+8VC+15(VC−VR)=0 12VC−360+8VC+15VC−15VR=0 35VC−15VR=360Step 5. The system to iterate.
⎩⎨⎧VC=3515VR+360VR=230−VCStep 6. Gauss-Seidel. Use the value just computed, never the previous iteration's. Start from VC(0)=VR(0)=0.
| k | VC | VR |
|---|---|---|
| 0 | 0.000000 | 0.000000 |
| 1 | 10.285714 | 9.857143 |
| 2 | 14.510204 | 7.744898 |
| 3 | 13.604956 | 8.197522 |
| 4 | 13.798938 | 8.100531 |
| 5 | 13.757370 | 8.121315 |
| 6 | 13.766278 | 8.116861 |
| 7 | 13.764369 | 8.117815 |
| 8 | 13.764778 | 8.117611 |
Iteration 1: VC(1)=3515(0)+360=10.285714, then VR(1)=230−10.285714=9.857143.
Step 7. Read off I0.
I0=1030−13.764778=1016.235222=1.6235 A I0=1.6235 A,VC=13.7648 V,VR=8.1176 V| x | 1.0 | 1.2 | 1.4 | 1.6 | 1.8 | 2.0 | 2.2 |
|---|---|---|---|---|---|---|---|
| y | 2.7183 | 3.3201 | 4.0552 | 4.9530 | 6.0496 | 7.3891 | 9.0250 |
The nodes are equally spaced with h=0.2, and the values are ex rounded to four decimals.
First derivative, three-point central. Uses x=1.0,1.2,1.4:
dxdy1.2≈2hy1.4−y1.0=0.44.0552−2.7183=0.41.3369=3.34225First derivative, three-point forward. Uses x=1.2,1.4,1.6:
dxdy1.2≈2h−3y1.2+4y1.4−y1.6=0.4−3(3.3201)+4(4.0552)−4.9530=0.4−9.9603+16.2208−4.9530=0.41.3075=3.26875The central form is both more accurate and symmetric, and it is therefore preferred. The true value is e1.2=3.3201169, giving errors of +0.0221 and −0.0514 respectively.
Second derivative, three-point central.
dx2d2y1.2≈h2y1.4−2y1.2+y1.0=0.044.0552−2(3.3201)+2.7183=0.040.1333=3.3325Second derivative, three-point forward.
dx2d2y1.2≈h2y1.6−2y1.4+y1.2=0.044.9530−2(4.0552)+3.3201=0.040.1627=4.0675The central form is again much better: error +0.0124 against +0.7474.
dxdy1.2≈3.3423,dx2d2y1.2≈3.3325The formula is the composite trapezoidal rule. h=nxn−x0, and yi=f(xi) at xi=x0+ih.
Step 1. Start from the trapezoidal rule on one interval. On [xi,xi+1], the trapezoid of area 21h(yi+yi+1),
∫xixi+1ydx=2h(yi+yi+1)−12h3y′′(ξi)+⋯Step 2. Sum over all n intervals.
∫x0xnydx=i=0∑n−1[2h(yi+yi+1)+error]Step 3. Collect the interior terms. Every y1,y2,…,yn−1 appears in two adjacent trapezoids, once from each side, so each collects a factor of 2h×2=h. Only y0 and yn appear once, each with factor 2h. Hence
∫x0xnydx=2hy0+h(y1+y2+⋯+yn−1)+2hyn−i=0∑n−112h3y′′(ξi)Step 4. Factor out h/2. Since h=2⋅2h, the interior sum becomes 2⋅2h(y1+⋯+yn−1), giving
∫x0xnydx=2h[y0+2(y1+y2+⋯+yn−1)+yn]−12h3i=0∑n−1y′′(ξi)Step 5. The leading error term. With n intervals, h=nb−a and ∑y′′(ξi)≈h1∫y′′, so
E=−12h2[y′(xn)−y′(x0)]+O(h4)which is O(h2), the signature of a second-order method.
∫x0xnydx=2h[y0+2i=1∑n−1yi+yn]+O(h2)Step 1. The first column, composite trapezoid.
Tn=2h[f0+2f1+⋯+2fn−1+fn],fi=2+xi1At h=0.5, n=2, nodes x=1,1.5,2:
T2=20.5[31+2⋅3.51+41]=0.25[0.333333+0.571429+0.25]=0.288690At h=0.25, n=4:
T4=20.25[31+2(3.251+3.51+3.751+4.251)+41]=0.287935At h=0.125, n=8:
T8=0.287745Step 2. Second column. The trapezoid rule has O(h2) error, so extrapolate with the factor 41−1=3:
Rk,1=Rk,0+4−1Rk,0−Rk−1,0Step 3. Third column. The result above is Simpson's rule, carrying O(h4), so the factor is 42−1=15:
Rk,2=Rk,1+16−1Rk,1−Rk−1,1The table.
Rk,00.2886900.2879350.287745Rk,10.2876830.287682Rk,20.287682Row 2: 0.287935+30.287935−0.288690=0.287935−0.000252=0.287683 Row 3, column 1: 0.287745+30.287745−0.287935=0.287745−0.000063=0.287682 Row 3, column 2: R3,2=R3,1+15R3,1−R2,1
Taken literally at the six decimals the table prints, this gives 0.287682−1510−6=0.2876819. Carried unrounded, which is what the answer below uses, the same line gives 0.2876820735, since the unrounded entries are R2,1=0.2876832 and R3,1=0.2876821.
I≈0.2876821The method.
yn+1=yn+hf(xn,yn)=yn+h⋅53xn3ynStep 1. Step 1, at x0=0, y0=1: slope 53(0)3(1)=0, so y1=1+0.25(0)=1.0000000.
Step 2. Step 2, at x1=0.25, y1=1: slope 53(0.25)3(1)=53(0.015625)=0.0093750, so y2=1+0.25(0.009375)=1.0023438.
Step 3. Step 3, at x2=0.5, y2=1.0023438: slope 53(0.5)3(1.0023438)=53(0.125)(1.0023438)=0.0751758, so y3=1.0023438+0.25(0.0751758)=1.0211377.
Step 4. Step 4, at x3=0.75, y3=1.0211377: slope 53(0.75)3(1.0211377)=53(0.421875)(1.0211377)=0.2584755, so y4=1.0211377+0.25(0.2584755)=1.0857566.
| Step | xn | yn | Slope 53xn3yn | yn+1 |
|---|---|---|---|---|
| 1 | 0.00 | 1.0000000 | 0.0000000 | 1.0000000 |
| 2 | 0.25 | 1.0000000 | 0.0093750 | 1.0023438 |
| 3 | 0.50 | 1.0023438 | 0.0751758 | 1.0211377 |
| 4 | 0.75 | 1.0211377 | 0.2584755 | 1.0857566 |
Other step sizes, to show the choice is not arbitrary:
| h | Steps to x=1 | y(1) | Error against exact |
|---|---|---|---|
| 0.5 | 2 | 1.03750 | −0.12433 |
| 0.25 | 4 | 1.08576 | −0.07608 |
| 0.1 | 10 | 1.12725 | −0.03459 |