Ran Wei/Maths Series
中文
Mathematical Foundations for Computer Science and AI — Ran Wei

Optional algebra refresher

Rebuild the arithmetic and algebra used throughout the series: fractions, signs, equations, powers, and graphs. Work through the examples until you can explain the operations.

6 hours4 sessions

By the end you can

  • Calculate with fractions, signs, and scientific notation.
  • Rearrange equations and inequalities while preserving their solutions.
  • Expand and factor simple polynomials.
  • Use powers, logarithms, coordinates, and slopes with their conditions.

Before you start

Whole-number arithmetic. Use the entry diagnostic to choose the sections you need; this refresher is optional.

Contents

Study plan

6 hours

Four optional sessions of 90 minutes including handwritten practice. Skip sections only after explaining their checks. Python orientation is a separate one-hour resource.

1

Choose the review you need

Use the entry diagnostic first. If the first five tasks are unfamiliar, work through this refresher. If only one operation is uncertain, study that section and its practice. The estimated six hours include writing your own calculations, drawing graphs, correcting mistakes, and explaining why each operation is allowed.

Work on paper before using a calculator. A numerical answer is useful, but the purpose is to recover the relationship that produces it. Keep a short error log: record the incorrect step, the rule it violated, and a corrected example. Revisit that example at the start of your next session.

2

Fractions signs and operation order

A fraction p/qp/q describes division by a nonzero denominator. Multiplying its numerator and denominator by the same nonzero value preserves the ratio: 1/2=2/41/2=2/4. To add fractions, express them using the same denominator; adding denominators does not perform the required operation.

Worked example
Subtract with a common denominator

3/4−2/3=9/12−8/12=1/123/4-2/3=9/12-8/12=1/12. The denominator twelve works because both four and three divide it. A useful check is the sign: 0.750.75 exceeds approximately 0.6670.667, so the result should be small and positive.

Multiplication gives (p/q)(r/s)=pr/(qs)(p/q)(r/s)=pr/(qs). Division by a nonzero fraction multiplies by its reciprocal: (3/4)/(2/3)=(3/4)(3/2)=9/8(3/4)/(2/3)=(3/4)(3/2)=9/8. The divisor cannot be zero. Cancel factors in products, rather than cancelling terms in sums: (2x)/(2y)=x/y(2x)/(2y)=x/y when y≠0y\ne0, but (x+2)/(y+2)(x+2)/(y+2) generally does not simplify to x/yx/y.

The negative of a negative value is positive. Subtracting a negative adds the corresponding positive amount: 5−(−2)=75-(-2)=7. Parentheses determine whether the minus belongs to a squared base: −32=−9-3^2=-9, but (−3)2=9(-3)^2=9. For several operations, handle parentheses first, then powers, then multiplication/division, then addition/subtraction. Operations of equal precedence are read in their appropriate order; add parentheses whenever a formula could be misread.

Check your understanding

Calculate 1/2+1/31/2+1/3 and 2−(−4)2-(-4). Why is (x+2)/2=x/2+1(x+2)/2=x/2+1, rather than xx?

Show answer

The results are 5/65/6 and 66. Dividing each numerator term by two gives x/2+2/2=x/2+1x/2+2/2=x/2+1. The numerator is a sum; deleting the two would not preserve it.

3

Ratios percentages and scientific notation

A percentage is a ratio per hundred. Twenty-five percent is 25/100=1/425/100=1/4. A percentage change compares a difference with the chosen starting value: increasing from eighty to one hundred gives (100−80)/80=25%(100-80)/80=25\%, while falling from one hundred to eighty is a 20%20\% decrease. The different denominators explain the difference.

Ratios need units and a reference. Three milliseconds per request multiplied by ten requests gives thirty milliseconds under a simple additive timing model. The same arithmetic does not establish a concurrent system’s elapsed time; the model tells us when adding durations is appropriate.

Scientific notation writes a nonzero value as a×10ka\times10^k, normally with 1≤∣a∣<101\le|a|<10. Thus 0.00032=3.2×10−40.00032=3.2\times10^{-4} and 45000=4.5×10445000=4.5\times10^4. When multiplying, multiply the leading factors and add the powers: (2×103)(3×10−2)=6×101=60(2\times10^3)(3\times10^{-2})=6\times10^1=60. This keeps small and large scales readable.

Check your understanding

Convert 0.00450.0045 to scientific notation. A value rises from fifty to sixty; what is the percentage increase?

Show answer

4.5×10−34.5\times10^{-3}; the increase is (60−50)/50=0.2=20%(60-50)/50=0.2=20\%. State which original value supplies the denominator.

4

Equations inequalities and reversible operations

