48.1 KB · commit a9602da
| title | ECE 2213 · 2024 Exam Style Answers |
|---|
RUET · ECE Dept · B.Sc. Engineering 2nd Year Even Semester Examination, 2024 Full Marks: 80 · Time: 03 Hours · CO-mapped
Engineering problems are too large to test directly. A model is a set of equations that captures the behaviour that matters and drops the rest.
Why it matters
How a problem becomes a model
Worked example. A reactor's coolant temperature must be known every second, and the thermocouple is slow. Model the exponential decay of the sensor reading: store the last reading Tn−1, then
Tn=Tn−1+(T∞−Tn−1)e−Δt/τwith τ the sensor time constant. The thermocouple is the real system, and the first-order lag is the model. For Δt≪τ this reduces to Tn−Tn−1≈(Δt/τ)(T∞−Tn−1), which is the linear formula used in a circuit.
Model=physics written as equations, with stated limits
The Taylor series of f about x0=0 is
f(x)=n=0∑∞n!f(n)(0)xnFor f(x)=ex every derivative is ex, so f(n)(0)=1 for all n. Hence
ex=1+x+2!x2+3!x3+4!x4+⋯Third order truncation, keeping terms up to x3:
ex≈P3(x)=1+x+2x2+6x3At x=0.5
P3(0.5)=1+0.5+20.25+60.125=1+0.5+0.125+0.0208333=1.6458333Truncation error, route 1, exact difference against the true value
e0.5=1.6487212707 ∣E3∣=∣e0.5−P3(0.5)∣=1.6487212707−1.6458333333=0.0028879374Truncation error, route 2, Lagrange remainder bound
The remainder after three terms is
R3(x)=4!f(4)(ξ)x4=24eξx4,0<ξ<xSubstituting x=0.5 and eξ≤e0.5=1.6487213 gives
∣R3∣≤241.6487213(0.5)4=241.6487213(0.0625)=0.0042935The two routes are consistent: the exact error 0.0028879 sits inside the bound 0.0042935. The first neglected term alone indicates the size of the error, since the series terms fall fast at x=0.5:
4!x4=240.0625=0.0026042 P3(0.5)=1.6458333,∣E3∣=0.0028879≤0.0042935Both errors make the computed answer differ from the true answer. They come from different places and cannot be removed the same way.
Round off error. The true value cannot be stored exactly in the machine's finite number of digits. Every number is chopped or rounded to the nearest representable value. It enters at every single arithmetic operation and it accumulates, roughly like a random walk.
Truncation error. The exact mathematics is replaced by a finite formula. The formula itself is wrong, and no amount of extra digits will fix it.
Comparison
| Round off | Truncation | |
|---|---|---|
| Source | Finite number of digits | Dropping terms of an exact formula |
| Controlled by | More digits, better algorithm order | Smaller step size, more terms |
| Effect of shrinking h | No help, often worse | Decreases |
| Sign | Random, no pattern | Fixed by which terms were dropped |
| Cure | Higher precision, rearranged sums | Refine the formula |
Choose the interval. Take [2.5,3.4], which brackets x=3 without landing on it, so each iteration narrows the bracket.
f(2.5)=15.625−37.5+27.5−6=−0.375,f(3.4)=39.304−69.36+37.4−6=+1.344f(2.5)⋅f(3.4)<0, so a root lies in (2.5,3.4).
Iteration 1. Midpoint x1=(2.5+3.4)/2=2.95
f(2.95)=25.6724−52.2150+32.45−6=−0.092625f(2.95)<0, same sign as f(2.5), so the root is in (2.95,3.4).
Iteration 2. Midpoint x2=(2.95+3.4)/2=3.175
f(3.175)=32.005984−60.483750+34.925−6=+0.447234f(3.175)>0, so the root is in (2.95,3.175).
x2=3.175,root∈(2.95, 3.175),true root=3Interval after n iterations. Each iteration halves the width, so
widthn=2nb0−a0The initial width is b0−a0=3.4−2.5=0.9. After two iterations the bracket is (2.95,3.175), of width 0.225, which matches (b0−a0)/22=0.9/4=0.225.
The standard maximum error bound for the midpoint after n iterations is ∣xn−r∣≤2nb0−a0. For n=2:
∣x2−r∣≤220.9=0.225Since the true root is r=3, the actual error is ∣3.175−3∣=0.175, which strictly satisfies the theoretical bound:
guaranteed: root∈(2.95,3.175),∣3.175−3∣=0.175≤0.225
Figure Q2(b): Three-mesh DC resistive circuit with independent voltage and current sources (Source: Page 1, Q.2(b))
Mesh equations. Take all three mesh currents clockwise.
Rearrange for iteration
I1=30500+20I2,I2=12020I1+100I3,I3=5Gauss-Seidel rule. The value just computed for I1 is used in the equation for I2, and the value just computed for I2 in the equation for I1. The previous iteration's values are not used. The start is I1(0)=I2(0)=I3(0)=0.
I3=5 is not iterated. It is fixed by the current source, so it is 5 in every row including row 0, and it is the value used from the first sweep onward.
| Iteration | I1 | I2 | I3 |
|---|---|---|---|
| 0 | 0 | 0 | 5.000000 |
| 1 | 16.666667 | 6.944444 | 5.000000 |
| 2 | 21.296296 | 7.716049 | 5.000000 |
| 3 | 21.810700 | 7.801783 | 5.000000 |
| 4 | 21.867856 | 7.811309 | 5.000000 |
| 5 | 21.874206 | 7.812368 | 5.000000 |
| 6 | 21.874912 | 7.812485 | 5.000000 |
Iteration 1 shown in full:
I1(1)=30500+20(0)=350=16.666667 I2(1)=12020(16.666667)+100(5)=120333.33334+500=18125=6.944444The increments shrink by roughly a factor of 4 each pass, so the sequence has settled by iteration 6.
I1≈21.875 A,I2≈7.8125 A,I3=5 AIdea. With n+1 points (x0,y0),…,(xn,yn) there is exactly one polynomial of degree at most n passing through all of them. Lagrange writes that polynomial directly, as a sum where each term is arranged to be correct at one point and zero at all the others.
The formula
Pn(x)=i=0∑nyiLi(x),Li(x)=j=0j=i∏nxi−xjx−xjWhy Li behaves as it must. At x=xk every factor with k=i has a numerator of xk−xk=0, so Li(xk)=0. At x=xi every ratio is (xi−xj)/(xi−xj)=1, so Li(xi)=1. Each term therefore contributes yi at its own point and nothing at the others.
Advantages
Disadvantages
Both take discrete data and produce a smooth relation, but they answer different questions.
Interpolation. Find a function that passes through every given point exactly. The result reproduces the data by construction.
P(xi)=yifor all iInterpolation applies when the data are accurate and values are needed between them. Example: reading a voltage between two calibration points.
Extrapolation. The same formula evaluated outside the range of the data. The result is an unconstrained estimate with no accuracy guarantee. Example: predicting next year's population from five decades of census figures.
Curve fitting. Find the function that comes closest to all the points without passing through any of them, by minimising a chosen measure of misfit, usually
i=1∑n[yi−f(xi)]2which is least squares. Use it when the data carry noise, or when a simpler form than degree n is wanted. Example: fitting a straight line through seven noisy measurements.
| Interpolation | Curve fitting | |
|---|---|---|
| Passes through the data | Yes | No |
| Data assumed | Exact | Noisy |
| Degree | Up to n for n+1 points | Chosen, often lower |
| Answers | What is between the points | What is the underlying trend |
| Year | 1921 | 1931 | 1941 | 1951 | 1961 |
|---|---|---|---|---|---|
| Population (thousands) | 46 | 66 | 81 | 93 | 101 |
Step 1. Build the difference table. Take h=10 years and put the years in steps from 1921, so u=(x−1921)/10 gives u=0,1,2,3,4.
| u | 0 | 1 | 2 | 3 | 4 |
|---|---|---|---|---|---|
| y | 46 | 66 | 81 | 93 | 101 |
| Δy | 20 | 15 | 12 | 8 | |
| Δ2y | −5 | −3 | −4 | ||
| Δ3y | 2 | −1 | |||
| Δ4y | −3 |
Step 2. Newton backward differences at the last point. The target 1995 lies beyond the table, so work backwards from 1961. The backward differences at u=4 are the last entry of each row:
∇y=8,∇2y=−4,∇3y=−1,∇4y=−3Step 3. Argument. With p measured in steps of h past the last point,
p=101995−1961=3.4Step 4. Apply the formula
y=yn+p∇yn+2!p(p+1)∇2yn+3!p(p+1)(p+2)∇3yn+4!p(p+1)(p+2)(p+3)∇4yn| Term | Working | Value |
|---|---|---|
| yn | 101 | |
| p∇yn | 3.4(8) | 27.2 |
| 2p(p+1)∇2yn | 23.4(4.4)(−4) | −29.92 |
| 6p(p+1)(p+2)∇3yn | 63.4(4.4)(5.4)(−1) | −13.464 |
| 24p(p+1)(p+2)(p+3)∇4yn | 243.4(4.4)(5.4)(6.4)(−3) | −64.6272 |
| x | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|---|---|---|---|---|---|---|---|
| y | 0.5 | 2.5 | 2 | 4 | 3.5 | 6 | 5.5 |
The model is y=a+bx. Choose a,b to minimise S=∑(yi−a−bxi)2.
Step 1. Sums. With n=7:
| ∑x | ∑y | ∑x2 | ∑xy |
|---|---|---|---|
| 28 | 24 | 140 | 119.5 |
Step 2. Normal equations. Differentiating S with respect to a and b and setting both to zero gives
na+b∑x=∑y,a∑x+b∑x2=∑xy {7a+28b=2428a+140b=119.5Step 3. Solve. Eliminating a by multiplying the first equation by 4 and subtracting it from the second:
28a+140b−(28a+112b)=119.5−96 28b=23.5⇒b=2823.5=5647=0.839286 a=724−28b=724−23.5=70.5=141=0.071429 y=0.0714+0.8393xCheck. Both normal equations are satisfied exactly: 7(0.071429)+28(0.839286)=0.5+23.5=24 and 28(0.071429)+140(0.839286)=2+117.5=119.5.
The shared starting point. Both replace derivatives by finite differences and solve the resulting algebraic system. The difference is which equations end up in that system.
Initial value problem. One condition is given at one end of the domain, for example y(0)=1. Marching step by step from there, each new row uses only the row just computed.
yi+1=f(xi,yi)h+O(h2)This works because the system is lower triangular in the unknowns. It is simple, needs no iteration, and each step is cheap.
Boundary value problem. Conditions are given at both ends, for example y(0)=0 and y(1)=1. No starting value is known, so the grid cannot be filled row by row.
The general approach.
The interior equations couple neighbours, so the system is tridiagonal. The standard efficient methods are the Thomas algorithm, or an iterative sweep such as Gauss-Seidel, which works because the system is diagonally dominant.
Key differences
| Initial value problem | Boundary value problem | |
|---|---|---|
| Conditions | Given at one end | Given at both ends |
| Direction | Marches forward from the start | Whole domain solved at once |
| System structure | Lower triangular | Tridiagonal |
| Cost per step | Very low | Full linear solve |
| Sensitivity | Local, errors stay near the start | Global, a change anywhere moves the whole solution |
| Shooting method | Not applicable | Reduces a BVP to an IVP by adjusting the unknown start value until the far end matches |
The method. With f(x,y)=x+y and h=0.1:
k1=hf(xi,yi) k2=hf(xi+2h, yi+2k1) k3=hf(xi+2h, yi+2k2) k4=hf(xi+h, yi+k3) yi+1=yi+61(k1+2k2+2k3+k4)Each k is a slope over a different point of the interval, and y3 and y4 are staged estimates that get corrected by later stages. This is why RK4 needs four function evaluations where Euler needs one.
Step 1. From x0=0 to x1=0.1, with x0=0, y0=1:
k1=0.1(0+1)=0.1 k2=0.1(0.05+1+20.1)=0.1(1.1)=0.11 k3=0.1(0.05+1+20.11)=0.1(1.105)=0.1105 k4=0.1(0.1+1+0.1105)=0.1(1.2105)=0.12105 y1=1+61(0.1+2(0.11)+2(0.1105)+0.12105)=1+60.66205=1.1103417Step 2. From x1=0.1 to x2=0.2, with x1=0.1, y1=1.1103417:
k1=0.1(0.1+1.1103417)=0.1210342 k2=0.1(0.15+1.1103417+20.1210342)=0.1(1.3208588)=0.1320859 k3=0.1(0.15+1.1103417+20.1320859)=0.1(1.3263846)=0.1326385 k4=0.1(0.2+1.1103417+0.1326385)=0.1(1.4429802)=0.1442980 y2=1.1103417+61(0.1210342+2(0.1320859)+2(0.1326385)+0.1442980) =1.1103417+60.7947810=1.1103417+0.1324635=1.2428051 y(0.2)=1.2428051Why they decide the answer. A partial differential equation gives the behaviour inside a region. Boundary conditions say what happens at the edges. Together with the PDE they form a complete problem; without them the problem is under-determined and the numerical solution is not unique.
What breaks without them.
Their role in practice.
PDE+boundary conditions=a problem with one unique numerical solution
Propositional logic is the study of statements that are either true or false, together with the connectives that build larger statements from them. It ignores the internal structure of a statement and cares only about its truth value.
Proposition. A declarative sentence that is unambiguously either true or false, and has exactly one truth value.
| Example | Proposition? | |
|---|---|---|
| a | The transistor conducts | Yes, true or false |
| b | 2+2=4 | Yes |
| c | Close the window | No, it is a command |
| d | x+1>0 | No, x is unknown |
| e | The sky is blue today | Yes |
| f | Is the door open | No, it is a question |
Propositional variable, written p,q,r,s, is a single letter standing for one whole proposition. The letter has no meaning of its own. It is simply a placeholder.
The difference in one line. A proposition is the actual sentence. A propositional variable is the name given to it so that logical connectives can be written on paper.
Statement: "The system is in multiuser state"⇒pBoth are needed. The prose gives the physics, the letter gives the algebra.
The three words are tested separately.
Step 1. Expand the implications.
(p→q)∧(q→r)=(¬p∨q)∧(¬q∨r)Step 2. Full truth table.
| p | q | r | p→q | q→r | (p→q)∧(q→r) |
|---|---|---|---|---|---|
| F | F | F | T | T | T |
| F | F | T | T | T | T |
| F | T | F | T | F | F |
| F | T | T | T | T | T |
| T | F | F | F | T | F |
| T | F | T | F | T | F |
| T | T | F | T | F | F |
| T | T | T | T | T | T |
Step 3. The verdict. The column holds T in four rows and F in four rows.
The system is in multiuser state if and only if it is operating normally, the kernel is functioning. The kernel is not functioning or the system is in interrupt mode. If the system is not in multiuser state, then it is in interrupt mode. The system is not in interrupt mode.
Assign variables
| Symbol | Meaning |
|---|---|
| p | system is in multiuser state |
| q | kernel is functioning |
| r | system is in interrupt mode |
Translate each sentence.
Test all eight assignments.
| p | q | r | (1) p↔q | (2) ¬q∨r | (3) p∨r | (4) ¬r | all four |
|---|---|---|---|---|---|---|---|
| F | F | F | T | T | F | T | F |
| F | F | T | T | T | T | F | F |
| F | T | F | F | F | F | T | F |
| F | T | T | F | T | T | F | F |
| T | F | F | F | T | T | T | F |
| T | F | T | F | T | T | F | F |
| T | T | F | T | F | T | T | F |
| T | T | T | T | T | T | F | F |
No row satisfies all four.
Reason without a table. Specification 4 forces r=F. Specification 2 then forces ¬q, so q=F. Specification 1 forces p=F. Specification 3 then reads p∨r=F∨F=F, a contradiction.
The specifications are INCONSISTENT: no assignment satisfies all fourEvery propositional formula falls into exactly one of three classes, decided by its truth value across all assignments.
1. Tautology. True for every assignment of its variables. It is also called a valid formula. It states a fact that cannot fail.
2. Contradiction. False for every assignment. It is also called an unsatisfiable formula, or an inconsistent set of conditions.
3. Contingency. True for some assignments and false for others. It is also called a satisfiable formula, or a non-tautology.
Comparison
| Tautology | Contradiction | Contingency | |
|---|---|---|---|
| True for | All assignments | None | Some |
| False for | None | All assignments | Some |
| Negation | Contradiction | Tautology | Contingency |
| Truth table last column | All T | All F | Mixed |
Worked example, classifying A→(B∨¬A)
| A | B | ¬A | B∨¬A | A→(B∨¬A) |
|---|---|---|---|---|
| F | F | T | T | T |
| F | T | T | T | T |
| T | F | F | F | F |
| T | T | F | T | T |
The last column holds T, T, F, T, so the formula is a contingency.
tautology (always T), contradiction (always F), contingency (mixed)(i) Variables
| Symbol | Meaning |
|---|---|
| m | motion is detected |
| w | window is open |
| d | door sensor is active |
| s | security code is entered |
| A | the alarm triggers |
(ii) The condition as one proposition. Branch (a) is m∧w. Branch (b) is d∧¬s, because "the code is not entered" is ¬s. The two branches are alternatives, so they are joined by ∨:
A=(m∧w)∨(d∧¬s)(iii-a) To DNF. By definition, a proposition is in Disjunctive Normal Form (DNF) if it is a disjunction of conjunctions of literals. The formulated condition:
A=(m∧w)∨(d∧¬s)is already in DNF (minimal DNF), consisting of two clauses: (m∧w) and (d∧¬s).
If the full canonical DNF (sum of minterms where every clause contains all 4 variables) is required, expand each term using the identity X≡X∧(Y∨¬Y):
m∧w≡(m∧w)∧(d∨¬d)∧(s∨¬s)=(m∧w∧d∧s)∨(m∧w∧d∧¬s)∨(m∧w∧¬d∧s)∨(m∧w∧¬d∧¬s) d∧¬s≡(m∨¬m)∧(w∨¬w)∧(d∧¬s)=(m∧w∧d∧¬s)∨(m∧¬w∧d∧¬s)∨(¬m∧w∧d∧¬s)∨(¬m∧¬w∧d∧¬s)Combining by disjunction and eliminating the duplicate minterm (m∧w∧d∧¬s):
Acanonical DNF=(m∧w∧d∧s)∨(m∧w∧d∧¬s)∨(m∧w∧¬d∧s)∨(m∧w∧¬d∧¬s)∨(m∧¬w∧d∧¬s)∨(¬m∧w∧d∧¬s)∨(¬m∧¬w∧d∧¬s)(iii-b) To CNF. A conjunction of disjunctions (product of sums). Apply the distributive law P∨(Q∧R)≡(P∨Q)∧(P∨R):
A=(m∧w)∨(d∧¬s)=[(m∧w)∨d]∧[(m∧w)∨¬s]=[(m∨d)∧(w∨d)]∧[(m∨¬s)∧(w∨¬s)]=(m∨d)∧(w∨d)∧(m∨¬s)∧(w∨¬s)=(m∨d)∧(m∨¬s)∧(w∨d)∧(w∨¬s)distribute over (d∧¬s)distribute d and ¬sremove grouping bracketsreorder clauses CNF: (m∨d)∧(m∨¬s)∧(w∨d)∧(w∨¬s)(i) Sorting the addresses by distance
Algorithm chosen: merge sort.
The addresses are sorted by one key, the distance from the warehouse. Merge sort splits the list in half, sorts each half recursively, then merges the two sorted halves in linear time.
Merge sort is chosen over quicksort because the worst case is guaranteed, and because the merges are stable, so two addresses at the same distance keep their original order.
(ii) Searching for a customer's order
Algorithm chosen: binary search, since the question says the address list is already sorted.
Pseudocode
function BINARY-SEARCH(A, key):
low ← 0
high ← length(A) - 1
while low ≤ high:
mid ← floor((low + high) / 2)
if A[mid].id = key:
return mid
else if A[mid].id < key:
low ← mid + 1
else:
high ← mid - 1
return NOT-FOUND
Binary search halves the search interval at every step, so n items take at most ⌈log2n⌉ comparisons. For n=106 that is 20 comparisons.
(iii) Assigning vans to the nearest unserved address
Greedy algorithm: nearest-first assignment.
At each step take the unassigned van that is closest to the warehouse and give it the unassigned address that is closest to that van. This is the locally optimal choice repeated.
function ASSIGN-VANS(vans, addresses):
for each address in addresses, in ascending order of distance:
best ← NONE
for each free van v:
if best = NONE or DISTANCE(v, address) < DISTANCE(best, address):
best ← v
assign address to best
mark best as used
return schedule
Why greedy is defensible here. Every delivery costs distance and there is no interaction between vans, so the total distance is a sum of independent terms and minimising each term separately minimises the total. That is the case where greedy is exactly right.
Where greedy would fail. If a van had a capacity of 3 and one address needed a truck, taking the nearest address for the van could block a heavier address that only the truck can serve. Then the locally nearest choice is not safe, and a matching algorithm is needed instead.
Sort O(nlogn),search O(logn),assign O(nlogn+nm)The biconditional P↔Q is true when P and q have the same truth value, that is when both are true or both are false. It is false when they disagree.
P↔Q≡(P→Q)∧(Q→P)
(i) 2+2=4 if and only if 1+1=2
2+2=4 is true. 1+1=2 is true. Same value, so the biconditional holds.
(i) TRUE
(ii) 1+1=2 if and only if 2+3=4
1+1=2 is true. 2+3=5, not 4, so 2+3=4 is false. The values disagree.
(ii) FALSE
(iii) 1+1=3 if and only if monkeys can fly
1+1=3 is false. Monkeys cannot fly, so that is false. Both false, so they match.
(iii) TRUE
(iv) 0>1 if and only if 2>1
0>1 is false. 2>1 is true. The values disagree.
(iv) FALSE
Since a and b are known only modulo 19, compute the expression modulo 19 and then reduce to 0≤c≤18. Congruence arithmetic lets the actual integers be replaced by their residues.
(i) c≡7a+3b(mod19)
c≡7(11)+3(3)=77+9=86(mod19)Divide: 86=19(4)+10.
c=10(ii) c≡a3+4b3(mod19)
Work entirely with residues to keep the numbers small.
a2≡112=121=19(6)+7≡7(mod19) a3≡7×11=77=19(4)+1≡1(mod19) b3≡33=27=19(1)+8≡8(mod19) c≡1+4(8)=1+32=33=19(1)+14(mod19) c=14The well-known algorithm is repeated squaring, also called square-and-multiply. It replaces 644 multiplications by about log2644≈10.
Step 1. Split the exponent in binary.
644=512+128+4=(1010000100)2Step 2. Build the table of squares, reducing modulo 645 at every step.
31=3 32=9 34=92=81 38=812=6561=645(10)+111≡111 316=1112=12321=645(19)+66≡66 332=662=4356=645(6)+486≡486 364=4862=236196=645(366)+126≡126 3128=1262=15876=645(24)+396≡396 3256=3962=156816=645(243)+81≡81 3512=812=6561≡111Step 3. Multiply the powers named by the set bits, which are 29=512, 27=128 and 22=4:
3644≡3512⋅3128⋅34 =111×396×81 111×396=43956=645(68)+96≡96 96×81=7776=645(12)+36≡36 3644mod645=36The principle. If N objects are placed into k boxes and N>k, then at least one box holds at least two objects. More generally, if N>mk, then some box holds at least m+1.
Real-world example. A company runs a help desk. Across 365 days the recorded weather is one of 20 conditions: clear, rain, snow, fog and so on. In any year with more than 20×4=80 days of observations, at least one condition was recorded on at least 5 days.
A second example. Among any group of 50 students, since there are 12 months in a year, the generalized pigeonhole principle guarantees that at least ⌈50/12⌉=⌈4.17⌉=5 students share a birth month. Similarly, since there are 7 days in a week, at least ⌈50/7⌉=⌈7.14⌉=8 students were born on the same day of the week.
More objects than box capacity forces at least one crowded box