48.4 KB · commit a9602da
| title | ECE 2213 · 2019 Exam Style Answers |
|---|
RUET · ECE Dept · B.Sc. Engineering 2nd Year Even Semester Examination, 2019 Full Marks: 96 · Time: 03 Hours
A numerical method is a procedure that obtains the answer of a mathematical problem as a finite sequence of arithmetic operations, yielding an approximate value in place of the exact closed form.
Why it became popular
Why ECE engineers require them
Numerical method=a finite arithmetic procedure for a problem without a usable closed form
The errors are inherent error, absolute error, and relative error.
Inherent error. The error already present in the physical statement, before any computation. It subdivides into:
Inherent error is not produced by the arithmetic and cannot be reduced by carrying more digits.
Absolute error. The difference between the approximate value A and the true value T:
Eabs=A−T,∣Eabs∣=∣A−T∣
Relative error. The absolute error measured against the true value:
Erel=TEabs,Epct=100TEabs
How they enter the process. The steps of any computation are:
Example. Take R=220 Ω and V=10 V, so I=10/220=0.0454545 A. Reading the current as 0.045 A on a three-digit display gives
Eabs=0.045−0.0454545=−0.0004545 A
Erel=0.0454545−0.0004545=−0.01=−1%
The −1% has two sources: the display rounding the reading to three decimals, and the tolerance of the resistor. The first is round-off in the reporting, the second is data error in the input.
The representations. Given a true value T and an approximate value A, with e=A−T:
Arrangement 1: A=999 V, T=1000 V.
e=999−1000=−1 V,∣e∣=1 V
Erel=1000−1=−10−3=−0.1%
Erel, reading=999−1=−1.001×10−3=−0.1001%
Accuracy=1000999=0.999=99.9%
Arrangement 2: A=9999 V, T=10000 V.
e=9999−10000=−1 V,∣e∣=1 V
Erel=10000−1=−10−4=−0.01%
Erel, reading=9999−1=−1.0001×10−4=−0.010001%
Accuracy=100009999=0.9999=99.99%
Comment on the error strength. The absolute error is identical in the two arrangements, 1 V, so the absolute error separates them not at all. Against the true value, the 9999 V reading has a relative error of 0.01% while the 999 V reading has 0.1%, a factor of ten difference. The 9999 V reading is therefore the stronger one.
∣e∣=1 V for both, but Erel=10−3 against 10−4
An iterative method solves f(x)=0 by producing a sequence x0,x1,x2,… from a starting estimate x0, each term obtained from the preceding ones by a fixed rule, so that the sequence converges to the root x=r. The answer is accepted when successive terms agree to the required precision, rather than when a formula closes.
Methods for a nonlinear equation
Generalized steps
Write the equation in the form f(I)=0:
f(I)=5I2+50I−1000=0,f′(I)=10I+50
Closed-form check on the answer. Completing the square, or dividing by 5,
I2+10I−200=0⟹I=2−10±100+800=2−10±30
the two roots are I=10 and I=−20. The current is positive, so I=10 is the root of interest. This fixes the target against which the iterations below are judged.
Iteration by Newton–Raphson. The formula is
Ik+1=Ik−10Ik+505Ik2+50Ik−1000
Take I0=5, and note f(5)=125+250−1000=−625<0 while f(20)=2000+1000−1000>0, so the root lies above I0 and the iteration moves the right way.
| k | Ik | f(Ik) | f′(Ik) | Ik+1 |
|---|---|---|---|---|
| 0 | 5 | −625 | 100 | 11.25 |
| 1 | 11.25 | 195.3125 | 162.5 | 10.0480769 |
| 2 | 10.0480769 | 7.2231 | 150.4808 | 10.0000768 |
| 3 | 10.0000768 | 0.0115 | 150.0008 | 10.0000000 |
The iterates settle on I=10. The last correction is 0.0000768, already below 10−4, so the value is accepted.
I=10 A
Newton–Raphson for f(x)=0.
Geometrically, xk+1 is the intercept on the x-axis of the tangent to y=f(x) at xk, so the root is approached along successive tangents.
Merits
Demerits
Gauss elimination solves Ax=b by transforming the coefficient matrix into upper triangular form using elementary row operations, then recovering the unknowns by back substitution. The solution set is unchanged, since every operation is reversible.
The system. For n equations in n unknowns,
a11x1+a12x2+⋯+a1nxn=b1
⋮
an1x1+an2x2+⋯+annxn=bn
Steps
u11x1+u12x2+⋯+u1nxn=b1′
u22x2+⋯+u2nxn=b2′
⋱⋮
unnxn=bn′
Operation count. Forward elimination needs roughly 3n3 multiplications and divisions; back substitution needs 2n2. Total cost grows as n3, so the method is practical for moderate n and for a single right-hand side.
Use in ECE. Nodal analysis of a network with more than two nodes produces a set of simultaneous equations larger than is comfortable by hand. Gauss elimination converts it to a triangular set whose values are read off successively, which is the standard automated form of that solution.
Partial pivoting. At step k of the elimination, search column k of the rows k through n for the entry of largest absolute value, and exchange it with the entry in position (k,k) before forming the multipliers. The multiplier is then
mik=akkaik,∣mik∣≤1
hence no multiplier exceeds one in magnitude, and the rounding introduced by the multiplier is controlled. Partial pivoting searches one column only, and is sufficient for the great majority of systems.
Complete pivoting. At step k, search the whole remaining sub-matrix, rows k through n and columns k through n, for the entry of largest absolute value, and bring it to position (k,k) by a row exchange and a column exchange. Column exchanges reorder the unknowns, so the order in which the solution vector is written must be restored afterwards. The extra search raises the cost by a factor of about n2 per step, which is why complete pivoting is reserved for systems that are nearly singular or where numerical stability is critical.
Comparison.
| Partial pivoting | Complete pivoting | |
|---|---|---|
| Search region | column k, rows k to n | sub-matrix, rows and columns k to n |
| Row exchange | yes | yes |
| Column exchange | no | yes, unknown order changes |
| Stability | adequate for most systems | best available |
| Cost | low | higher by a factor of about n2 |
When it matters. If the pivot akk is small relative to the entries below it, the multiplier mik is large, and the row Ri−mikRk carries a value dominated by rounding. Choosing the largest available pivot keeps the magnitude of what is subtracted under control, and prevents a small physical quantity from being lost against a large one.
Circuit. Two non-reference nodes, V1 and V2, with a common reference ground. Node 1 connects to ground through 2 Ω and to node 2 through 4 Ω, with a 5 A source entering node 1 through the top branch. Node 2 connects to ground through 6 Ω and to node 1 through 4 Ω, with a 5 A source leaving toward node 1 and a 10 A source entering node 2.