Solving an equation means finding values that make both sides equal. Apply the same reversible operation to both sides to preserve its solutions. Adding or subtracting a fixed value is reversible. Multiplying or dividing by a nonzero fixed value is reversible. Dividing by an expression that might be zero needs a separate case; otherwise you may discard a valid solution.

Worked example
Solve and check a linear equation

From 3x+5=173x+5=17, subtract five to get 3x=123x=12, then divide by three to get x=4x=4. Substitute into the original: 3(4)+5=173(4)+5=17. Checking the original equation catches transcription and arithmetic errors.

For inequalities, adding the same value preserves the comparison direction. Multiplying or dividing by a positive value also preserves it, but a negative value reverses it. From −2x<6-2x<6, division by −2-2 gives x>−3x>-3. Check one included value such as zero, and the excluded boundary −3-3.

Squaring is not reversible on all reals: both two and minus two square to four. If a rearrangement squares both sides, verify any candidate in the original equation. For example, x=x−2\sqrt{x}=x-2 requires both x≥0x\ge0 and x−2≥0x-2\ge0; squaring alone can produce a candidate that violates these restrictions.

Check your understanding

Solve 2x−7=52x-7=5 and −3x≥9-3x\ge9. In x(x−1)=0x(x-1)=0, why can you not simply divide by xx?

Show answer

x=6x=6; x≤−3x\le-3. The product equation permits x=0x=0, so dividing by xx would remove that valid case. Its full solution set is {0,1}\{0,1\}.

5

Expansion factoring and polynomials

Distributivity is the rule a(b+c)=ab+aca(b+c)=ab+ac. Applying it to each term gives (x+2)(x−3)=x2−3x+2x−6=x2−x−6(x+2)(x-3)=x^2-3x+2x-6=x^2-x-6. Combine like terms only: xx and x2x^2 represent different powers and cannot be added into a single coefficient of xx.

Factoring reverses expansion. A common factor gives 3x+6=3(x+2)3x+6=3(x+2). The polynomial x2−x−6x^2-x-6 factors as (x−3)(x+2)(x-3)(x+2) because minus three and two have sum minus one and product minus six. Expand your factorisation to check it.

If a product of real numbers is zero, at least one factor is zero. Thus (x−3)(x+2)=0(x-3)(x+2)=0 has solutions x=3x=3 and x=−2x=-2. A factor can be cancelled in a fraction only where it is nonzero. The expression (x2−1)/(x−1)(x^2-1)/(x-1) agrees with x+1x+1 for x≠1x\ne1; it remains undefined at one unless a new function is deliberately defined there.

Check your understanding

Expand (x+1)2(x+1)^2. Explain why it is not x2+1x^2+1, using both algebra and x=1x=1.

Show answer

Expansion gives x2+2x+1x^2+2x+1. At one the original expression is four while x2+1x^2+1 is two; the missing cross term causes the discrepancy.

6

Powers logarithms and a trigonometry preview

For nonzero aa, a0=1a^0=1 and a−k=1/aka^{-k}=1/a^k. With positive bases, aras=ar+sa^r a^s=a^{r+s} and (ar)s=ars(a^r)^s=a^{rs}. Distinguish x2x^2 from 2x2^x: the variable occupies a different role. Real square roots require nonnegative inputs; a root symbol gives the nonnegative square root, so 9=3\sqrt9=3, while solving x2=9x^2=9 gives two answers.

For a>0a>0, a≠1a\ne1, and x>0x>0, log⁡ax\log_a x is the exponent that makes aa produce xx. Thus log⁡28=3\log_2 8=3 because 23=82^3=8. Solving 2x=82^x=8 gives x=3x=3. Logarithms turn positive products into sums; they do not generally distribute over addition. Module 01 explains these domains and identities in detail.

Trigonometry is a preview for later geometry and calculus. An angle in radians measures arc length divided by the circle’s radius. A half-turn is π\pi radians, or 180180 degrees. On the unit circle, an angle θ\theta gives coordinates (cos⁡θ,sin⁡θ)(\cos\theta,\sin\theta), satisfying cos⁡2θ+sin⁡2θ=1\cos^2\theta+\sin^2\theta=1. At zero the point is (1,0)(1,0); at π/2\pi/2 it is (0,1)(0,1). Python’s standard trigonometric functions use radians. No trigonometric calculation is required for Module 01’s labs.

Check your understanding

Calculate 2−32^{-3} and solve x2=9x^2=9. What is the real domain of ln⁡(x−2)\ln(x-2)?

Show answer

1/81/8; the equation has x=3x=3 and x=−3x=-3. The logarithm requires x−2>0x-2>0, hence x>2x>2.

7

Coordinates slopes and reading graphs

