59.8 KB · commit a9602da
| title | ECE 2213 · 2022 Exam Style Answers |
|---|
RUET · ECE Dept · B.Sc. Engineering 2nd Year Even Semester Examination, 2022 Full Marks: 80 · Time: 03 Hours · CLO-mapped
Bracketing method. The root is first enclosed in an interval [a,b] where f(a) and f(b) have opposite signs,
f(a)⋅f(b)<0Continuity guarantees a root inside. Every step keeps the sign change, so the interval shrinks and the root can never be lost.
| Property | Bracketing |
|---|---|
| Initial data | An interval with a sign change |
| Information needed | Only f and its sign |
| Convergence | Always, from any valid bracket |
| Rate | Linear, O(h) |
| Examples | Bisection, regula falsi |
Open method. No interval is needed. The method starts from a single guess x0 and generates the next point from a formula, so it may wander away from the root and never come back.
| Property | Open method |
|---|---|
| Initial data | One estimate x0 |
| Information needed | f and f′ |
| Convergence | Only if x0 is close enough |
| Rate | Superlinear or quadratic |
| Examples | Newton-Raphson, secant, fixed point |
Why the distinction matters. Bracketing is safe but slow. Open methods are fast but can fail, so production codes keep a bracket and fall back to bisection whenever a Newton step leaves it. That hybrid keeps the speed of the open method and the guarantee of the bracketing one.
bracketing encloses the root and always converges; open methods start free and may notStep 1. Taylor's series about x=0.
f(x)=f(0)+xf′(0)+2!x2f′′(0)+3!x3f′′′(0)+4!x4f(4)(0)+⋯Step 2. Differentiate and evaluate at 0.
| f(x) | f′(x) | f′′(x) | f′′′(x) | f(4)(x) | |
|---|---|---|---|---|---|
| x3−3x2+5x−10 | 3x2−6x+5 | 6x−6 | 6 | 0 |
Step 3. The series terminates. Since the fourth derivative is identically zero, the expansion is a polynomial with no terms beyond x3:
f(x)=−10+5x−3x2+x3Step 4. Put x=1.
f(1)=−10+5(1)−3(1)2+(1)3=−10+5−3+1 f(1)=−7A real application of curve fitting. Calibrating a thermocouple, or any sensor, against a set of certified reference temperatures.
A calibration certificate lists reference points, for example
| Reference temperature (∘C) | Indicated reading (mV) |
|---|---|
| 0 | 0.00 |
| 100 | 4.09 |
| 200 | 7.33 |
| 400 | 12.45 |
The readings are measured to three decimals and each carries thermal drift and instrument noise, so no curve passes exactly through all four. Fitting a polynomial by least squares finds the one that comes closest, and the fit then calibrates the instrument: a raw reading of 9.20 mV is converted to a temperature through the fitted curve.
Second application: in a load-extension test, the raw data scatter because the specimen is not perfectly uniform, and the fitted curve gives the engineering stress and stiffness.
When to use Lagrange interpolation. Use it when all of these hold:
| Situation | Method |
|---|---|
| Few, exact, irregularly spaced points | Lagrange |
| Many, equally spaced, exact, near the start | Newton forward |
| Many, equally spaced, exact, near the end | Newton backward |
| Noisy data, any spacing | Least squares |
| Target outside the data | Least squares, not interpolation |
With three points a quadratic y=a0+a1x+a2x2 is the lowest-degree polynomial that can pass through all three.
Method, simultaneous equations. Substituting each point:
a0−a1+a2=7 a0+a1+a2=5 a0+2a1+4a2=15Subtract the first from the second:
2a1=−2⇒a1=−1With a1=−1 the first equation becomes a0−(−1)+a2=7, so a0+a2=6. The third becomes a0+2(−1)+4a2=15, so a0+4a2=17. Subtracting, 3a2=11, giving a2=311, and a0=6−311=37.
a0=37,a1=−1,a2=311 y=311x2−x+37Check all three points.
x=−1:311(1)+1+37=318+1=6+1=7✓ x=1:311−1+37=318−1=6−1=5✓ x=2:311(4)−2+37=344+7−2=17−2=15✓Step 1. Linearise. Take reciprocals of both sides:
y1=xa+bx=xa+b=a(x1)+bThis has the standard form v=au+b with
u=x1,v=y1Therefore the slope is a and the intercept is b.
Step 2. Transformed data.
| x | y | u=1/x | v=1/y |
|---|---|---|---|
| 3 | 7.148 | 0.333333 | 0.139899 |
| 5 | 10.231 | 0.200000 | 0.097742 |
| 8 | 13.509 | 0.125000 | 0.074025 |
| 12 | 16.434 | 0.083333 | 0.060849 |
Step 3. Sums.
n=4,∑u=0.741667,∑v=0.372516,∑uv=0.080505,∑u2=0.173681Step 4. Normal equations. The fitted line in the transformed variables is v=au+b, so summing v=au+b over the four points and summing uv=au2+bu:
nb+a∑u=∑v,(∑u)b+a∑u2=∑uvNote which coefficient multiplies which sum: the slope a multiplies ∑u and ∑u2, while the intercept b multiplies n and ∑u.
{4b+0.741667a=0.3725160.741667b+0.173681a=0.080505 a=n∑u2−(∑u)2n∑uv−∑u∑v=4(0.173681)−(0.741667)24(0.080505)−(0.741667)(0.372516)=0.694722−0.5500690.322022−0.276282=0.1446530.045739 a=0.316200 b=vˉ−auˉ=0.093129−0.316200(0.185417)=0.093129−0.058629=0.034500 y=0.3162+0.0345xxCheck the fitted values, using the unrounded coefficients a=0.31619988 and b=0.03450017, whose four-decimal forms are the boxed ones:
| x | y actual | y^=a+bxx | y−y^ |
|---|---|---|---|
| 3 | 7.148 | 7.147956 | +0.000044 |
| 5 | 10.231 | 10.231210 | −0.000210 |
| 8 | 13.509 | 13.508920 | +0.000080 |
| 12 | 16.434 | 16.433809 | +0.000191 |
Every residual is below 2.2×10−4, so the fit is essentially exact. Substituting the four-decimal 0.3162 and 0.0345 instead raises the largest residual to 2.26×10−4, still negligible.
Step 1. Set up the difference table. Here y=r3 with r=1,2,3,… and h=1, so u=r−1.
| r | 1 | 2 | 3 | 4 | 5 | ⋯ |
|---|---|---|---|---|---|---|
| y=r3 | 1 | 8 | 27 | 64 | 125 | |
| Δy | 7 | 19 | 37 | 61 | ||
| Δ2y | 12 | 18 | 24 | |||
| Δ3y | 6 | 6 | ||||
| Δ4y | 0 |
Step 2. Write the series. With y0=1, Δy0=7, Δ2y0=12, Δ3y0=6 and Δ4y0=0:
y(u)=1+7u+122!u(u−1)+63!u(u−1)(u−2) =1+7u+6u(u−1)+u(u−1)(u−2)=1+7u+6u2−6u+u3−3u2+2u =u3+3u2+3u+1=(u+1)3The series returns r3 exactly, as it must, since r3 is itself a cubic.
Step 3. Sum from u=0 to u=n−1.
Sn=u=0∑n−1[1+7u+6u(u−1)+u(u−1)(u−2)]Use ∑u=0n−11=n, ∑u=2n(n−1), ∑u(u−1)=2∑(2u)=2(3n)=3n(n−1)(n−2) and ∑u(u−1)(u−2)=6∑(3u)=6(4n)=4n(n−1)(n−2)(n−3):
Sn=n+7⋅2n(n−1)+6⋅3n(n−1)(n−2)+4n(n−1)(n−2)(n−3) =n+27n(n−1)+2n(n−1)(n−2)+4n(n−1)(n−2)(n−3)Putting over the common denominator 4 and collecting:
Sn=44n+14n(n−1)+8n(n−1)(n−2)+n(n−1)(n−2)(n−3)Expanding each term, 4n, 14n2−14n, 8n3−24n2+16n, n4−6n3+11n2−6n, the sum is
n4+2n3+n2=n2(n+1)2 Sn=[2n(n+1)]2Step 1. Function values.
| x | 0 | 0.125 | 0.25 | 0.375 | 0.5 | 0.625 | 0.75 | 0.875 | 1 |
|---|---|---|---|---|---|---|---|---|---|
| f(x)=1+x21 | 1.000000 | 0.984615 | 0.941176 | 0.876712 | 0.800000 | 0.719101 | 0.640000 | 0.566372 | 0.500000 |
Step 2. Trapezoidal rule, first column.
Tn=2h[f0+2f1+2f2+⋯+2fn−1+fn]At h=0.5, n=2:
T2=20.5[1+2(0.8)+0.5]=0.25(3.1)=0.775000At h=0.25, n=4:
T4=20.25[1+2(0.941176+0.8+0.640000)+0.5]=0.125(6.262352)=0.782794At h=0.125, n=8:
T8=20.125[1+2(0.984615+0.941176+0.876712+0.800000+0.719101+0.640000+0.566372)+0.5] =0.0625[1+2(5.527976)+0.5]=0.0625(12.555952)=0.784747Step 3. Richardson extrapolation. The trapezoid rule has O(h2) error, so each new column divides by 41−1=3:
Rk,j=Rk,j−1+4j−1Rk,j−1−Rk−1,j−1Step 4. The table.
Rk,00.7750000.7827940.784747Rk,10.7853920.785398Rk,20.7853985Row 2: 0.782794+30.782794−0.775000=0.782794+0.002598=0.785392 Row 3, column 1: 0.784747+30.784747−0.782794=0.784747+0.000651=0.785398 Row 3, column 2: 0.785398+150.785398−0.785392=0.785398+0.0000004=0.7853985
I≈0.7853985(trapezoid alone gives 0.784747)Step 1. Newton's divided difference form. Using the leading diagonal of the table above, 1,3,5,0,21:
f(x)=1+3x+5x(x−1)+0⋅x(x−1)(x−2)+21x(x−1)(x−2)(x−3)The third divided difference is zero, so that term vanishes entirely.
Step 2. Expand. Using x(x−1)(x−2)(x−3)=x4−6x3+11x2−6x:
f(x)=1+3x+5x2−5x+21(x4−6x3+11x2−6x) f(x)=2x4−3x3+221x2−5x+1Step 3. Verify all five points before differentiating anything.
| x | 2x4 | −3x3 | 221x2 | −5x | 1 | Total | Given | |
|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | ✓ |
| 1 | 0.5 | −3 | 10.5 | −5 | 1 | 4 | 4 | ✓ |
| 2 | 8 | −24 | 42 | −10 | 1 | 17 | 17 | ✓ |
| 3 | 40.5 | −81 | 94.5 | −15 | 1 | 40 | 40 | ✓ |
| 4 | 128 | −192 | 168 | −20 | 1 | 85 | 85 | ✓ |
All five points are reproduced exactly.
Step 4. Differentiate and evaluate.
f′(x)=2x3−9x2+21x−5 f′(4)=2(64)−9(16)+21(4)−5=128−144+84−5 =−16+84−5=68−5=63 f′(4)=63Definition. In Gaussian elimination, pivoting is the act of interchanging rows, or columns, so that the element chosen as the pivot (the next divisor) is as large as possible in magnitude, or at least not negligibly small.
Why it is needed. Every elimination step divides by the pivot. If the pivot happens to be 0 the step is impossible. If it is merely tiny, say 10−9, the multiplier aik/akk becomes enormous and the elimination floods the remaining rows with round off error.
Two kinds.
Scaled partial pivoting chooses k maximising maxj∣aij∣∣aik∣.
A third form. Complete pivoting searches the whole remaining submatrix and permutes both rows and columns. It is the most stable but costs more and scrambles the variable order, so its use is confined largely to research codes.
When pivoting cannot help. If a whole column of the remaining submatrix is zero, the matrix is singular and no rearrangement helps. Pivoting cannot create a nonzero pivot where none exists.
Pivoting reorders rows or columns so the divisor is as large as possible, avoiding a tiny pivot and its round offStep 1. Rearrange each equation to isolate its own variable.
x=620−y−z,y=46−x+z,z=57−x+yStep 2. Check the condition for convergence. Jacobi converges when the matrix is strictly diagonally dominant, that is when each diagonal entry exceeds the sum of the off-diagonal entries in its own row:
| Row | Diagonal | Off-diagonal sum | |
|---|---|---|---|
| 1 | 6 | 1 + 1 = 2 | 6 > 2 ✓ |
| 2 | 4 | 1 + 1 = 2 | 4 > 2 ✓ |
| 3 | 5 | 1 + 1 = 2 | 5 > 2 ✓ |
Convergence is guaranteed.
Step 3. Jacobi rule. Use only values from the previous iteration, never a value just computed:
x(k+1)=620−y(k)−z(k),y(k+1)=46−x(k)+z(k),z(k+1)=57−x(k)+y(k)Step 4. Iterate from x(0)=y(0)=z(0)=0.
| k | x | y | z |
|---|---|---|---|
| 0 | 0.000000 | 0.000000 | 0.000000 |
| 1 | 3.333333 | 1.500000 | 1.400000 |
| 2 | 2.850000 | 1.016667 | 1.033333 |
| 3 | 2.991667 | 1.045833 | 1.033333 |
| 4 | 2.986806 | 1.010417 | 1.010833 |
| 5 | 2.996458 | 1.006007 | 1.004722 |
| 6 | 2.998212 | 1.002066 | 1.001910 |
| 7 | 2.999337 | 1.000924 | 1.000771 |
| 8 | 2.999717 | 1.000358 | 1.000317 |
| 9 | 2.999887 | 1.000150 | 1.000128 |
| 10 | 2.999954 | 1.000060 | 1.000053 |
The errors fall by roughly a factor of 3 each pass, the expected rate for Jacobi on a diagonally dominant system.
x=3.000,y=1.000,z=1.000Check. Substituting into the original equations:
6(3)+1+1=20✓ 3+4(1)−1=6✓ 3−1+5(1)=7✓Step 1. Write the augmented matrix.
2131−2−1−135−1914Step 2. Eliminate x1 from rows 2 and 3.
Row 2: R2←R2−21R1
[1−21(2),−2−21,3−21(−1),9−21(−1)]=[0,−25,27,219]Row 3: R3←R3−23R1
[3−3,−1−23,5−23(−1),14−23(−1)]=[0,−25,213,231] 2001−25−25−127213−1219231Step 3. Eliminate x2 from row 3.
The multiplier is −5/2−5/2=1, so R3←R3−R2:
[0,0,213−27,231−219]=[0,0,3,6] 2001−250−1273−12196Step 4. Back substitution.
Row 3: 3x3=6⇒x3=2
Row 2: −25x2+27(2)=219, so
−25x2=219−7=219−214=25⇒x2=−5/25/2=−1Row 1: 2x1+(−1)−(2)=−1⇒2x1=2⇒x1=1
x1=1,x2=−1,x3=2Required check, by substitution into the original equations.
2x1+x2−x3=2(1)+(−1)−2=2−1−2=−1✓ x1−2x2+3x3=1−2(−1)+3(2)=1+2+6=9✓ 3x1−x2+5x3=3(1)−(−1)+5(2)=3+1+10=14✓All three residuals are exactly zero.
Definition. A system of linear equations is ill-conditioned when a small change in the input produces a disproportionately large change in the solution.
Measure. The condition number κ of the coefficient matrix is the ratio of the largest to the smallest relative error:
∥b∥∥δb∥∥x∥∥δx∥≤κ(A)Thus a relative error of ϵ in the data may become up to κϵ in the answer.
| κ | Behaviour |
|---|---|
| κ=1 | Perfectly conditioned, error passes through unchanged |
| κ≈10 | Mild amplification |
| κ≈106 | Loss of about six significant digits |
| κ>1016 | All precision lost; the matrix is numerically singular |
Causes.
Why it matters in engineering. The data itself has uncertainty, typically 10−4 relative from the instrument. If κ=108 then the answer carries a relative uncertainty of 104, which is useless, even though the computation ran to machine precision.
What to do about it. Row or column scaling to make the entries comparable, choosing better-conditioned variables, reformulating the physical problem, or using higher precision. Pivoting helps stability but does not change κ. Conditioning is a property of the problem, not of the algorithm.
ill-conditioned means small input errors produce large output errors; measured by κProposition. A declarative sentence that is unambiguously either true or false, with exactly one truth value. Nothing more is required: it need not be meaningful, need not be verifiable today, and carries no quantifier.
Traditional (ordinary) sentence. Any statement of natural language. The category is much wider, admitting sentences that have no truth value at all.
| Sentence | Proposition? | Reason |
|---|---|---|
| The transistor conducts | Yes | true or false |
| 2+2=4 | Yes | |
| Water boils at 100∘C at sea level | Yes | fact, though it needs a reference condition |
| Close the window | No | imperative, a command |
| Is the door open | No | interrogative, a question |
| Please hand me the tool | No | request |
| x+1>0 | No | depends on the unknown x |
| The present king of France is bald | No | presupposes a non-existent referent, no truth value |
| 1/0=3 | No | meaningless, division by zero |
The four tests for a proposition.
What propositions are not. A compound proposition is built from simple ones using ¬,∧,∨,→,↔. A predicate such as "x is prime" is not a proposition on its own, because x is free. Only after binding, "for every prime x, x>1", does it become one.
Why the distinction matters. Propositional logic can only reason over things with a definite truth value. A sentence like "close the window" has to be translated into one before any logical tool applies, and that translation step is where most real errors in control logic occur.
Setup. Fuzzy logic assigns each proposition a truth value in [0,1], where 0 is false and 1 is true. Fuzzy conjunction is defined by
T(A∧B)=min(T(A),T(B))Assign variables. Let
h=T(Fred is happy),j=T(John is happy),0≤h,j≤1Statement A: "Fred and John are happy." A conjunction of two, so
T(A)=min(h,j)Statement B: "Neither Fred nor John is happy." "Neither A nor B" expands to ¬A∧¬B, and fuzzy negation is T(¬P)=1−T(P):
T(B)=min(1−h,1−j)=1−max(h,j)Statement C: the conjunction A∧B. By the definition of fuzzy conjunction,
T(C)=min(T(A),T(B))=min(min(h,j),1−max(h,j))This is exactly what the question asserts, so the claim holds by the defining rule. Written out in full,
T(C)=min(h,j,1−h,1−j)Definition. A collection of operators is functionally complete if every other Boolean operator can be expressed using only those operators.
Goal. Build ∨ and → from ¬ and ∧ alone.
Step 1. Disjunction by De Morgan. ¬(p∧q)=¬p∨¬q, so
p∨q=¬(¬p∧¬q)Step 2. Implication. Since p→q≡¬p∨q,
p→q=¬p∨q=¬(¬(¬p)∧¬q)Step 3. Biconditional. p↔q≡(p→q)∧(q→p), so substituting step 2 into both places gives it in terms of ¬ and ∧.
Step 4. Verify both against the truth tables. Rows run p outer and q inner, each taking T then F.
| p | q | ¬p | ¬q | p∨q | ¬(¬p∧¬q) | p→q | ¬(¬(¬p)∧¬q) |
|---|---|---|---|---|---|---|---|
| F | F | T | T | F | ¬(T∧T)=F ✓ | T | ¬(F∧T)=T ✓ |
| F | T | T | F | T | ¬(T∧F)=T ✓ | T | ¬(F∧F)=T ✓ |
| T | F | F | T | T | ¬(F∧T)=T ✓ | F | ¬(T∧T)=F ✓ |
| T | T | F | F | T | ¬(F∧F)=T ✓ | T | ¬(T∧F)=T ✓ |
Every constructed column matches its target column in all four rows.
Step 5. Conclusion. The operators ¬ and ∧ generate ∨, →, ↔ and everything built from them, so the collection is functionally complete.
p∨q=¬(¬p∧¬q),p→q=¬(¬(¬p)∧¬q)Step 1. Define predicates. Let the universe of discourse be the set of all birds. Natural language opposites in Lewis Carroll's logic puzzles represent complementary predicates:
Step 2. Formalise premises and conclusion.
Step 3. Formal deduction via rules of inference. Let c be an arbitrary bird in the domain:
Since ¬Q(x) represents "small", the conclusion "Hummingbirds are small" follows logically.
The argument is VALID via Universal Instantiation, Contraposition, and Hypothetical SyllogismMethod. A knight's every statement is true. A knave's every statement is false. A spy is unconstrained. Each of A, B and C may be any of the three types, and the three types are all different, so there are only 3!=6 assignments to test.
Rule stated first. Nobody can truthfully say "I am the knave", because a knave is by definition not a knave. Nobody can falsely say "I am the knave" either, because that statement would be true for a knave. Therefore only a spy can say "I am the knave", and a knight or knave saying it is an immediate contradiction.
(i) A says "C is the Knave." B says "A is the Knight." C says "I am the spy."
Test all six assignments. The three statements are true when, respectively, C is the knave, A is the knight, and C is the spy.
| Assignment | A's statement | B's statement | C's statement | Verdict |
|---|---|---|---|---|
| A=K, B=N, C=S | false (C is a spy, not a knave) | true | true | A is a knight but lies. Out. |
| A=K, B=S, C=N | true | true | false | Consistent. |
| A=N, B=K, C=S | false | false | true | B is a knight but lies. Out. |
| A=N, B=S, C=K | false | false | false | C is a knight but lies. Out. |
| A=S, B=K, C=N | true | false | false | B is a knight but lies. Out. |
| A=S, B=N, C=K | false | true | false | C is a knight but lies. Out. |
Exactly one row survives, so the solution is unique:
(i) A = Knight, B = Spy, C = KnaveVerification. A, a knight, says C is the knave: true, since C is the knave. B, a spy, says A is the knight: true, and a spy may tell the truth. C, a knave, says "I am the spy": false, since C is the knave. All consistent.
(ii) A says "I am the Knave." B says "I am the Knave." C says "I am the Knave."
| Assignment | A's statement | B's statement | C's statement | Verdict |
|---|---|---|---|---|
| A=K, B=N, C=S | false | true | false | A is a knight but lies. Out. |
| A=K, B=S, C=N | false | false | true | A is a knight but lies. Out. |
| A=N, B=K, C=S | true | false | false | A is a knave but tells the truth. Out. |
| A=N, B=S, C=K | true | false | false | A is a knave but tells the truth. Out. |
| A=S, B=K, C=N | false | false | true | B is a knight but lies. Out. |
| A=S, B=N, C=K | false | true | true | B is a knave but tells the truth. Out. |
Every row is eliminated.
(ii) There is NO solutionReason, without the table. From the rule above, "I am the knave" can only be said by a spy. All three of A, B and C say it. Since exactly one of the three is a spy, at least two are knights or knaves, and each of those contradicts what they said. A puzzle in which every person utters a sentence only one of them may utter is a contradiction in three.
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.
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) FALSEWork with the residues, then reduce to 0≤c≤18.
(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)
Reduce the powers first 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.
Step 1. Binary expansion of the exponent.
644=512+128+4=(1010000100)2Step 2. Square repeatedly, 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=36Step 1. Ordinary Euclidean algorithm.
662=1×414+248 414=1×248+166 248=1×166+82 166=2×82+2 82=41×2+0The last nonzero remainder is 2, so gcd(414,662)=2.
Step 2. Extended part, back-substituting to find integers s,t with 414s+662t=2.
From the last division, 2=166−2×82.
Substitute 82=248−166:
2=166−2(248−166)=3×166−2×248Substitute 166=414−248:
2=3(414−248)−2×248=3×414−5×248Substitute 248=662−414:
2=3×414−5(662−414)=8×414−5×662Check.
8(414)−5(662)=3312−3310=2✓ gcd(414,662)=2,8(414)−5(662)=2Step 1. Write a=qb+r with q=⌊a/b⌋≥0 and r=amodb so 0≤r<b. Then a=qb+r.
Step 2. Reduce the power.
2a−1=2qb+r−1=2r(2qb)−1Step 3. Show 2b≡1(mod2b−1). This is immediate:
2b−1≡0(mod2b−1)⟹2b≡1(mod2b−1)Hence any positive power of 2b is also congruent to 1:
2qb=(2b)q≡1q=1(mod2b−1)Step 4. Substitute.
2a−1≡2r×1−1=2r−1(mod2b−1)Since r=amodb,
(2a−1)mod(2b−1)≡2amodb−1Step 5. The residue really is the least one. Since 0≤r<b we have 0≤2r−1<2b−1, so 2r−1 is the actual remainder and not merely a congruent value. This is what makes the statement an equality of remainders rather than only a congruence.
Fermat's little theorem. If p is prime and gcd(a,p)=1, then
ap−1≡1(modp)Equivalently ap≡a(modp) for every integer a, with no coprimality condition needed. A worked case: 22=4≡1(mod3), and 44=256≡1(mod5).
The CRT construction. For moduli n1,n2,…,nk that are pairwise coprime, put N=n1n2⋯nk and
Mi=niN,ui=Mi−1(modni)Then the solution to x≡ai(modni) for all i is
x=i=1∑kaiuiMi(modN)Direct evaluation using the CRT construction formula. Here a1=2,n1=3; a2=1,n2=4; a3=3,n3=5. The moduli are pairwise coprime, with N=3×4×5=60.
M1=360=20. We need u1≡M1−1(modn1), so 20u1≡1(mod3). Since 20≡2(mod3), 2u1≡1⟹u1=2.
M2=460=15. We need u2≡M2−1(modn2), so 15u2≡1(mod4). Since 15≡3(mod4), 3u2≡1⟹u2=3.
M3=560=12. We need u3≡M3−1(modn3), so 12u3≡1(mod5). Since 12≡2(mod5), 2u3≡1⟹u3=3.
Now evaluate the sum:
x=a1u1M1+a2u2M2+a3u3M3=2(2)(20)+1(3)(15)+3(3)(12) =80+45+108=233Reducing modulo N=60:
233=3(60)+53≡53(mod60)Alternative verification: combining two congruences at a time.
Combine the first two, x≡2(mod3) and x≡1(mod4). Write x=2+3k. Substituting into the second:
2+3k≡1(mod4)⟹3k≡−1≡3(mod4)Since 3−1≡3(mod4), k≡3×3=9≡1(mod4). Hence k=1+4m and
x=2+3(1+4m)=5+12mCheck: 5mod3=2 ✓ and 5mod4=1 ✓.
Now impose the third, x≡3(mod5):
5+12m≡3(mod5)⟹12m≡−2≡3(mod5)Since 12≡2(mod5) and 2−1≡3(mod5),
m≡3×3=9≡4(mod5)Take m=4:
x=5+12(4)=53 x≡53(mod60)Verify all three.
53mod3=2✓53mod4=1✓53mod5=3✓Since N=3⋅4⋅5=60, the complete solution set is x=53+60k for every integer k.
Setting up. A route via Detroit is fully described by one choice from Boston to Detroit and one choice from Detroit to Los Angeles. There is no other freedom, and the order is fixed by the geography: Boston first, Detroit second, Los Angeles third.
This is the product rule (multiplication principle):
number of routes=4×6 24 routesThe principle. If N objects are placed into k boxes and N>k, then at least one box holds at least two objects. The generalized form: if N>mk, then some box holds at least m+1 objects.
Real-world examples.
Birth months in a class. With 12 months, a class of 25 students guarantees that at least 3 share a birth month, since 25>2×12=24. Taking m=2, k=12 needs N=25.
Socks from a drawer. A drawer holds only black and white socks. Drawing 5 socks guarantees at least 3 of one colour, since 5>2×2=4.
Hash tables. Storing n keys in m buckets forces a collision once n>m. Keeping the load factor below 1, typically near 0.75, is what guarantees headroom before collisions become frequent.
Servers. A cluster with r racks and 2r+1 machines must place at least 3 machines in one rack.
Proof.
Step 1. Count the possible remainders. For any integer a, the division algorithm gives
a=qd+r,0≤r<dEvery integer therefore has exactly one of the residues 0,1,2,…,d−1. There are exactly d possible remainders.
Step 2. Identify the boxes. Take the d+1 integers and let each box be one of the d possible remainders, 0 through d−1. Place each integer in the box named by its remainder.
Step 3. Apply the pigeonhole principle. There are d+1 integers placed into d boxes, and d+1>d. By the pigeonhole principle, at least one box contains two or more integers.
Step 4. Conclude. Two integers a1,a2 share a box, so they share a remainder. Writing a1=q1d+r and a2=q2d+r, subtracting gives
a1−a2=(q1−q2)dhence d divides a1−a2, which is exactly the statement that the two have the same remainder on division by d.
Any d+1 integers include two congruent modulo d