RUET · ECE Dept · B.Sc. Engineering 2nd Year Even Semester Examination, 2023
This file explains the same questions as
the 2023 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.
SECTION A
Question 1
(a) Explain the differences between analytical and numerical solution; also describe the significance of numerical analysis in engineering field.
[Marks: 04, CO: 1]
An analytical solution is one where you manipulate symbols until the unknown
appears on its own, and the answer is valid at every point of the domain. A
numerical solution is one where you approximate the problem by something you
can evaluate, and the answer is a number valid near the point you evaluated it
at.
The distinction that actually matters. An analytical answer is a rule; a
numerical answer is a reading. If the answer is y=3x2+1, you can
evaluate it anywhere without computing anything new. If the answer is
y(2.5)=19.75, that one number is all you have, and getting y(3) means
starting again.
Side by side.
Analytical
Numerical
Result
Closed form, exact
Approximate
Domain
Whole domain
Local, near one point
Difficulty of problem
May be impossible
Grows slowly with size
Cost per answer
Fixed once derived
Grows with problem size
Round off error
None
Present
Typical size
Thousands of equations
Millions
The differences, stated as points.
Form. Analytic gives y=f(x) in symbols. Numeric gives a table of
values or one point y(x0).
Accuracy. Analytic is exact. Numeric carries both truncation error, from
the approximation itself, and round off error, from finite precision. A good
method reports a bound on their sum, which is the part that distinguishes
engineering practice from guesswork.
Problem size. Analytic solutions exist for a handful of textbook
equations. Real systems give equations nobody can solve in symbols, and that
is exactly where numeric methods begin.
Changing the data. Analytic re-evaluates instantly. Numeric must be run
again from the start.
Understanding. Analytic reveals structure, such as a conservation law or
a resonance condition. Numeric hides it.
Why numerical analysis matters in engineering. Six reasons, and the marks
are usually spread across them.
It makes unsolvable problems solvable. Most real systems have no closed
form: a coupled circuit, a fluid flow, a heat-transfer body, a structural
frame. These are not hard problems, they are problems whose closed form
nobody has written down.
It replaces an expensive experiment. A structural analysis or a CFD run
costs a fraction of a physical test and can be repeated at any parameter
setting. It is also the only option when the real thing cannot be built,
because it would be dangerous or too expensive.
It handles irregular data. Measurements arrive unevenly spaced and noisy.
Interpolation and least squares fit them without demanding a functional form
in advance.
It supports design iteration. Optimisation needs hundreds or thousands of
evaluations, each one a numerical solve. An analytical solution would be
faster per evaluation but frequently does not exist.
It quantifies its own trust. Every method carries an error bound, so the
engineer knows how far to believe the answer. This is the difference between
a method and a guess.
It is cheap in time and memory, which is why it is used before the
hardware exists.
Analytical is exact and general; numerical is approximate, local, and reaches further
(b) Given that u=z35xy2, find the relative error at x=y=z=1 when the errors in each of x,y,z is 0.001.
[Marks: 03, CO: 2]
This question deals with error propagation. In numerical analysis, errors in measured quantities can be treated in two standard ways:
Interpretation 1: Maximum Relative Error (Standard Textbook / Worst-Case Bound)
In engineering and numerical analysis textbooks (e.g., S. S. Sastry, B. S. Grewal), an "error of 0.001" in a measured variable represents an uncertainty bound:
∣Δx∣≤0.001,∣Δy∣≤0.001,∣Δz∣≤0.001
The exact value at x=y=z=1 is:
u=135(1)(1)2=5
Taking natural logarithms of u=z35xy2:
lnu=ln5+lnx+2lny−3lnz
Differentiating gives the relation between relative errors:
udu=xdx+2ydy−3zdz
To find the maximum possible relative error, we take absolute values of each component (since errors in different measurements can have opposing signs and conspire to produce the worst-case error bound):
(c) Derive the formula for root finding using Newton-Raphson method. Also, discuss the problems of it and how this problem can be solved.
[Marks: 03, CO: 1]
Newton-Raphson is built on one idea: draw the tangent to the curve at your
current guess and see where it cuts the axis. Because the tangent touches the
curve, it tracks the curve closely near the root, so the intercept is a much
better guess than the current point.
The derivation. Let the root of f(x)=0 be x∗. Start at x0 and move
along the tangent to the curve at that point. The tangent at x0 is
f(x0)+f′(x0)(x−x0)
Set it to zero to find where the tangent meets the axis:
f(x0)+f′(x0)(x1−x0)=0⟹x1=x0−f′(x0)f(x0)
Equivalently, and this is the form usually derived: let x∗=x0+h, so the
tangent crosses at x0+h. By the first-order mean value form of Taylor,
0=f(x∗)=f(x0+h)≈f(x0)+hf′(x0)
which gives h=−f′(x0)f(x0) and the same iteration. Repeating:
xn+1=xn−f′(xn)f(xn)
If f′ is not available in closed form, write
f′(xn)=limh→0hf(xn+h)−f(xn), which is the origin of
the secant method.
Why it converges so fast. Keep the second-order Taylor term:
f(x∗)=0=f(xn)+f′(xn)Δx+2f′′(ξ)Δx2
Substituting Δx=−f′f shows the error satisfies
en+1≈2f′(x∗)f′′(x∗)en2. The error is squared at
every step. From six correct digits you get twelve, from twelve you get
twenty-four. That doubling of the digit count for one extra derivative
evaluation is why Newton-Raphson is the default root finder.
The problems, and what fixes each.
Problem
Cause
Fix
Diverges or oscillates
Initial guess too far, or f′ small
Bracket the root first and start inside, or use bisection
Division by zero
f′(xn)=0, a stationary point
Choose another start, or use a method that does not divide by f′
Cycle between two points
Overshoot from a bad start
Damp the step, or switch to bisection when two successive values repeat
False convergence
f(xn)=0 but f′(xn)=0
Always check ∣f(xn)∣, not only ∣xn+1−xn∣
Slow near a repeated root
Squaring holds only for a simple root
Use xn+1=xn−mf′(xn)f(xn) with m the multiplicity
No convergence on a step-like function
No tangent information, as on a signum
Bisection, which needs only a sign change
f′ unavailable
Only a formula for f
Secant, which builds the derivative from two points
Question 2
(a) Derive the Newton's forward interpolation formula: yn(x)=y0+pΔy0+2!p(p−1)Δ2y0+3!p(p−1)(p−2)Δ3y0+⋯
[Marks: 04, CO: 3]
The setup. Let y=f(x) be given at n+1 equally spaced points:
x0,x1=x0+h,x2=x0+2h,…,xn=x0+nh
with common spacing h and values y0,y1,y2,…,yn.
Write any point in the domain as:
x=x0+ph⟹p=hx−x0
where p is the dimensionless parameter measuring distance from x0 in units of h.
Step 1. Newton's interpolating polynomial form.
We assume the interpolating polynomial Pn(x) of degree n in factorial powers of (x−x0):
where a0,a1,…,an are constant coefficients to be determined so that Pn(xi)=yi for all i=0,1,…,n.
Step 2. Determine coefficients successively.
Because each factor (x−xk) vanishes at all subsequent interpolation nodes, the coefficients decouple cleanly:
At x=x0:
All terms after a0 vanish:
Pn(x0)=a0=y0⟹a0=y0
At x=x1=x0+h:Pn(x1)=a0+a1(x1−x0)=y0+a1h=y1a1=hy1−y0=1!hΔy0
At x=x2=x0+2h:Pn(x2)=a0+a1(2h)+a2(2h)(h)=y2y0+2Δy0+2h2a2=y22h2a2=y2−2y1+y0=Δ2y0⟹a2=2!h2Δ2y0
By induction for any k≤n:ak=k!hkΔky0
Step 3. Change variable to p=hx−x0.
Express each product of factors in terms of p:
x−x0=ph
x−x1=ph−h=(p−1)h
x−x2=ph−2h=(p−2)h
(x−x0)(x−x1)⋯(x−xk−1)=p(p−1)⋯(p−k+1)hk
Substitute ak and the factor product into the k-th term of Pn(x):
(b) Find y(2) from the following data using Lagrange's formula.
[Marks: 03, CO: 2]
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−xj
The Li are basis polynomials: each one is 1 at its own node and 0 at every
other node, so the combination reproduces all five data values exactly.
Step 2. Compute each weight. The thing that goes wrong here is signs. Keep
the numerator factors and denominator factors separate and count them, because
the denominator carries one negative sign per factor below xi.
Node 0, at x=0. All four denominator factors are negative, so the product
is positive.
(c) Use Romberg's method to compute ∫122+x1dx. Consider h=0.5,0.25,0.125.
[Marks: 03, CO: 3]
Romberg is repeated Richardson extrapolation. The idea is worth understanding
before the arithmetic, because it explains every number in the table.
The mechanism. The trapezoid rule on a grid of width h has error
12(b−a)h2f′′(ξ)+O(h4), so the error is proportional to h2 to
leading order. Halving h therefore divides the error by 4. If you have two
grids, you can subtract off the h2 part and cancel it exactly. Apply the
same trick to what is left, and the h4 part cancels. Each column of the
Romberg table buys two more orders of accuracy.
Step 1. The first column, composite trapezoid. With f(x)=2+x1,
Tn=2h[f0+2f1+⋯+2fn−1+fn].
(a) Find the eigenvalues and eigenvectors of the matrix A=5010−20105.
[Marks: 05, CO: 2]
Step 1. The characteristic equation. Eigenvalues are the values of
λ for which A−λI is singular:
A−λI=5−λ010−2−λ0105−λ
Expand along the second row, because it holds a single nonzero entry. This is
the whole trick: this matrix has a row of the form (0,⋅,0), so the
determinant reduces to a 2×2 minor immediately.
det(A−λI)=(−2−λ)5−λ115−λ=(−2−λ)[(5−λ)2−1]
Now factor the bracket as a difference of squares, (5−λ)2−12:
=(−2−λ)[(5−λ)−1][(5−λ)+1]=(−2−λ)(4−λ)(6−λ)=0
Each factor gives one eigenvalue:
λ1=6,λ2=4,λ3=−2
Step 2. Eigenvector for λ1=6. Solve (A−6I)v=0:
−1010−8010−1v1v2v3=0
Row 1 gives −v1+v3=0, so v3=v1. Row 2 gives −8v2=0, so
v2=0. One free parameter, so one dimension of eigenvector space, which is
what you expect. Take v1=1:
v(1)=101,∥v(1)∥=2,v^(1)=21101
Step 3. Eigenvector for λ2=4. Solve (A−4I)v=0:
1010−60101v1v2v3=0
Row 1 gives v1+v3=0, so v3=−v1, and row 2 gives v2=0. Take
v1=−1, so v3=1:
v(2)=−101,∥v(2)∥=2,v^(2)=21−101
Step 4. Eigenvector for λ3=−2. Solve (A+2I)v=0:
701000107v1v2v3=0
Row 1 gives 7v1+v3=0, so v3=−7v1. Row 2 is 0=0, so v2 is
free. Take v1=0, hence v3=0, and v2=1:
(b) Using Euler's method, solve the following problems: (i) dxdy=53x3y, y(0)=1, (ii) dxdy=1+y2, y(0)=0.
[Marks: 05, CO: 2]
The method. Take the slope at the left end of each step and project it
straight:
yn+1=yn+hf(xn,yn),xn+1=xn+h
Geometrically, that is drawing a straight line from (xn,yn) to
(xn+h,yn+hf) using the slope at the start of the interval. The
true curve bends away over the interval, and the accumulated error is why Euler
is only first order.
(i) y′=53x3y, y(0)=1, h=0.25
Step
xn
yn
Slope 53xn3yn
yn+1=yn+h⋅slope
1
0.00
1.0000000
53(0)3(1)=0
1+0.25(0)=1.0000000
2
0.25
1.0000000
53(0.25)3(1)=0.0093750
1+0.25(0.009375)=1.0023440
3
0.50
1.0023438
53(0.5)3(1.002344)=0.0751758
1.002344+0.25(0.075176)=1.0211377
4
0.75
1.0211377
53(0.75)3(1.021138)=0.2584755
1.021138+0.25(0.258475)=1.0857566
y(1)≈1.0857566
Step 1 is worth a second look, because a zero there is easy to misread as an
error. The slope is 53(0)3(1)=0 because x0=0, so y does not
move at all on the first step and y1=y0=1. That is correct, and it is why
y1 and y2 both start from exactly 1.
(ii) y′=1+y2, y(0)=0, h=0.25
Step
xn
yn
Slope 1+yn2
yn+1
1
0.00
0.0000000
1.0000000
0+0.25(1)=0.2500000
2
0.25
0.2500000
1.0625000
0.25+0.25(1.0625)=0.5156250
3
0.50
0.5156250
1.2658691
0.515625+0.25(1.265869)=0.8320923
4
0.75
0.8320923
1.6923776
0.832092+0.25(1.692378)=1.2551867
y(1)≈1.2551867
Question 4
(a) Briefly explain interpolation, extrapolation and curve fitting with examples.
[Marks: 03, CO: 1]
All three take discrete data and produce a continuous relation. They differ in
what they promise, and the promise is what you are choosing when you pick
one.
Interpolation builds a function that passes through every given point
exactly:
P(xi)=yifor every i
The answer is exact at the data and carries no modelling error at all. Example: a
thermocouple is calibrated at 0∘C and 100∘C, and its reading at
37∘C is found by interpolating between those two calibrations.
Extrapolation evaluates a fitted function outside the range of the data.
The function may pass through every point perfectly and still say nothing
trustworthy outside, because nothing constrains it there. Example: predicting
next year's sales figure from five years of history. The fit is exact on those
five years and can still be badly wrong on the sixth, because the polynomial that
threads five points has no particular opinion about the sixth.
Curve fitting finds the function that comes closest to all points without
passing through any, by minimising a misfit such as
i∑[yi−f(xi)]2
Example: fitting a straight line to seven noisy voltage readings to recover the
true calibration slope. The line deliberately misses the readings, because
passing through them would reproduce the noise as well as the signal.
Interpolation
Extrapolation
Curve fitting
Passes through data
Yes
May or may not
No
Outside the data
Not defined
Defined but unreliable
Defined, degree dependent
Data assumed
Exact
Exact
Noisy
Point count
Need n+1 points for degree n
Same
Can use fewer
Risk
Runge oscillation far out
Large and growing error
Under-fitting if too simple
Choosing between them. Interpolate inside the data. Fit when the data are
noisy, or when the underlying trend rather than the individual points is the
object of interest. Extrapolation is required only when the target genuinely
lies outside the data range, and then only over a short distance, at most about
one data interval.
(b) The distance covered by a rocket from t=8 to t=30 is given by x=∫830(2000ln[140000−2100t140000]−9.8t)dt. (i) Use Simpson's 1/3 rule to find the approximate value of x, (ii) find the true error Et, (iii) find the absolute relative true error ∣ϵt∣.
[Marks: 05, CO: 3]
The integrand is the vertical velocity of the rocket:
f(t)=2000ln(140000−2100t140000)−9.8t
Interval [a,b]=[8,30], total interval width b−a=22.
This problem is a classic exercise originally from Autar Kaw's Numerical Methods with Applications. In an examination setting without an explicit step size, "Simpson's 1/3rd rule" fundamentally refers to the single-application, 2-segment rule (n=2):
Step 1. Grid setup.
With n=2 segments:
h=2b−a=230−8=11 s
The three evaluation nodes are t0=8, t1=19, and t2=30:
f(t0)=f(8)=2000ln(140000−2100(8)140000)−9.8(8)=177.2667 m/s
f(t1)=f(19)=2000ln(140000−2100(19)140000)−9.8(19)=484.7455 m/s
f(t2)=f(30)=2000ln(140000−2100(30)140000)−9.8(30)=901.6740 m/s
Step 3. Analytical integration and error calculation.
Integrating f(t) by parts yields the exact distance:
Iexact=∫830f(t)dt=11061.34 m
(ii) True error (Et):Et=Iexact−x=11061.34−11065.72=−4.38 m
(ii) Et=−4.38 m
(Note: Because Et<0, the numerical approximation x=11065.72 is slightly larger than the true distance, meaning Simpson's rule overestimated the true value).
If composite Simpson's rule is applied on n=22 subintervals (h=1):
Summing the 23 points gives x≈11061.335875 m
Et=11061.335535−11061.335875=−0.000340 m (overestimated)
∣ϵt∣=3.076×10−6%
(c) Compare Simpson's 1/3 and 3/8th rules.
[Marks: 02, CO: 1]
Feature
Simpson's 1/3rd Rule
Simpson's 3/8th Rule
Formula weights
1,4,2,4,…,4,1 (coefficients 3h[1,4,1])
1,3,3,2,3,3,…,3,1 (coefficients 83h[1,3,3,1])
Panel width
2h (fits a 2nd-degree parabola)
3h (fits a 3rd-degree cubic)
Subintervals per panel
2
3
Subinterval constraint (n)
n must be even (2∣n)
n must be a multiple of 3 (3∣n)
Order of accuracy
4th order (O(h4))
4th order (O(h4))
Truncation error
−180(b−a)h4f(4)(ξ)
−80(b−a)h4f(4)(ξ)
Error constant
1801≈0.00556
801=0.0125
Degree of precision
3 (exact for polynomials of degree ≤3)
3 (exact for polynomials of degree ≤3)
Differences that matter in practice:
Accuracy comparison: Simpson's 1/3 rule is roughly 2.25 times more accurate than the 3/8 rule on the same step size because its error coefficient (1801) is significantly smaller than that of the 3/8 rule (801).
Subinterval requirements: Simpson's 1/3 needs an even number of subintervals, whereas Simpson's 3/8 requires n to be divisible by 3. When n is a multiple of 6, either rule may be used across the whole interval.
Exactness on cubic polynomials: Both rules have a degree of precision of 3. This means that for ANY polynomial of degree up to 3 (including cubics), both single-segment and composite Simpson's rules give the exact integral with zero truncation error, because f(4)(ξ)≡0. Truncation error only emerges for quartic (degree 4) and higher polynomials.
Hybrid combination: When n is odd and not divisible by 3, a standard practice is to use Simpson's 1/3 rule for the first n−3 segments and Simpson's 3/8 rule for the final 3 segments.
Both are 4th order and exact for cubics; 1/3 needs even n,3/8 needs 3∣n,and 1/3 is more accurate
SECTION B
Question 5
(a) Build a digital circuit that produces the output (p∨¬r)∧(¬p∨(q∨¬r)) when given input bits p,q and r.
[Marks: 04, CO: 2]
The question gives you an expression and asks for hardware. Building the circuit
straight from the expression works, but it needs four gates where three will do,
so the first job is simplification.
Step 1. Simplify algebraically. Look at the two bracketed terms:
F=(p∨¬r)∧(¬p∨q∨¬r)
¬r appears in both, and that is the handle to pull. Apply the distributive
identity
(a∨c)∧(b∨c)=(a∧b)∨c
with c=¬r, a=p and b=(¬p∨q):
F=¬r∨[p∧(¬p∨q)]
Now distribute inside the bracket:
p∧(¬p∨q)=(p∧¬p)∨(p∧q)=0∨(p∧q)=p∧q
Therefore
F=¬r∨(p∧q)
Step 2. Read off the circuit.
Invert r with a NOT gate to give ¬r.
AND p with q to give p∧q.
OR that with ¬r to give the output F.
Gates required: 1 NOT, 1 AND (2-input), 1 OR (2-input), total: 3 gates.
Logic Circuit Diagram (Simplified Form):
Alternative: Direct (Unsimplified) Circuit:
If implemented directly without simplification:
F=¬r∨(p∧q)
F=(¬r∨p)∧(¬r∨q)
This is useful in hardware because NAND is often the only gate a cheap part
family provides. De Morgan's theorem turns each bracket into a NAND followed by
an inverter, and a NAND-inverter pair is itself a NAND with its inputs tied, so
the whole thing maps onto two NAND stages.
(b) Four friends have been identified as suspects for an unauthorized access into a computer system. Alice said "Carlos did it." John said "I did not do it." Carlos said "Diana did it." Diana said "Carlos lied when he said that I did it." (i) If exactly one of the four suspects is telling the truth, who did it? (ii) If exactly one is lying, who did it?
[Marks: 04, CO: 3]
Translate the statements. The four suspects are mutually exclusive, so exactly
one of them did it. Let the culprit be one of A,J,C,D.
Statement
True when
SA: "Carlos did it"
culprit =C
SJ: "I did not do it"
culprit =J
SC: "Diana did it"
culprit =D
SD: "Carlos lied when he said I did it"
Carlos's claim was false, that is culprit =D
The structural observation that makes this easy: SC and SD are exact
negations of each other. Carlos says Diana did it; Diana says Carlos's claim
was false. Either Diana did it and Carlos is truthful, or she did not and Carlos
is lying. Exactly one of those two is therefore always true, whatever the
culprit. This drives both parts.
(i) Exactly one telling the truth
Test each culprit:
Culprit
SA
SJ
SC
SD
True count
A
F
T
F
T
2
J
F
F
F
T
1
C
T
T
F
T
3
D
F
T
T
F
2
Only one row gives a count of 1.
(i) John did it
Reasoning without a table. Since SC and SD are negations, one of them
must be true, so the single truth must be one of those two, which means Alice and
John are both lying. John lying means his statement "I did not do it" is false,
so John did it.
Verify: John lying, Carlos lying (Diana did not do it), Alice lying (Carlos did
not do it), Diana telling the truth (Carlos's claim was false). Exactly one truth.
Agrees.
(ii) Exactly one lying
Equivalently, exactly three telling the truth. The same table, reading the false
count:
Culprit
SA
SJ
SC
SD
Lying count
A
F
T
F
T
2
J
F
F
F
T
3
C
T
T
F
T
1
D
F
T
T
F
2
Only one row gives a lying count of 1.
(ii) Carlos did it
Reasoning without a table. Exactly one lying means Alice and Diana are both
telling the truth, since they cannot both lie. Alice true gives culprit =C.
Then John says "I did not do it", which is true since Carlos did it, and Carlos
says "Diana did it", which is false. Exactly one lie, Carlos's. Agrees.
(c) Show that each of the conditional statements is a tautology by using truth tables: (i) ¬(p→q)→p, (ii) p→(p∨q).
[Marks: 02, CO: 2]
A tautology is true on every assignment, so the last column of the table must
be T in all four rows. There is no partial credit in "show that", so both rows of
each table must be filled in; leaving the last column half blank defeats the
purpose.
(i) ¬(p→q)→p
p→q is F only when p=T,q=F. So ¬(p→q) is T only there.
p
q
p→q
¬(p→q)
¬(p→q)→p
F
F
T
F
T
F
T
T
F
T
T
F
F
T
T
T
T
T
F
T
The final column is T in every row.
Algebraic confirmation.¬(p→q)=¬(¬p∨q)=p∧¬q.
Then (p∧¬q)→p=¬(p∧¬q)∨p=(¬p∨q)∨p=⊤.
(a) Show that ¬(p↔q) and ¬p↔q are logically equivalent.
[Marks: 02, CO: 3]
Step 1. Build the truth table.
p
q
p↔q
¬(p↔q)
¬p
¬p↔q
F
F
T
F
T
F
F
T
F
T
T
T
T
F
F
T
F
T
T
T
T
F
F
F
The two computed columns are identical: F, T, T, F reading down the rows
FF, FT, TF, TT. Identical columns on every row means the formulas are
logically equivalent.
¬(p↔q)≡(¬p↔q)
Step 2. Algebraic proof. Rewrite both sides to the same thing.
Left side:
¬(p↔q)=¬[(p→q)∧(q→p)]=¬(p→q)∨¬(q→p)=(p∧¬q)∨(¬p∧q)
This is exclusive-or. Right side:
¬p↔q=(¬p→q)∧(q→¬p)=(p∨q)∧(¬q∨¬p)
Distribute:
(p∨q)∧(¬q∨¬p)=[(p∧¬q)∨(p∧¬p)∨(q∧¬q)∨(q∧¬p)]
The middle two terms are contradictions, since nothing is both a statement and its
negation:
=(p∧¬q)∨0∨0∨(¬p∧q)=(p∧¬q)∨(¬p∧q)
Both sides reduce to the same expression, so the equivalence is proven.
In words. "p and q disagree" means exactly one of them is true. If p is
false, then "q agrees with ¬p" means q is true, which is precisely the
case where they disagree. Flipping one input and asking for agreement tests the
same thing as asking for disagreement without the flip.
(b) Briefly explain modus ponens, modus tollens, hypothetical syllogism, disjunctive syllogism with truth tables and examples.
[Marks: 04, CO: 1]
All four are inference rules. Each is a valid argument form, meaning the
conclusion is guaranteed true whenever the premises are true. Validity is about
the form, not about whether any particular conclusion happens to be true, which
is why a truth table is the right tool: you are checking the form.
1. Modus ponens (MP), affirming the antecedent
p→q,p∴q
p
q
p→q
Premises both true
Conclusion q
F
F
T
antecedent false
F
F
T
T
antecedent false
T
T
F
F
no
T
T
T
yes
T
Whenever both premises hold, so does the conclusion. Valid.
Example. "If the switch is closed the lamp is lit." The switch is closed.
Therefore the lamp is lit.
2. Modus tollens (MT), denying the consequent
p→q,¬q∴¬p
p
q
p→q
¬q
Both true
Conclusion ¬p
F
F
T
T
yes
T
F
T
T
F
no
T
F
F
T
no
T
T
T
F
no
Valid. MT is the contrapositive rule, since p→q≡¬q→¬p.
Example. "If the fuse has blown the lamp is dark." The lamp is not dark.
Therefore the fuse has not blown.
3. Hypothetical syllogism (HS), chaining
p→q,q→r∴p→r
p
q
r
p→q
q→r
p→r
F
F
F
T
T
T
F
F
T
T
T
T
F
T
F
T
F
T
F
T
T
T
T
T
T
F
F
F
T
F
T
F
T
F
T
T
T
T
F
T
F
F
T
T
T
T
T
T
Whenever both premises are T, so is p→r. Valid.
Example. "If it rains the ground is wet. If the ground is wet the crop grows."
Therefore if it rains the crop grows.
4. Disjunctive syllogism (DS), eliminating by negation
p∨q,¬p∴q
p
q
p∨q
¬p
Both true
Conclusion q
F
F
F
T
no
F
T
T
T
yes
T
T
F
T
F
no
T
T
T
F
no
Valid.
Example. "The input is 0 or 1." The input is not 0. Therefore the input is 1.
Summary and comparison
Rule
Form
Name
Uses
MP
p→q,p∴q
Affirming the antecedent
Forward chaining
MT
p→q,¬q∴¬p
Denying the consequent, that is contraposition
Backward chaining
HS
p→q,q→r∴p→r
Transitivity
Chaining rules
DS
p∨q,¬p∴q
Elimination
Splitting a case
The invalid forms
Form
Status
Why it fails
p→q,q∴p
Invalid (Fallacy of affirming the consequent)
Counterexample: p=F,q=T. Premises (F→T)=T and q=T are true, but conclusion p=F is false.
p→q,¬p∴¬q
Invalid (Fallacy of denying the antecedent)
Counterexample: p=F,q=T. Premises (F→T)=T and ¬p=T are true, but conclusion ¬q=F is false.
Both are the converse and inverse of a conditional, and a conditional is not
equivalent to its converse or its inverse. It is equivalent only to its
contrapositive¬q→¬p, which is what MT uses.
MP, MT, HS, DS are valid; affirming the consequent and denying the antecedent are not
(c) With these hypotheses: "It is not sunny this afternoon and it is colder than yesterday." "We will go swimming only if it is sunny." "If we do not swimming, then we will take a canoe trip." "If we take a canoe trip then we will be home by sunset." Using the inference rules, construct a valid argument for the conclusion: "we will be home by sunset".
[Marks: 04, CO: 3]
Assign variables.
Symbol
Meaning
S
it is sunny this afternoon
C
it is colder than yesterday
W
we go swimming
K
we take a canoe trip
H
we are home by sunset
Translate the four hypotheses.
"It is not sunny this afternoon and it is colder than yesterday":
¬S∧C
"We will go swimming only if it is sunny". The phrase "only if" means
swimming is a necessary condition of sunshine, so W→S:
W→S
"If we do not swim, then we will take a canoe trip": ¬W→K
"If we take a canoe trip then we will be home by sunset": K→H
Extract what is needed. Split hypothesis 1 by simplification to get ¬S
and C. The proof needs only ¬S.
The goal is H, so work backwards from the rule that produces it. Rule 4 needs
K, rule 3 needs ¬W, and ¬W comes from S by modus tollens on rule
2.
The valid argument, step by step.
Step
Statement
Rule
1
¬S∧C
Premise 1
2
¬S
Simplification, 1
3
W→S
Premise 2
4
¬W
Modus tollens, 3 and 2
5
¬W→K
Premise 3
6
K
Modus ponens, 5 and 4
7
K→H
Premise 4
8
H
Modus ponens, 7 and 6
Therefore "we will be home by sunset" is a valid conclusion.
¬S⇒¬W⇒K⇒H,so H follows validly
Question 7
(a) Suppose that a and b are integers, a≡4(mod13), and b≡9(mod13). Find the integer c with 0≤c≤12 such that (i) c=2a+3b(mod13), (ii) c=a2+b2(mod13).
[Marks: 04, CO: 2]
Work entirely with the residues, then reduce to 0≤c≤12. Congruence
arithmetic is exactly real arithmetic modulo the modulus, so substituting the
residues for a and b is valid from the start and keeps every intermediate
number small.
(c) If n is a composite integer then n has a prime divisor less than or equal to n.
[Marks: 03, CO: 2]
Proof.
Let n be composite. Then by definition n=ab for integers a,b with
1<a<n and 1<b<n.
Key observation. At least one of a and b is at most n. Suppose
both were larger:
a>nandb>n⟹ab>nn=n
Since ab=n, this is a contradiction. Hence a≤n or
b≤n. Without loss of generality suppose a≤n, so
1<a≤n.
Now find a prime divisor at most a. Every integer a>1 has a prime
divisor: keep dividing by a prime factor until the result is 1, and the last
prime divided out is a prime p dividing a. So there is a prime p with
p∣a.
Since a∣n and p∣a, transitivity of divisibility gives p∣n. And
p≤a≤n.
Every composite n has a prime divisor p with p≤n
Question 8
(a) Briefly describe the pigeonhole principle with a real world example.
[Marks: 02, CO: 1]
The principle. If N objects are placed into k boxes and N>k, then at
least one box holds at least two objects.
Proof. Suppose every box held at most one object. Then the boxes would hold
at most k objects in total. But N>k, a contradiction.
Real-world examples.
Socks. From a drawer holding black and white socks only, drawing three
socks guarantees two of a colour, since two boxes cannot take three objects
with at most one each. This is the tightest version: N=3 into k=2.
Birthdays. With 366 possible birthdays, the plain principle needs 367
people to force a shared birthday, not 23. The famous result is therefore a
probabilistic one, not a pigeonhole one: under a random model, past about
23 people the chance of a shared birthday exceeds 50%.
Pigeonholes in a building. A building with n floors and n+1 people
must have two on the same floor.
Hash tables. Storing n keys in m buckets forces a collision once
n>m, which is why the load factor is kept below 1.
More objects than boxes forces at least one box to hold two or more
(b) A group of 30 people have been trained as astronauts to go on the first mission to mars. How many ways are there to select a crew of six people to go on this mission (assuming all crew members have the same job)?
[Marks: 03, CO: 2]
Setting up. Selection is without regard to order, so order does not
matter: the crew {A,B,C} is the same crew whichever order you write it.
Every crew member has the same job, so there is no assignment to count either.
This is a combination, (rn), not a permutation.
(c) Briefly describe the Binomial theorem, and what is the coefficient of x12y13 in the expansion of (2x−3y)25?
[Marks: 04, CO: 3]
The theorem. For positive integers m and n,
(x+y)n=r=0∑n(rn)xn−ryr
The general term is
Tr+1=(rn)xn−ryr,r=0,1,…,n
A proof by induction on n: the case n=1 is immediate, and the step follows
from Pascal's identity (rn+1)=(rn)+(r−1n) applied to
(x+y)n+1=(x+y)n⋅(x+y).
Applying it. With x→2x and y→−3y and n=25,
(2x−3y)25=r=0∑25(r25)(2x)25−r(−3y)r
Identify the term. A general term carries x25−ryr. For x12y13 we
need
25−r=12andr=13
Both give r=13, and the powers 12+13=25 check out.
The coefficient.
coefficient=(1325)(2)12(−3)13
Since (1325)=(1225)=5200300,
=5200300×4096×(−1594323)coefficient of x12y13=−33959763545702400
(d) Why is discrete mathematics essential in computer science and algorithm design?
[Marks: 01, CO: 1]
Discrete mathematics supplies the exact language for the structures a computer
represents, so that correctness and cost can be reasoned about rather than
guessed at.
Sets, relations, graphs, logic and counting describe what is stored and how it is
linked. Combinatorics counts the cases an algorithm must handle, which is what
converts "this is fast" into a bound. Logic gives proof rules that certify an
algorithm correct, so correctness is demonstrated rather than asserted. And the
binary system Question 7(b) uses is itself discrete: arithmetic on a fixed number
of bits is arithmetic in a finite structure, with overflow as one of its theorems.
Discrete mathematics is the language in which algorithms are specified, proved and costed