An ordered pair (x,y)(x,y) names a point: horizontal coordinate first, vertical second. A function graph places (x,f(x))(x,f(x)) for allowed inputs. To read a value, find the input on the horizontal axis and follow to the curve, then read the vertical coordinate. Check the axis units and displayed range before interpreting a shape.

The slope through points (x1,y1)(x_1,y_1) and (x2,y2)(x_2,y_2) with distinct horizontal coordinates is (y2−y1)/(x2−x1)(y_2-y_1)/(x_2-x_1). Through (1,2)(1,2) and (3,6)(3,6) it is (6−2)/(3−1)=2(6-2)/(3-1)=2. A corresponding line is y=2xy=2x. For y=2x+1y=2x+1, the slope is still two, but the vertical intercept is one.

Draw a line by calculating two or three points. For y=2x+1y=2x+1, use (0,1),(1,3),(2,5)(0,1),(1,3),(2,5). Draw the square using (−2,4),(−1,1),(0,0),(1,1),(2,4)(-2,4),(-1,1),(0,0),(1,1),(2,4); it is curved, so joining just two points with a straight line would misrepresent it. A vertical line has no finite slope under this formula because its horizontal difference is zero.

Check your understanding

Find the slope through (0,1)(0,1) and (2,5)(2,5). Does changing metres to centimetres on one axis change the numerical slope?

Show answer

The slope is (5−1)/(2−0)=2(5-1)/(2-0)=2. Changing units on one axis changes the numerical ratio; state the units before interpreting it physically.

8

Ten practice tasks

The first six tasks are hand calculations, the next two concern graphs, and the final two repair invalid manipulations. Rework missed tasks with new values until you can justify each step.

Exercise 1★★★calculation

Calculate 3/4−2/33/4-2/3 and (3/4)/(2/3)(3/4)/(2/3).

Show solution

9/12−8/12=1/129/12-8/12=1/12; multiplying by the reciprocal gives 9/89/8.

Exercise 2★★★calculation

Evaluate −32-3^2, (−3)2(-3)^2, and 5−(−2)5-(-2).

Show solution

−9,9,7-9,9,7; the parentheses determine whether the negative sign is squared.

Exercise 3★★★calculation

Solve 3x+5=173x+5=17 and check the solution.

Show solution

Subtract five, divide by three: x=4x=4; substituting gives seventeen.

Exercise 4★★★calculation

Expand (x+2)(x−3)(x+2)(x-3), then factor your result.

Show solution

x2−x−6=(x+2)(x−3)x^2-x-6=(x+2)(x-3). The cross terms are −3x+2x=−x-3x+2x=-x.

Exercise 5★★★calculation

Solve 2x=82^x=8 and express 0.000320.00032 in scientific notation.

Show solution

x=3x=3; 3.2×10−43.2\times10^{-4}. Moving the decimal four places left corresponds to a negative power of ten.

Exercise 6★★★calculation

Solve −2x<6-2x<6 and find the percentage increase from eighty to one hundred.

Show solution

x>−3x>-3, since dividing by a negative reverses the inequality. The increase is 20/80=25%20/80=25\%.

Exercise 7★★★calculation

Plot (1,2)(1,2) and (3,6)(3,6); find the slope and line equation.

Show solution

The slope is two and the line is y=2xy=2x; both points satisfy it.

Exercise 8★★★conceptual

Draw y=x2y=x^2 through five integer inputs from minus two through two. Read the value at zero and explain its symmetry.

Show solution

The points are (−2,4),(−1,1),(0,0),(1,1),(2,4)(-2,4),(-1,1),(0,0),(1,1),(2,4). The value at zero is zero. Opposite inputs square to the same value, giving symmetry about the vertical axis.

Exercise 9★★★conceptual

A solution of x(x−1)=0x(x-1)=0 divides by xx and concludes that only one is possible. Repair the argument.

Show solution

Consider x=0x=0 first; it is valid. For x≠0x\ne0, division gives x=1x=1. Together the solutions are zero and one.

Exercise 10★★★conceptual

A learner cancels x−1x-1 in (x2−1)/(x−1)(x^2-1)/(x-1) and evaluates the original expression at one as two. Repair the conclusion.

Show solution

Factor the numerator as (x−1)(x+1)(x-1)(x+1); cancellation is valid only for x≠1x\ne1. The original expression is undefined at one. The simplified expression describes equal values only on the original domain.

9

Readiness check

Repeat the first five diagnostic tasks without consulting their answers. Explain the denominator in fraction addition, the placement of a negative sign, each reversible equation step, the cross terms in an expansion, and the inverse relationship defining a logarithm. Then start Module 01.

For extra practice, use the single-variable calculus course’s preparation materials selectively; its later calculus is not required yet. The refresher’s worked examples and tasks are original.