76.5 KB · commit a9602da
| title | ECE 2213 · 2024 Explanations |
|---|
RUET · ECE Dept · B.Sc. Engineering 2nd Year Even Semester Examination, 2024
This file explains the same questions as the 2024 answer script, written to be read rather than copied. Every step is named, the reason a formula is chosen is stated, and the traps that catch people are called out.
[Marks: 03, CO: 1]
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. That last clause is the whole idea, and it is worth being precise about: a model is not a copy of reality, it is a deliberate simplification of it. Choosing what to leave out is the engineering judgement, and the choice is what a modelling question is really testing.
Why it matters. Four reasons, in the order they tend to be asked:
How a problem becomes a model. The five steps are the standard ones, and they are worth learning as a sequence because the question can be asked in the form "describe the modelling process":
The worked example. The answer script uses a thermocouple on a reactor coolant loop. The thermocouple is slow, and the model is a first-order lag:
Tn=Tn−1+(T∞−Tn−1)e−Δt/τ
with τ the sensor time constant. The reason this model is chosen is that first-order lag is the standard description of any sensor whose response is limited by a single energy or charge storage. For Δt≪τ the exponential reduces to a linear update, which is the form that can actually be implemented in a loop running every second.
Model=physics written as equations, with stated limits
[Marks: 03, CO: 1]
The setup. The Taylor series of f about x0 is
f(x)=n=0∑∞n!f(n)(x0)(x−x0)n
For f(x)=ex about x0=0, every derivative is ex, and evaluated at zero every derivative is 1. This is why ex is the standard worked example: the derivative never changes, so the series is simply
ex=1+x+2!x2+3!x3+4!x4+⋯
Third order means keeping terms up to n=3.
ex≈P3(x)=1+x+2x2+6x3
At x=0.5:
P3(0.5)=1+0.5+20.25+60.125=1+0.5+0.125+0.0208333=1.6458333
The truncation error. Taylor's theorem gives the exact remainder
Rn=(n+1)!f(n+1)(ξ)(x−x0)n+1
for some ξ between x0 and x. Here n=3, so
R3=4!eξ(0.5)4=24eξ(0.0625)=eξ×0.0026042
To bound this, take the largest eξ can be on the interval, which is at ξ=0.5:
∣R3∣≤24e0.5(0.5)4=241.6487213(0.0625)=0.0042935
P3(0.5)=1.6458333,∣E3∣=0.0028879≤0.0042935
Why the bound and the actual differ. The bound 0.0042935 uses eξ at its worst, ξ=0.5. The actual error is
∣e0.5−P3(0.5)∣=1.6487213−1.6458333=0.0028879
which is about two thirds of the bound. The first neglected term alone is
4!(0.5)4=240.0625=0.0026042
which is already 90% of the actual error. This is the useful practical fact about alternating-free Taylor series: the first neglected term tells you the size of the error. For ex with positive x the terms are all positive, so the first neglected term is a lower bound on the error rather than an estimate of it, and the ratio of consecutive terms tells you how many more terms you would need.
[Marks: 04, CO: 2]
Round-off error is the error caused by the finite precision of the machine. A computer holding t significant digits cannot represent most numbers exactly, so every arithmetic operation rounds its result to the t digits available. That rounding, introduced at one step, propagates into every later step.
It arises in three distinct ways, and naming the type is usually what the marks are for:
Truncation error is the error caused by replacing an infinite process by a finite one. It is not a property of the machine at all: it would be present even with infinite precision, because it comes from the method.
It arises in three ways too:
The opposition between them. This is the part of the answer that distinguishes a good response from a listing. The two errors behave differently as a method is refined:
So the total error has a minimum at some optimal refinement level, below which making the method finer makes the answer worse. This is why the answer to "how accurately can this integral be computed" is not always "use more panels".
Why it matters in practice. The stability of the method, not the precision of the machine, decides whether round-off is amplified or damped. A method is well-conditioned if an error introduced early is damped in later steps, and unstable if it is amplified. The same machine precision can give six correct digits on one method and none on another.
Total error=truncation+round off+data error
Note the three terms, not two. Data error is the error already present in the inputs, and it is not reduced by choosing a better method. A method can drive truncation and round off down indefinitely; data error only comes down by measuring more carefully. The three do not always add, since a truncation error and a round-off error can partly cancel, so the practical statement is a bound rather than an equality. The box writes the standard decomposition, which is what an exam expects.
[Marks: 03, CO: 2]
The setup. The question gives no interval, so the first task is to find one. Bisection needs f to change sign across the interval, so scan for a sign change before iterating.
f(x)=x3−6x2+11x−6
| x | f(x) |
|---|---|
| 2.5 | −0.375 |
| 3.4 | +1.344 |
The three roots are exactly 1,2,3. This is worth checking at the outset, because it is the fastest possible verification of everything that follows:
x3−6x2+11x−6=(x−1)(x−2)(x−3)
Any bisection result must converge to one of these three values. A result that converges elsewhere is wrong, and this is the check to apply before accepting any number of iterations.
Choosing 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.504<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, the 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).
| Iteration | a | b | midpoint | f(midpoint) | retained |
|---|---|---|---|---|---|
| 1 | 2.5 | 3.4 | 2.95 | −0.092625 | (2.95,3.4) |
| 2 | 2.95 | 3.4 | 3.175 | +0.447234 | (2.95,3.175) |
x2=3.175,root∈(2.95, 3.175),true root=3
The interval halves each time, so after n iterations its width is 2nb−a, and the answer is known to lie inside it. This is the feature that makes bisection valuable despite being slow: the error is bounded at every step, whether or not the iteration has converged.
Why bisection is chosen here. The marks are for the method, not for the algebra, so the polynomial's factoring is the check rather than the answer. The question is asking for the bracketing procedure, and the demonstration of it requires a valid bracket, which requires finding a sign change.
Convergence rate. Bisection is first order: halving the interval halves the error, so gaining one decimal place costs about 3.3 iterations. Compare Newton–Raphson at second order, where the number of correct digits roughly doubles per step. The trade is reliability for speed.
[Marks: 04, CO: 1]
Figure Q2(b): Three-mesh DC resistive circuit with independent voltage and current sources (Source: Page 1, Q2(b))
Gauss-Seidel solves a linear system by solving each equation for its own unknown and immediately using every new value as soon as it is computed. The word "immediately" is the whole method, and it is the difference from Jacobi.
Jacobi versus Gauss-Seidel. In Jacobi, the whole right-hand side is computed from the previous sweep's values, and only then is the new sweep adopted. In Gauss-Seidel, the k-th unknown is computed using I1 through Ik−1 from the current sweep and Ik+1 through In from the previous one. Because the new values are always at least as good as the old ones, Gauss-Seidel converges in fewer sweeps than Jacobi on the same system, typically by a factor of about two.
The convergence condition. Gauss-Seidel is guaranteed to converge when the coefficient matrix is strictly diagonally dominant, meaning
∣aii∣>j=i∑∣aij∣
for every row. If the matrix is not diagonally dominant, convergence is possible but not guaranteed, and checking this before iterating is the first step of the answer. Where the matrix is not dominant in the given order, rearranging the equations may make it so, and that rearrangement should be stated.
Why the method is used on circuits. Mesh and nodal analysis of a network with more than two unknowns gives a linear system whose coefficients are the conductances. Those systems are sparse and usually diagonally dominant, both of which suit Gauss-Seidel. The method also has a practical advantage: if a parameter changes, you restart from the previous solution rather than from zero, and the iteration converges in a few sweeps.
The general iteration. Writing the system as ∑jaijIj=bi and solving equation i for Ii:
Ii(k+1)=aii1(bi−j<i∑aijIj(k+1)−j>i∑aijIj(k))
The circuit. Three meshes, all clockwise: a 500 V source in mesh 1, a 5 A current source bounding mesh 3, and resistors 10, 20 and 100 Ω.
The mesh equations.
Rearrange each equation for its own unknown.
I1=30500+20I2,I2=12020I1+100I3,I3=5The sweeps. Start from I1(0)=I2(0)=0, with I3=5 throughout.
| 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 |
Sweep 1 in full:
I1(1)=30500+20(0)=350=16.666667 I2(1)=12020(16.666667)+100(5)=120333.33334+500=18125=6.944444I1≈21.875 A,I2≈7.8125 A,I3=5 A
The convergence test, applied here. Row 1 has ∣30∣ against 20, so it is dominant. Row 2 has ∣120∣ against 20+100=120, which is equal, not strictly greater. So the matrix is not strictly diagonally dominant, and strict dominance is not available as the justification. The iteration converges anyway, because the off-diagonal coupling is weak in one direction and the two equations pull towards the solution rather than away from it. Stating the near-equality is more accurate than claiming dominance, and it costs nothing.
[Marks: 03, CO: 1]
The method. Given n+1 points (xi,yi), the unique polynomial of degree at most n through them is
Pn(x)=i=0∑nyij=i∏xi−xjx−xj
Each yi is multiplied by a basis polynomial Li(x) that equals 1 at x=xi and 0 at every other tabulated xj. That construction is what guarantees the interpolant passes through every point: at x=xk, every term except the k-th vanishes.
The error. With n+1 points,
f(x)−Pn(x)=(n+1)!f(n+1)(ξ)i=0∏n(x−xi)
for some ξ in the interval. The product is zero at every node, so the error is zero there, and it grows between nodes. This is why interpolation error is not uniformly distributed across the interval.
Advantages.
Disadvantages.
When to use it. Lagrangian interpolation is the right choice when the data are exact, unevenly spaced, and evaluated at few points. For many points, or when a model of the trend is wanted, use fitting instead.
[Marks: 02, CO: 1]
Both estimate the value of a function from data, and the difference is whether the estimated curve is required to pass through the known points.
Interpolation constructs a curve through every tabulated point exactly. The interpolant reproduces the data. It is the right tool when the data are known to be accurate and the noise is negligible, such as values taken from a table of a known function or a calibrated instrument.
Curve fitting constructs a curve that captures the trend without passing through the points. The fitted curve does not reproduce the data; it summarises them. It is the right tool when the data carry measurement error, because forcing the curve through noisy points reproduces the noise as well as the signal.
How the difference shows up. With five points, interpolating gives a quartic that passes through all five, including any scatter among them. Fitting a line to the same five points gives a line that misses all five but shows the direction. Neither is wrong; they answer different questions.
The test for which to use. Ask what the data are: exact tabulated values, or measurements? Ask what is wanted: the value at an intermediate point, or the model of the trend? Exact data and an intermediate value gives interpolation. Measured data and a model gives fitting.
Interpolation reproduces data; curve fitting explains it
The general methods.
| Method | Curve through points | Best for |
|---|---|---|
| Lagrange interpolation | yes | exact, unevenly spaced data |
| Newton divided differences | yes | exact, equally spaced, points added later |
| Least squares fitting | no | noisy data, a trend model |
| Piecewise (spline) interpolation | yes, locally | many points, avoiding oscillation |
[Marks: 04, CO: 1]
The setup. A census table is equally spaced with h=10, so the difference methods apply. But note where the target sits: the table ends at 1961 and the question asks for 1995, which is outside the data. That single fact decides the whole method.
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 |
The first differences fall steadily, which means the increments are getting smaller and the population is decelerating.
Step 2. Choose backward, not forward. Because 1995 lies beyond the table, work from the last point, 1961, and use backward differences. Those are the last entry of each row:
∇y=8,∇2y=−4,∇3y=−1,∇4y=−3Step 3. The 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 |
Is this sensible? A sanity check matters more here than usual, because the answer is small when a large number would have been the giveaway. The increments were 20,15,12,8, the last of them only 8 thousand per decade. Extrapolating 3.4 decades past 1961 on a degree 4 polynomial that has been decelerating for two decades gives a decrease to 20.19 thousand. That is the polynomial's answer and it is arithmetically correct, but it is not a plausible prediction: a linear reading of the last increment alone gives 101+3.4(8)=128.2.
Route 2, as a check. Newton forward from 1921 with p=7.4 gives 20.1888000000, matching to nine figures. Lagrange on the five points gives 20.1887999999. Both agree with the backward-difference value because all three evaluate the same unique degree 4 polynomial, so this confirms the arithmetic but not the modelling. Confirming that a computation is right and confirming that it answers the question are two different things.
[Marks: 04, CO: 1]
The method. Least squares picks the line y=a+bx that minimises the sum of squared vertical residuals. Differentiating with respect to a and to b and setting both to zero gives the two normal equations:
na+b∑x=∑y
a∑x+b∑x2=∑xy
These are two linear equations in the two unknowns a and b, so they always have a unique solution (provided the x values are not all identical).
Sums over the data.
∑x=28,∑y=24,∑xy=119.5,∑x2=140,n=7
The ∑xy term is the one to compute carefully, because it is the only one that is not a simple sum of a column. Its seven products are 0.5,5,6,16,17.5,36 and 38.5, which add to 119.5.
Solve.
7a+28b=24
28a+140b=119.5
Multiplying the first by 4 gives 28a+112b=96, and subtracting from the second:
28b=23.5⟹b=2823.5=5647=0.839286
Substituting back into the first:
7a=24−28(0.839286)=24−23.5=0.5⟹a=70.5=141=0.071429
y=0.0714+0.8393x
The centroid check. The fitted line must pass through the point (xˉ,yˉ). Here xˉ=4 and yˉ=24/7=3.4286, and
0.0714+0.839286(4)=0.0714+3.3571=3.4286
which matches. This check costs nothing and catches a transposition between the two normal equations immediately, because a swapped pair of equations gives a line that misses yˉ.
The residuals.
| x | y | 0.0714+0.8393x | e=y−y^ |
|---|---|---|---|
| 1 | 0.5 | 0.9107 | −0.4107 |
| 2 | 2.5 | 1.7500 | +0.7500 |
| 3 | 2.0 | 2.5893 | −0.5893 |
| 4 | 4.0 | 3.4286 | +0.5714 |
| 5 | 3.5 | 4.2679 | −0.7679 |
| 6 | 6.0 | 5.1071 | +0.8929 |
| 7 | 5.5 | 5.9464 | −0.4464 |
The residuals sum to zero, as the normal equations guarantee, and the sum of squared residuals is 2.9911.
The quality of the fit. The correlation coefficient is r=0.9318, so r2=0.8683, meaning about 87% of the variation in y is accounted for by the line. That is a good fit but not a strong one, and the residual table shows why: the residuals alternate in sign and grow from both ends toward the middle, which is the signature of a straight line fitted to data with genuine curvature rather than of an arithmetic slip.
[Marks: 03, CO: 1]
What a boundary value problem is. A boundary value problem (BVP) gives conditions at more than one point of the domain. The standard statement is a differential equation on [a,b] plus values of y at a and at b:
y′′=f(x,y,y′),y(a)=ya,y(b)=yb
An initial value problem (IVP) gives both conditions at the same point, usually the left end, and asks for the solution at later points.
The general numerical approach. Three steps, and they are the same for every BVP method:
Discretise the domain. Replace [a,b] by a finite set of nodes x0,x1,…,xn with spacing h. The solution is now sought at the nodes only, rather than at every point.
Replace derivatives by finite differences. Each derivative in the equation is replaced by an approximation involving nodal values. For y′′ the standard choice is the central difference
yi′′≈h2yi+1−2yi+yi−1
After this step the differential equation has become a linear (or nonlinear) algebraic equation at each interior node.
Assemble and solve. Collecting the nodal equations gives one algebraic system with n−1 unknowns for n−1 interior nodes. The boundary values supply the terms that are already known. Solve the system, by elimination or, for a large mesh, by an iterative method such as Gauss-Seidel.
Why the discretisation is sound. The central difference for y′′ is second-order accurate, meaning the error is O(h2). Taylor expanding y(x±h) and subtracting gives
h2yi+1−2yi+yi−1=yi′′+12h2yi(4)+⋯
so the approximation becomes exact as h→0, and the method converges.
How it differs from an initial value problem. The difference is not cosmetic; it changes the whole structure of the computation.
| Initial value problem | Boundary value problem | |
|---|---|---|
| Where conditions are given | all at x=a | at both x=a and x=b |
| Shape of the computation | marching, one node at a time | simultaneous, all nodes together |
| Does the solution grow or decay | matters greatly, errors accumulate | irrelevant, solved as a system |
| Method family | Euler, RK4, predictor-corrector | shooting, finite differences, relaxation |
| Can one value be found alone | yes, by marching to it | no, the whole mesh is coupled |
The one-line version: an IVP can be solved by marching, a BVP cannot. A BVP must be solved as a simultaneous system, which is why the numerical linear algebra of the earlier sections suddenly becomes relevant.
Shooting, as the alternative. The shooting method converts the BVP into a sequence of IVPs: guess the missing initial slope, march forward, compare the result at x=b against the required value, and correct the guess. It is the method of choice when the IVP machinery is already reliable and the interval is long, and it fails when the underlying IVP is unstable, which is common.
[Marks: 05, CO: 1]
Why RK4 rather than Euler. Euler's method is O(h) globally: halving h halves the error, so six digits costs about a million steps. RK4 is O(h4) globally: halving h reduces the error by a factor of sixteen. RK4 buys its accuracy with four evaluations of f per step, and for a smooth right-hand side that trade is overwhelmingly worth it.
The method. Given y′=f(x,y), y(x0)=y0 and step h:
k1=f(xn,yn)
k2=f(xn+2h,yn+2hk1)
k3=f(xn+2h,yn+2hk2)
k4=f(xn+h,yn+hk3)
yn+1=yn+6h(k1+2k2+2k3+k4)
The four k values are slopes evaluated at the start, two trial midpoints, and a trial end. The weighted average weights the midpoints double, which is what makes the fourth-order term cancel.
Applying it. With f(x,y)=x+y, y(0)=1 and h=0.1:
k1=0+1=1
k2=0.05+(1+20.1⋅1)=0.05+1.05=1.1
k3=0.05+(1+20.1⋅1.1)=0.05+1.055=1.105
k4=0.1+(1+0.1⋅1.105)=0.1+1.1105=1.2105
y(0.1)=1+60.1(1+2(1.1)+2(1.105)+1.2105)=1+60.1(6.6205)=1.1103417
Step 2. From x1=0.1, y1=1.1103417:
k1=0.1+1.1103417=1.2103417
k2=0.15+(1.1103417+20.1⋅1.2103417)=0.15+1.1708587=1.3208587
k3=0.15+(1.1103417+20.1⋅1.3208587)=0.15+1.1763846=1.3263846
k4=0.2+(1.1103417+0.1⋅1.3263846)=0.2+1.2429801=1.4429801
y(0.2)=1.1103417+60.1(1.2103417+2(1.3208587)+2(1.3263846)+1.4429801)
=1.1103417+60.1(7.9478085)=1.1103417+0.1324635=1.2428051
y(0.2)=1.2428051
Checking the answer. The equation is linear, so it has a closed-form solution:
y′−y=x⟹(ye−x)′=xe−x⟹y=Cex−x−1
With y(0)=1, C=2, so y(x)=2ex−x−1, and
y(0.2)=2(1.2214028)−0.2−1=2.4428056−1.2=1.2428056
The RK4 value 1.2428051 differs from the exact 1.2428056 by 3.7×10−7, which over two steps is the expected O(h4) accuracy.
[Marks: 02, CO: 1]
A partial differential equation on its own has infinitely many solutions. The boundary conditions are what select one, and this is why they are not an optional addition to the problem but part of its statement.
What they do, concretely. For a problem discretised on a mesh, the boundary conditions do three jobs:
The two kinds, and why they behave differently.
| Kind | What is given | Behaviour |
|---|---|---|
| Dirichlet | the value of u itself on the boundary | the boundary nodes are eliminated, the system shrinks |
| Neumann | the normal derivative ∂u/∂n | a ghost row or one-sided difference is needed, the system grows |
For a Neumann condition the derivative is unknown in terms of nodal values, so one-sided differences are used, and this is where extra discretisation error enters. Getting the boundary condition kind right is therefore as important as getting the interior discretisation right.
Why this matters practically. Most of the numerical difficulty in a PDE problem is at the boundary, not in the interior. The interior stencil is uniform and its error is a clean O(h2). The boundary treatment is where the order can drop, where the system can become ill-conditioned, and where the physics of the problem is actually encoded. A mesh refinement study that improves slowly is almost always showing boundary error, not interior error.
PDE+boundary conditions=a problem with one unique numerical solution
The PDE on its own has a whole family of solutions. The boundary conditions are what select one of them, and they do it by fixing both the solution and the size of the algebraic system that the discretisation produces, since only the interior nodes become unknowns.
[Marks: 02, CO: 2]
Propositional logic is the branch of logic that deals with propositions, which are declarative statements that are either true or false, and with the connectives that combine them. Unlike first-order logic it does not look inside a proposition: it treats each one as a single indivisible unit and studies how the truth values of whole propositions combine.
A proposition is a declarative sentence that has a definite truth value. "Swift is a functional language" is a proposition. So is "The bridge opened." The two essential requirements are that the sentence is declarative rather than interrogative or imperative, and that it is unambiguously either true or false. "Jaffna is a city in the world" is true. "Cairo is the capital of Egypt" is true. "Are you hungry?" is not a proposition at all, because it is a question and has no truth value.
A propositional variable is a symbol, usually p,q,r, that stands for a proposition. The variable does not have a truth value by itself: it takes the truth value of the proposition it represents. The propositional variable p in the formula p→q is a placeholder; the propositions are the statements behind p and behind q.
The difference in one sentence. A proposition is a statement with a truth value; a propositional variable is a name for one, whose own truth value depends on which proposition it names.
| Proposition | Propositional variable | |
|---|---|---|
| What it is | A declarative sentence with a definite truth value | A single letter standing for a proposition |
| Truth value | Has one of its own | Borrows the one it stands for |
| Example | "Cairo is the capital of Egypt" | p, standing for that statement |
| Not one | "Close the switch", an imperative with no truth value |
Proposition=declarative statement with a definite truth value; variable=its symbol
Why the distinction matters. It is the reason a truth table can be finite. A single proposition has two possible truth values, so n propositional variables need 2n rows to enumerate, which is a finite and complete account. If propositions were allowed to be compound in arbitrary ways, no finite table would suffice.
[Marks: 04, CO: 2]
The three definitions, because the question needs them.
These are not mutually exclusive categories in the order they were asked. Every valid formula is also satisfiable, because it is true in every row including at least one. The standard classification of a formula asks whether it is a tautology, a contradiction, or neither, and then reports satisfiability separately.
Building the truth table. Three variables means 23=8 rows.
| p | q | r | p→q | q→r | (p→q)∧(q→r) |
|---|---|---|---|---|---|
| T | T | T | T | T | T |
| T | T | F | T | F | F |
| T | F | T | F | T | F |
| T | F | F | F | T | F |
| F | T | T | T | T | T |
| F | T | F | T | F | F |
| F | F | T | T | T | T |
| F | F | F | T | T | T |
Reading the table. The formula is true in rows 1, 5, 7 and 8, and false in rows 2, 3, 4 and 6.
Satisfiable but not valid
The formula is not valid, because there are rows where it is false. It is satisfiable, because there are rows where it is true. It is not unsatisfiable, for the same reason.
The reasoning behind the result, stated in English. p→q says that p being true requires q to be true. q→r says q requires r. Together they say the chain p then q then r is consistent, which is exactly the hypothetical syllogism. The formula fails precisely when p and q are both true but r is false: then p→q holds and q→r fails. That row is the counterexample to validity, and it is the one to name in an answer.
[Marks: 04, CO: 2]
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.
What consistency means. A set of specifications is consistent when at least one assignment of truth values makes all of them true at the same time. The object being tested is the conjunction of the four, not each one on its own. Four individually plausible sentences can easily be jointly impossible.
Assign variables. One symbol per simple statement:
| Symbol | Meaning |
|---|---|
| p | system is in multiuser state |
| q | kernel is functioning |
| r | system is in interrupt mode |
Translate. The four sentences become
| # | English | Logic |
|---|---|---|
| 1 | multiuser if and only if the kernel is functioning | p↔q |
| 2 | kernel not functioning, or interrupt mode | ¬q∨r |
| 3 | if not multiuser, then interrupt mode | ¬p→r, equivalent to p∨r |
| 4 | not in interrupt mode | ¬r |
Two of these translations need care. Sentence 3 is a conditional whose consequent is r, so ¬p→r is equivalent to p∨r by the definition of implication, and writing it as p∨r makes the truth table easier to read. Sentence 2 is a disjunction, so it is true whenever the kernel is broken or interrupt mode holds; the mistake is to read it as a conjunction.
Test all eight assignments. Three variables, so 23=8 rows.
| 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 | F | T | F |
| T | T | T | T | T | T | F | F |
No row satisfies all four, so the set is inconsistent.
Reason without a table. This is faster and worth writing alongside, since it shows where the conflict is. Sentence 4 forces r=F. Sentence 2, ¬q∨r, then has both terms false unless q is false, so q=F. Sentence 1 ties p to q, so p=F. Sentence 3 then reads p∨r=F∨F=F, contradicting the requirement that all four hold.
The specifications are INCONSISTENT: no assignment satisfies all four
[Marks: 04, CO: 2]
The three classifications. Given a formula, its class is decided by how many rows of its truth table are true.
| Class | True in | Example |
|---|---|---|
| Tautology | every row | p∨¬p |
| Contradiction | no row | p∧¬p |
| Contingency | some rows, not all | p∧q |
The test is therefore mechanical: build the table, count the T's. A formula with no variables is a tautology or a contradiction outright. A formula with n variables is tested over 2n rows.
Where each class shows up. Tautologies are the valid arguments of logic, and they are what a proof system is designed to derive. Contradictions are what makes a proof by contradiction work: if assuming ¬φ yields a contradiction, then φ must be true. Contingencies are what describes anything whose truth depends on facts, which is to say almost every sentence actually used in a specification.
The five connectives.
| Connective | Symbol | Reads as | Truth condition |
|---|---|---|---|
| Negation | ¬p | "not p" | true iff p is false |
| Conjunction | p∧q | "p and q" | true iff both are true |
| Disjunction | p∨q | "p or q" | true iff at least one is true |
| Implication | p→q | "if p then q" | false only when p true and q false |
| Biconditional | p↔q | "p if and only if q" | true iff the two agree |
Why the connectives matter. They are the vocabulary in which every compound proposition is written, and each one identifies a particular kind of valid inference:
Functional completeness. A set of connectives is functionally complete if every truth function can be built from it. {¬,∧,∨} is complete, as is {¬,∧}, as is {∣} (NAND) alone. The reason NAND alone suffices is
¬p≡p∣p,p∧q≡(p∣q)∣(p∣q)
and every other connective follows from those two. This is why a whole computer processor can be built out of one gate type, and why the connectives are a practical engineering matter rather than only a logical one.
tautology (always T), contradiction (always F), contingency (mixed)
[Marks: 06, CO: 2]
Assign variables. Every variable is defined positively, so the negation falls where the English puts it rather than where the reader expects it.
| Symbol | Meaning |
|---|---|
| m | motion is detected |
| w | window is open |
| d | door sensor is active |
| s | security code is entered |
| A | the alarm triggers |
The condition as one proposition. Branch (a) is m∧w. Branch (b) is d∧¬s, because "the code is not entered" is ¬s and not a new variable. The two branches are alternatives, so they are joined by ∨:
A=(m∧w)∨(d∧¬s)
To DNF. By definition, a compound 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 containing all 4 variables) is required, we expand each clause 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 and removing the shared duplicate minterm (m∧w∧d∧¬s) yields the 7-minterm canonical DNF:
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)To CNF. A conjunction of disjunctions, that is a 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 clausesCNF: (m∨d)∧(m∨¬s)∧(w∨d)∧(w∨¬s)
How to check the two forms. The original proposition, the canonical DNF (7 minterms), and the CNF (4 clauses) are all logically equivalent and evaluate identically across all 24=16 assignments of (m,w,d,s).
[Marks: 06, CO: 2]
This is three algorithmic tasks plus a complexity analysis for each. The tasks are independent, and each one has a natural choice whose justification is what the marks are for.
(i) Sorting the addresses by distance.
Algorithm chosen: merge sort. The addresses are sorted on a single numeric key, the distance from the warehouse. Merge sort divides the list in half, sorts each half recursively, and merges the two sorted halves in linear time.
Why merge sort and not the others.
Merge sort's selling point here is that its worst case equals its average case, so a delivery system with a hard deadline can rely on it. The cost is O(n) extra space.
(ii) Searching for a customer's order.
Algorithm chosen: binary search, since the list is already sorted from step (i).
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 need at most ⌈log2n⌉ comparisons. For n=106 that is 20 comparisons against 106 for a linear scan, which is the whole reason sorting is worth doing once if many searches follow.
(iii) Assigning vans greedily.
Algorithm: nearest-neighbour greedy. Scan the unserved addresses, take the closest one, assign it, mark it served, and repeat.
function GREEDY-ASSIGN(addresses, vans):
served <- {}
for each van:
current <- warehouse position
while an unserved address remains and the van has capacity:
best <- the unserved address nearest to current
assign best to this van
add best to served
current <- position of best
return assignment
Sort O(nlogn),search O(logn),assign O(nlogn+nm)
The complexity analysis. The outer loop runs V times. For each van, the inner loop scans the unserved list to find the nearest, and it does so once per assigned address, giving A scans in the worst case, each of cost O(A) if the list is not indexed. So the total is O(V⋅A2) in the worst case, or O(A2) when the number of vans is proportional to the address count. Using a spatial index, a k-d tree or a grid hash, reduces the nearest-neighbour query to O(logA), giving O(VAlogA).
Why greedy here, and what it costs. Greedy is O(VA2) and simple, and for a delivery list it is close to optimal in practice. It does not guarantee the shortest total route, which is the travelling salesman problem and is NP-hard. The bound is that greedy's tour is at most O(logA) times the optimal tour in the worst case, and in practice it lands within a few percent. Since the exam asks for a greedy approach, the answer is the nearest-neighbour construction with its complexity stated, plus the note that it is a heuristic.
[Marks: 04, CO: 2]
The rule. A biconditional P↔Q is true exactly when the two sides 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)
So the evaluation is two steps: find the truth value of each side separately, then compare. The comparison is the only step that decides the answer, and it is the step people get wrong.
The four cases.
(i) 2+2=4 is true. 1+1=2 is true. Same value, so the biconditional holds.
(ii) 1+1=2 is true. 2+3=5, not 4, so 2+3=4 is false. The values disagree.
(iii) 1+1=3 is false. Monkeys cannot fly, so that is false. Both false, so they match, and the biconditional holds.
(iv) 0>1 is false. 2>1 is true. The values disagree.
(i) TRUE
(ii) FALSE
(iii) TRUE
(iv) FALSE
[Marks: 04, CO: 2]
The rule that settles all of these. Congruence behaves like equality under addition, subtraction and multiplication. If a≡c and b≡d modulo n, then
a+b≡c+d,a−b≡c−d,ab≡cd(modn)
So every part is computed by substituting the residues and reducing at the end.
(i) c≡7a+3b(mod19)
7a+3b≡7(11)+3(3)=77+9=86(mod19)
Reduce: 86=19(4)+10.
c=10
(ii) c≡a3+4b3(mod19)
a3+4b3≡113+4(33)=1331+108=1439(mod19)
Reduce: 1439=19(75)+14.
c=14
Why substitution is legitimate. The chain rule is what makes this work, and it is worth stating once because it is used in every subsequent number theory question. Write a=11+19m and b=3+19k for integers m,k. Then
ab=(11+19m)(3+19k)=33+19(11k+3m+19mk)
so ab−33 is a multiple of 19, which is the definition of ab≡33. The multiple of 19 that appears carries the information about m and k, so the residue does not depend on which representatives a and b were chosen. This is the argument behind "substitute the residues".
The reduction step. After computing a residue, reduce it into the standard range 0,1,…,n−1 by subtracting n until the result lies in range. For 33 modulo 19 this means one subtraction, giving 14. For large products the efficient version is to reduce during the multiplication rather than at the end, which is exactly what modular exponentiation does.
[Marks: 04, CO: 2]
The algorithm is fast exponentiation, also called square-and-multiply. It computes abmodn in O(logb) steps instead of O(b) by writing the exponent in binary and repeatedly squaring.
The method. Write b in binary. Then
ab≡i:bi=1∏(a2imodn)(modn)
and the terms a2imodn are generated by repeated squaring:
a20,a2i+1≡(a2i)2(modn)
Each is reduced modulo n immediately, so no intermediate value exceeds n2, which is what keeps the computation inside machine precision. This is the point of the method: without the reduction, 3644 has over 300 digits.
Write 644 in binary.
644=512+128+4=29+27+22
So the binary form is 10100001002, with ones in positions 9,7 and 2. Three rows of the table below will be used.
Repeated squaring of 3 modulo 645.
| i | 2i | 32imod645 | derived from |
|---|---|---|---|
| 0 | 1 | 3 | given |
| 1 | 2 | 9 | 32=9 |
| 2 | 4 | 81 | 92=81 |
| 3 | 8 | 111 | 812=6561=10(645)+111 |
| 4 | 16 | 66 | 1112=12321=19(645)+66 |
| 5 | 32 | 486 | 662=4356=6(645)+486 |
| 6 | 64 | 126 | 4862=236196=366(645)+126 |
| 7 | 128 | 396 | 1262=15876=24(645)+396 |
| 8 | 256 | 81 | 3962=156816=243(645)+81 |
| 9 | 512 | 111 | 812=6561=10(645)+111 |
The cycle visible in rows 2, 3, 8 and 9, namely 81→111→66→486→126→396→81, is real and follows from 645=3×5×43, which is not prime and not a prime power.
Multiply the three rows that are one. Positions 9,7 and 2:
3644≡111×396×81(mod645)
First, 111×396=43956. Reducing:
43956=68(645)+96,so 111×396≡96(mod645)
Then
96×81=7776=12(645)+36
3644≡96×81≡36(mod645)
3644mod645=36
Both notations are correct and mean the same thing. The exam-style origin prints
the bmod form, so that is what is boxed here; the congruence form above is
easier to follow while working, since each step is a congruence rather than a
remainder.
| modulus | 3644 mod it | why |
|---|---|---|
| 3 | 0 | 3 divides 3644 |
| 5 | 1 | 34=81≡1(mod5), and 644=4(161), so the residue is 1 |
| 43 | 36 | found by the same square-and-multiply method modulo 43 |
Combining the three residues by the Chinese Remainder Theorem gives the single residue 36 modulo 645. The two routes, one direct and one via three smaller moduli, agree on 36, which is the confirmation worth having, because a single wrong squaring propagates through every later row and produces an answer that looks entirely reasonable. Note that Euler's theorem is not available here, since gcd(3,645)=3=1, so reducing the exponent modulo ϕ(645)=336 would be invalid. This is a good example of a method that works only when the side condition is checked first.
[Marks: 02, CO: 2]
The principle. If N objects are placed into k boxes, then some box contains at least ⌈N/k⌉ objects.
The generalised form goes further than the simple one. The simple form says only that k+1 objects in k boxes forces some box to hold at least two. The generalised form gives the guaranteed minimum occupancy as a number, and that number is the ceiling of the ratio.
Why the ceiling. Spreading N objects as evenly as possible fills each box with either ⌊N/k⌋ or ⌈N/k⌉ objects. No smaller number than the ceiling can be guaranteed, because an even spread is always achievable, and in it the fullest box holds exactly ⌈N/k⌉.
A real-world example. A delivery company operates a call centre. Over 365 days of recorded customer contacts, each day's contacts fall into one of 20 issue categories: billing, delivery delay, damaged item, and so on. Since 365>20×18=360, at least one category received contacts on at least ⌈365/20⌉=19 days. The number 19 is what staffing has to plan for, and the principle produces it without looking at a single record.
A second example, closer to computing. A warehouse receives 4800 packages for 250 storage slots. Then some slot holds at least ⌈4800/250⌉=⌈19.2⌉=20 packages, so the shelves must be rated for 20, and the figure comes from the principle alone.
Why it matters in computing. The principle is the basis of several standard results. In hashing it guarantees collision counts: with N keys in m slots, some slot receives at least ⌈N/m⌉ keys, which is the worst-case chain length for chained hashing. In sorting theory it gives the lower bound Ω(nlogn): there are n! possible orderings and only 2c outcomes from c comparisons, so 2c≥n! and therefore c≥log2n!, which is Ω(nlogn).
More objects than box capacity forces at least one crowded box