KCL at node 1. Currents leaving: through 2 Ω to ground, through 4 Ω to node 2, and 5 A back through the top branch.
2V1+4V1−V2−5=0
Multiplying by 4:
2V1+V1−V2−20=0⟹3V1−V2=20
KCL at node 2. Currents leaving: through 6 Ω to ground, through 4 Ω to node 1, and 5 A through the top branch. The 10 A source enters, so it stands on the other side.
6V2+4V2−V1+5=10
Multiplying by 12:
2V2+3(V2−V1)+60=120⟹−3V1+5V2=60
Gauss-Seidel form. Solve each equation for the diagonal unknown, and use the most recent value of the other as soon as it is available.
V1(k+1)=320+V2(k),V2(k+1)=560+3V1(k+1)
The coefficient matrix is diagonally dominant, since ∣3∣>∣−1∣ in the first row and ∣5∣>∣−3∣ in the second, so the iteration converges. Start from V1(0)=V2(0)=0.
| Iteration | V1(k+1)=320+V2(k) | V2(k+1)=560+3V1(k+1) |
|---|---|---|
| 1 | 320+0=6.666667 | 560+3(6.666667)=16.000000 |
| 2 | 320+16=12.000000 | 560+3(12)=19.200000 |
Two iterations only, as required.
V1(1)=6.666667 V,V2(1)=16.000000 V V1(2)=12.000000 V,V2(2)=19.200000 V
The exact solution, for reference. Adding the two equations eliminates V1:
4V2=80⟹V2=20 V,3V1=40⟹V1=13.333333 V
V1=13.3333 V,V2=20 V
Curve fitting is the construction of an equation y=f(x) that represents the trend of a set of data points (xi,yi). Where interpolation forces the curve through every point, curve fitting accepts that the points carry error and seeks a single relation that describes the whole set.
Why it is required for ECE engineers
Least squares. Let the trial curve be y=a0+a1x+⋯+amgm(x). The residual at point i is ri=yi−f(xi). The coefficients are chosen to minimise the sum of squared residuals,
S=i=1∑nri2=i=1∑n(yi−f(xi))2
The conditions are obtained by setting each partial derivative to zero:
∂a0∂S=0,∂a1∂S=0,…
which gives the normal equations. For the straight line y=a+bx:
∑y=na+b∑x,∑xy=a∑x+b∑x2
and in general the squares are needed because the minimum, not the root, is sought: setting the derivatives to zero locates the stationary point of S, and the second derivatives are positive there, so it is a minimum.
The least-squares condition, stated fully. Of all curves in the chosen family, the least squares curve is the one for which the residuals satisfy
which follows directly from the two normal equations. The three conditions are the algebraic signature of the fit: the line passes through the centroid (xˉ,yˉ), and the residuals are uncorrelated with the fitted values.
The three tabulated points through which the quadratic path passes are
(x0,y0)=(2,7.2),(x1,y1)=(4.25,7.1),(x2,y2)=(5.25,6.0)
Three points determine one quadratic, so the curve-fitting technique is exact interpolation by a second-degree Lagrange polynomial.
Lagrange basis. With x=4.00:
L0=(x0−x1)(x0−x2)(x−x1)(x−x2)=(2−4.25)(2−5.25)(4−4.25)(4−5.25)=(−2.25)(−3.25)(−0.25)(−1.25)
L0=7.31250.3125=0.04273504
L1=(x1−x0)(x1−x2)(x−x0)(x−x2)=(4.25−2)(4.25−5.25)(4−2)(4−5.25)=(2.25)(−1)(2)(−1.25)
L1=−2.25−2.5=1.11111111
L2=(x2−x0)(x2−x1)(x−x0)(x−x1)=(5.25−2)(5.25−4.25)(4−2)(4−4.25)=(3.25)(1)(2)(−0.25)
L2=3.25−0.5=−0.15384615
Evaluate the polynomial.
y(4)=y0L0+y1L1+y2L2=7.2(0.04273504)+7.1(1.11111111)+6.0(−0.15384615)
y(4)=0.30769231+7.88888889−0.92307692=7.27350427
y(4.00)=7.2735 in.
Let the data be (xi,yi), i=1,…,n, and let the fitted line be
y^=a+bx
The residual at point i is ri=yi−a−bxi. Minimise the sum of squared residuals:
S(a,b)=i=1∑n(yi−a−bxi)2
At a minimum, both partial derivatives vanish:
∂a∂S=−2i=1∑n(yi−a−bxi)=0⟹∑yi=na+b∑xi
∂b∂S=−2i=1∑nxi(yi−a−bxi)=0⟹∑xiyi=a∑xi+b∑xi2
These are the normal equations. Solving the 2×2 system:
na+b∑xi=∑yi
a∑xi+b∑xi2=∑xiyi
Eliminating a from the first, a=yˉ−bxˉ, and substituting into the second:
∑xiyi=(yˉ−bxˉ)∑xi+b∑xi2
Dividing through and collecting terms in b:
b=n∑xi2−(∑xi)2n∑xiyi−∑xi∑yi,a=yˉ−bxˉ
y=(yˉ−bxˉ)+bxwithb=n∑x2−(∑x)2n∑xy−∑x∑y
Interpolation is the estimation of an intermediate value of a function from a set of known values, at a point within the range covered by the known data. Extrapolation is the estimation of a value at a point outside that range. Interpolation is bounded by the data; extrapolation extends beyond it.
The two are distinguished by the position of the target relative to the tabulated interval. For a table covering [x0,xn], a target x with x0<x<xn is interpolated; a target with x>xn or x<x0 is extrapolated. Extrapolation carries the further risk that the fitted relation may not hold outside the range where it was fitted at all.
Two general techniques of curve fitting
Other techniques include the geometric mean, moving average and orthogonal polynomial fits; the two above are the general ones.
| V (volt) | 5 | 10 | 15 | 20 | 25 |
|---|---|---|---|---|---|
| I (amps) | 1 | 2.1 | 3 | 4.2 | 5 |
The target V=12 lies between V0=10 and V1=15, so the bracketing data are (10,2.1) and (15,3).
Linear interpolation. The chord through the two points is
I(V)=I0+V1−V0V−V0(I1−I0)
I(12)=2.1+15−1012−10(3−2.1)=2.1+52(0.9)=2.1+0.36
I(12 V)=2.46 A
Why this differs from the true value. The actual value follows Ohm's law, V=IR, with the resistance from the data. The 5 V and 15 V and 25 V readings give R=V/I=5 Ω exactly, whereas the 10 V and 20 V readings give R≈4.76 Ω. The true current at 12 V is therefore
Itrue=512=2.4 A
against the interpolated 2.46 A, a difference of 0.06 A.
The cause is the data, not the method. Linear interpolation follows the chord joining the two bracketing points, and that chord is not the Ohm's-law line: the 10 V reading carries a measurement error of +0.1 A against the 2.0 A the law predicts, so the chord from (10,2.1) to (15,3) has slope 0.9/5=0.18 A/V instead of the true 0.2 A/V. The interpolated value inherits that slope over the whole interval from 10 to 15 V. The effect would be less at a point nearer an accurate reading, and it would vanish if both bracketing readings were error-free.
| x | −1 | 0 | 3 | 6 | 7 |
|---|---|---|---|---|---|
| f(x) | 3 | −6 | 39 | 822 | 1611 |
Divided differences. Each entry is f[xi,…,xi+k]=xi+k−xif[xi+1,…,xi+k]−f[xi,…,xi+k−1].
| Order | Values |
|---|---|
| 0 | 3, −6, 39, 822, 1611 |
| 1 | 0−(−1)−6−3=−9; 3−039−(−6)=15; 6−3822−39=261; 7−61611−822=789 |
| 2 | 3−(−1)15−(−9)=6; 6−0261−15=41; 7−3789−261=132 |
| 3 | 6−(−1)41−6=5; 7−0132−41=13 |
| 4 | 7−(−1)13−5=1 |
Newton's general (divided difference) form.
f(x)=f[x0]+f[x0,x1](x−x0)+f[x0,x1,x2](x−x0)(x−x1)+⋯
f(x)=3−9(x+1)+6(x+1)x+5(x+1)x(x−3)+(x+1)x(x−3)(x−6)
Expand to a polynomial in x. Working outward from the last term:
(x+1)x(x−3)(x−6)=x4−8x3+9x2+18x
5(x+1)x(x−3)=5(x3−2x2−3x)=5x3−10x2−15x
6(x+1)x=6x2+6x,−9(x+1)=−9x−9
Collecting all terms:
f(x)=x4−3x3+5x2−6
f(x)=x4−3x3+5x2−6
Apply it to f(3.5). Substituting into the expanded form:
f(3.5)=150.0625−128.625+61.25−6=76.6875
f(3.5)=76.6875
The basis. A function known only at discrete points is replaced by a polynomial that passes through those points, and the derivative of that polynomial is used for the derivative of the function. Starting from the Taylor series
f(x+h)=f(x)+hf′(x)+2h2f′′(x)+6h3f′′′(x)+⋯
combinations of the series at neighbouring points cancel the terms that are not wanted. Since the first omitted term is proportional to a power of h, the result is an approximation with an error O(h) or O(h2).
Four difference equations. With h the tabular spacing and fn=f(xn):
Forward difference (two-point). f′(xn)=hfn+1−fn,error O(h)
Backward difference (two-point). f′(xn)=hfn−fn−1,error O(h)
Central difference (three-point). f′(xn)=2hfn+1−fn−1,error O(h2)
Forward difference (three-point). f′(xn)=2h−3fn+4fn+1−fn+2,error O(h2)
Central difference (five-point). f′(xn)=12hfn−2−8fn−1+8fn+1−fn+2,error O(h4)
The central formulas are preferred where data exist on both sides, since their error is O(h2) and above rather than O(h), and their error constants are smaller by the same factor.
| t (sec) | 0.25 | 0.26 | 0.27 | 0.28 | 0.29 |
|---|---|---|---|---|---|
| I (amp) | 0.2474 | 0.2571 | 0.2667 | 0.2764 | 0.2860 |
The tabular spacing is h=0.01. The target t=0.27 has two points on each side, so the five-point central formula is available and is the most accurate.
Five-point central difference.
f′(xn)=12hfn−2−8fn−1+8fn+1−fn+2
With fn−2=0.2474, fn−1=0.2571, fn+1=0.2764, fn+2=0.2860:
dtdIt=0.27=12(0.01)0.2474−8(0.2571)+8(0.2764)−0.2860
dtdI=0.120.2474−2.0568+2.2112−0.2860=0.120.1158=0.965
Voltage across the inductor. For L=1 H, v=LdtdI:
v=1×0.965=0.965 V
v(0.27)=0.965 V
The trapezoidal rule approximates ∫abf(x)dx by replacing the curve with a straight line joining the endpoints of each subinterval, so the area under the curve becomes the area of a set of trapezoids.
Derivation. Over one interval [x0,x0+h], the straight line through (x0,f0) and (x1,f1) has slope hf1−f0, and its integral is
∫x0x1f(x)dx≈2h(f0+f1)
Composite rule. Over [a,b] with n subintervals of width h=nb−a, summing the one-interval result gives
∫abf(x)dx≈2h[f0+2f1+2f2+⋯+2fn−1+fn]
∫abf(x)dx≈2h[f(a)+f(b)+2i=1∑n−1fi]
Error. The error over one interval is −12h3f′′(ξ), so the composite error is
E=−12(b−a)h2f′′(ξ),O(h2)
Properties.
Derivation. Take three equally spaced nodes
x0,x1=x0+h,x2=x0+2h
and replace f by the quadratic P2(x) through the three values f0,f1,f2. The integral of P2 is the approximation.
With x=x0+ph, so dx=hdp, the Lagrange basis is
L0=2(p−1)(p−2),L1=−p(p−2),L2=2p(p−1)
and
∫x0x2P2dx=h∫02[f02(p−1)(p−2)−f1p(p−2)+f22p(p−1)]dp
Integrating each basis function separately:
∫022(p−1)(p−2)dp=21∫02(p2−3p+2)dp=21[38−6+4]=21⋅32=31
∫02−p(p−2)dp=−∫02(p2−2p)dp=−[38−4]=34
∫022p(p−1)dp=21∫02(p2−p)dp=21[38−2]=21⋅32=31
Hence
∫x0x2f(x)dx≈3h(f0+4f1+f2)
which is Simpson's one-third rule. Over [a,b] with n even and h=nb−a, the composite form is
∫abf(x)dx≈3h[f0+4f1+2f2+4f3+⋯+2fn−2+4fn−1+fn]
Exactness to degree three. By construction the rule is exact for every quadratic, since P2=f. For a cubic, apply the rule to f(x)=x3 on [−h,h], which by symmetry is equivalent to any interval:
∫−hhx3dx=[4x4]−hh=0
3h[(−h)3+4(0)3+(h)3]=3h(−h3+h3)=0
The two agree. The cause is symmetry: for a cubic antisymmetric about the midpoint, both the true integral and the weighted sum vanish identically, and each weighted sum reproduces the exact area because the weights 1,4,1 were themselves derived from exact integration of the quadratic basis. Hence the rule is exact for 1,x,x2,x3.
Failure at degree four. For f(x)=x4 on [−h,h]:
∫−hhx4dx=52h5,3h(h4+0+h4)=32h5
and 32=52, so the rule is not exact for quartics.
∫x0x2fdx≈3h(f0+4f1+f2) exact for all polynomials of degree ≤3
Simpson's 3/8 rule applies over three subintervals, using four nodes. Over [1,2], take n=3, so
h=32−1=31,x=1, 34, 35, 2
The ordinates:
f(1)=1+1=2
f(34)=916+1=925≈2.777778
f(35)=925+1=934≈3.777778
f(2)=4+1=5
∫12(x2+1)dx≈83h[f0+3f1+3f2+f3]
=83⋅31[2+3(925)+3(934)+5]
=81[2+325+334+5]=81[7+359]=81⋅380=310
∫12(x2+1)dx=310=3.3333
Purpose. Given y′=f(x,y) and y(x0)=y0, the value of y is wanted at x0+nh for a step size h.
Derivation. Taylor expand about xn:
yn+1=yn+hyn′+2h2yn′′+⋯
Euler's method keeps the first two terms and discards the rest:
yn+1=yn+hf(xn,yn)
Geometrically, yn+1 is the value at xn+h of the tangent to the solution curve at (xn,yn), so the solution is followed along successive short tangent segments.
Procedure. Set xn+1=xn+h. Starting from (x0,y0), compute y1=y0+hf(x0,y0), then y2=y1+hf(x1,y1), and continue.
Error. The local truncation error is O(h2) per step, from the discarded 2h2y′′ term; over n steps these accumulate into a global error O(h). Halving h therefore halves the global error, which is the defining property of a first-order method.
Merits and demerits.
yn+1=yn+hf(xn,yn),global error O(h)
Step 1. x0=0, y0=0.
f(x0,y0)=x02+y02=0+0=0
y1=y0+hf(x0,y0)=0+0.2(0)=0
Hence x1=0.2 and y1=0.
Step 2. x1=0.2, y1=0.
f(x1,y1)=(0.2)2+02=0.04
y2=y1+hf(x1,y1)=0+0.2(0.04)=0.008
Hence x2=0.4 and y2=0.008.
| Step | xn | yn | f(xn,yn)=xn2+yn2 | yn+1=yn+0.2f |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 1 | 0.2 | 0 | 0.04 | 0.008 |
y(0.4)≈0.008
The mesh. A uniform 3×3 mesh over the square, with four interior nodes u1,u2,u3,u4 and the boundary values shown.

The standard Laplace finite-difference stencil. For a square mesh with uniform spacing h, ∇2u=0 gives
h2ui+1,j−2ui,j+ui−1,j+h2ui,j+1−2ui,j+ui,j−1=0
and cancelling h2:
ui,j=41(ui+1,j+ui−1,j+ui,j+1+ui,j−1)
The four nodal equations. Reading the neighbours of each interior node from the figure, and taking the boundary values in the order left, right, top, bottom:
u1=41(u2+u3+4+2)
4u1−u2−u3=6
u2=41(u1+u4+5+5)
4u2−u1−u4=10
u3=41(u1+u4+1+1)
4u3−u1−u4=2
u4=41(u3+u2+2+4)
4u4−u3−u2=6
Solve the 4×4 system.
4u1−u2−u3=6 −u1+4u2−u4=10 −u1+4u3−u4=2 −u3−u2+4u4=6
Writing this as a matrix,
4−1−10−140−1−104−10−1−14u1u2u3u4=61026
Step 1. One relation from subtracting. Equation 3 minus equation 2 cancels both u1 and u4:
4u3−4u2=−8⟹u3=u2−2
Step 2. One relation from adding. Adding all four, every column sums to 2:
2(u1+u2+u3+u4)=24⟹u1+u2+u3+u4=12
Step 3. Substitute u3=u2−2 into that sum:
u1+2u2+u4=14,u4=14−u1−2u2
Step 4. Use equation 2. Substituting that u4 into −u1+4u2−u4=10:
−u1+4u2−14+u1+2u2=10⟹6u2=24⟹u2=4
Here u3=2 and u4=6−u1. Equation 1 then gives 4u1−4−2=6, hence u1=3 and u4=3.
Every value is an integer, which is not a coincidence: the boundary data are integers and the mesh is small, so the solution is a small rational that happens to be integral.
u1=3,u2=4,u3=2,u4=3