Skip to content
Tactiverge

Textbooks/The Mathematics of Machines/Chapter 1

1Algebraic modelling

Version 1 · Technically checked (automated checks only) · 4 source lessons · 8 practice items

Text
All chapters and search
  1. 1. Algebraic modelling
  2. 2. Functions as models
  3. 3. Trigonometry and periodic motion
  4. 4. Vectors
  5. 5. Matrices and transformations
  6. 6. Rates of change
  7. 7. Accumulation and integrals
  8. 8. Differential equations
  9. 9. Probability and uncertainty
  10. 10. Linear systems
  11. 11. Eigenvalues and stability

Introduction

Most engineering calculations start as a formula that has to be turned round. You know the supply voltage and the current an LED wants, and you need the resistor. This chapter treats a formula as a model: name the quantities and units, rearrange for the one you need, compute it carefully (in code if it helps) and check the answer is sensible.

+5 VRLED, Vf = 2 VI = 20 mAVs = I·R + VfR = (Vs − Vf) / IR = (5 − 2) / 0.02R = 150 Ω
Figure 1.1. Rearranging for an LED resistor. A 5 V supply, a resistor R and an LED in series. The steps: Vs = I·R + Vf, so R = (Vs − Vf) / I. With Vs = 5 V, Vf = 2 V and I = 0.020 A, R = 3 / 0.020 = 150 Ω.

Explanation

This chapter is built from 4 School lessons. Each part below is the lesson's own explanation; open the lesson for its predict-and-discover activities.

1.1 Translate a formula into Python

Two programs compute a voltage divider's output. One says 3.4 V, the other 2211 V. Which pair of brackets is missing?

Python's order of operations

  1. Brackets. 2. Powers ** (worked right to left). 3. Unary minus, so -3 ** 2 is -9. 4. *, /, //, % from left to right. 5. +, - from left to right. When in doubt, add brackets: they cost nothing and show your intent.

A translation recipe

  1. Name each quantity with its unit: mass_kg, speed_m_per_s. 2. Replace a fraction bar with / and wrap the whole top and bottom in brackets. 3. Write powers with **. 4. Run it with numbers you can check by hand.
mass_kg = 1.2
speed_m_per_s = 3
energy_j = 0.5 * mass_kg * speed_m_per_s ** 2
print(round(energy_j, 2))   # 5.4

Units check and estimate

For E = ½mv²: kg × (m/s)² = kg·m²/s² = J, so the formula is consistent. Estimate: ½ × 1 × 3² ≈ 4.5, close to 5.4. If an answer is out by a factor of 1000 or has the wrong unit, a conversion or bracket is missing.

Derivation: Average speed is total distance over total time
  1. A robot drives d₁ = 120 m in t₁ = 40 s, then d₂ = 80 m in t₂ = 60 s.

  2. Average speed means one steady speed that covers the same total distance in the same total time: v = (d₁ + d₂) / (t₁ + t₂).

  3. Substitute: v = (120 + 80) / (40 + 60) = 200 m / 100 s = 2.0 m/s.

  4. Averaging the two speeds gives (3.0 + 1.33) / 2 ≈ 2.17 m/s, which is wrong because the robot spends longer on the slow leg.

  5. In Python the brackets carry the fraction bar: (d1_m + d2_m) / (t1_s + t2_s). Without them, d1_m + d2_m / t1_s + t2_s gives 120 + 2 + 60 = 182.0, with meaningless units.

Common mix-ups

  • Python works out a line from left to right, whatever the operators.
    ✓ Precedence comes first: ** before * and /, which come before + and −. Left to right only applies within the same level.
  • Extra brackets are bad style.
    ✓ Brackets that show intent are good style in engineering code, especially around a whole numerator or denominator.

Open the full lesson: Translate a formula into Python →

1.2 Rearrange the formula, then compute: an LED resistor

An LED needs 20 mA from a 5 V supply. Ohm's law says R = V/I. Which V, and why does the answer come out 1000 times too small?

The calculator

v_supply = 5.0      # V
v_forward = 2.0     # V, from the LED datasheet
current_ma = 20     # mA, wanted LED current

current_a = current_ma / 1000
r_ohm = (v_supply - v_forward) / current_a
power_w = (v_supply - v_forward) * current_a
print(f"R = {r_ohm:.0f} ohm, P = {power_w:.3f} W")

Output: R = 150 ohm, P = 0.060 W

Convert first, in one place

Datasheets mix units: mA, kΩ, mV. Convert everything to base SI units (A, Ω, V) once, near the top, in a clearly named variable such as current_a. Then every formula below can be written exactly as it appears in a textbook.

Pick a real part and check it

Resistors come in standard values, such as 120, 150 and 180 Ω. If the calculation gives 140 Ω, choose the next value up (150 Ω), so the current is slightly lower, never higher. Then check the power against the resistor's rating. This lesson is calculation only: any real circuit is built in the circuit simulator first.

Derivation: From Ohm's law to the LED resistor formula
  1. Ohm's law for the resistor: V_R = I · R, with V_R in volts, I in amps and R in ohms.

  2. Divide both sides by I to make R the subject: R = V_R / I.

  3. The LED and the resistor are in series across the supply, so their voltages add: V_supply = V_forward + V_R, giving V_R = V_supply − V_forward.

  4. Substitute: R = (V_supply − V_forward) / I.

  5. Example: (5.0 V − 2.0 V) / 0.020 A = 3.0 / 0.020 = 150 Ω. Power in the resistor: P = V_R · I = 3.0 × 0.020 = 0.060 W, well under a common 0.25 W rating.

Common mix-ups

  • Use the supply voltage in R = V / I for an LED resistor.
    ✓ Use the voltage across the resistor, V_supply − V_forward.
  • Unit conversions can be done in your head while reading the code.
    ✓ Do them in code, once, in named variables, so every reader and every rerun gets them right.

Open the full lesson: Rearrange the formula, then compute: an LED resistor →

1.3 Ohm's law: V = I × R

Measure the current through a resistor at 1 V, 2 V and 3 V. One number connects all three readings. Can you find it before the graph does?

The law

For a resistor at a steady temperature, V = I × R. Know any two of voltage (V), current (A) and resistance (Ω) and you can find the third. A 220 Ω resistor with 20 mA through it has 0.02 × 220 = 4.4 V across it.

Units are where answers go wrong

Convert first: mA ÷ 1000 → A, kΩ × 1000 → Ω. A current of 5 mA through 2.2 kΩ is 0.005 A × 2200 Ω = 11 V. Then sanity-check: does the answer have the right size and unit?

Reading the graph

Plot current against voltage. For a resistor you get a straight line through the origin: that is what 'ohmic' means. The slope is I ÷ V = 1 ÷ R, so a steeper line means a smaller resistance.

Not everything is ohmic

A filament lamp's line curves over: as it heats, its resistance rises. An LED passes almost nothing below about 1.8–2 V and then the current shoots up. For these, V ÷ I still gives 'the resistance right now', but it changes from point to point.

Derivation: One law, three forms
  1. Start from the experimental finding: for a resistor, current is proportional to voltage, I ∝ V. The constant of proportionality is 1/R, so I = V ÷ R.

  2. Multiply both sides by R: V = I × R.

  3. Divide both sides of V = I × R by I: R = V ÷ I.

  4. Units: volts = amps × ohms. If I is in mA and R in kΩ, the factors of 1000 cancel (10⁻³ × 10³), so mA × kΩ gives volts directly: 5 mA × 2.2 kΩ = 11 V.

Common mix-ups

  • R = V ÷ I means resistance depends on the voltage you apply.
    ✓ For a resistor, R is fixed: change V and I changes in proportion, so V ÷ I stays the same. Only non-ohmic parts change.
  • Ohm's law works for every component.
    ✓ It describes ohmic components. Lamps, LEDs and diodes do not follow a straight line.

Open the full lesson: Ohm's law: V = I × R →

1.4 Models are functions: input in, output out

A robot must stop within 1 m of an obstacle. What's the fastest it may drive? One graph answers that instantly.

One input, one output

A function f takes an input x and gives exactly one output f(x). In engineering both have units: a spring with f(F) = 2.5F turns a load in newtons into an extension in millimetres. Writing f(x) = … makes the rule something you can test, plot and reuse, just like a Python function.

Shapes tell stories

Linear (straight line): equal input steps give equal output steps, like a spring. Inverse: doubling the input halves the output, like effort on a longer lever. Periodic: the output repeats, like an arm's tip height as it turns. Quadratic: the output grows faster and faster, like stopping distance with speed.

Reading backwards

A requirement is a line on the graph: 'stop within 1 m' is a horizontal line at d = 1. Inputs where the curve is below the line pass. For d = 0.2v + v²/4, that's speeds up to about 1.6 m/s. To solve a linear function backwards, undo its steps: if f(x) = 2x + 10 = 50, then x = (50 − 10) ÷ 2 = 20.

Common mix-ups

  • If the input doubles, the output doubles.
    ✓ Only for proportional (linear through zero) functions. Inverse, quadratic and periodic functions behave differently.
  • A graph is just a picture of a table.
    ✓ It also shows the shape, which tells you how sensitive the output is and where a requirement is met.

Open the full lesson: Models are functions: input in, output out →

Worked examples

Translate a formula into Python: example 1

Write F = C × 9/5 + 32 in Python and check it at 100 °C.

Solution

temp_f = temp_c * 9 / 5 + 32. Left to right: 100 × 9 = 900, / 5 = 180.0, + 32 = 212.0 °F, which is right for boiling water. temp_c * 9 / (5 + 32) would divide by 37 instead and give about 24.3.

Rearrange the formula, then compute: an LED resistor: example 1

A 12 V supply drives a white LED (3.0 V) at 15 mA. Find R and P.

Solution

V_R = 12 − 3.0 = 9.0 V. I = 15 / 1000 = 0.015 A. R = 9.0 / 0.015 = 600 Ω, so choose the next standard value up, such as 620 Ω. P = 9.0 × 0.015 = 0.135 W: under 0.25 W, but closer than you might like, so a 0.5 W part gives more margin.

Ohm's law: V = I × R: example 1

A 9 V battery is connected across a 450 Ω resistor. What current flows?

Solution

I = V ÷ R = 9 ÷ 450 = 0.02 A = 20 mA.

Ohm's law: V = I × R: example 2

A sensor has 3.3 V across it and draws 1.5 mA. What is its resistance?

Solution

R = V ÷ I = 3.3 ÷ 0.0015 = 2200 Ω (2.2 kΩ).

Models are functions: input in, output out: example 1

A 3D printer's print time is t(m) = 2m + 10 minutes for a part of mass m grams. How long for 25 g? Largest part in 90 minutes?

Solution

t(25) = 50 + 10 = 60 min. 2m + 10 = 90 gives m = 40 g.

Interactive figures

Figure 1.2 from Translate a formula into PythonPick 'Voltage divider' and step through each expression: in which step does the wrong one go astray? Then try 'Kinetic energy' (is 1 / 2 * m * v ** 2 right?) and 'Average speed' (why is averaging the two speeds wrong?).
Can't use the interactive? Read a description instead

The precedence explorer shows a formula, sliders for its inputs, and several Python expressions. For the chosen expression it lists every evaluation step. Example, voltage divider with 5 V, 1000 Ω, 2200 Ω: v_in * r2 / (r1 + r2) → 5 * 2200 / 3200 → 11000 / 3200 → 3.4375 (matches); v_in * r2 / r1 + r2 → 11000 / 1000 + 2200 → 11.0 + 2200 → 2211.0 (does not match).

Interactive figure (online). Description: The precedence explorer shows a formula, sliders for its inputs, and several Python expressions. For the chosen expression it lists every evaluation step. Example, voltage divider with 5 V, 1000 Ω, 2200 Ω: v_in * r2 / (r1 + r2) → 5 * 2200 / 3200 → 11000 / 3200 → 3.4375 (matches); v_in * r2 / r1 + r2 → 11000 / 1000 + 2200 → 11.0 + 2200 → 2211.0 (does not match).

Figure 1.3 from Ohm's law: V = I × RChoose the 220 Ω resistor. Record points at 1 V, 2 V, 4 V and 6 V and check that V ÷ I is the same each time. Do the same for the 100 Ω resistor: which line is steeper? Then try the filament lamp and the LED and record three points each. What is different about their V ÷ I?
Can't use the interactive? Read a description instead

The V–I plotter shows current (0 to 60 mA) against voltage (0 to 6 V). The 100, 220 and 470 ohm resistors give straight lines through the origin; the 100 ohm line is steepest. The filament lamp's curve bends over as its resistance rises. The LED passes almost no current below about 1.8 V, then rises steeply. Recorded points are listed in a table with V ÷ I for each.

Interactive figure (online). Description: The V–I plotter shows current (0 to 60 mA) against voltage (0 to 6 V). The 100, 220 and 470 ohm resistors give straight lines through the origin; the 100 ohm line is steepest. The filament lamp's curve bends over as its resistance rises. The LED passes almost no current below about 1.8 V, then rises steeply. Recorded points are listed in a table with V ÷ I for each.

Figure 1.4 from Models are functions: input in, output outTry each example. Move the input slider and read the output; then move the requirement line and read off which inputs pass. For the stopping-distance example, find the top speed that still stops within 1 m.
Can't use the interactive? Read a description instead

The function grapher offers four examples: spring extension (linear), lever effort (inverse), arm tip height (periodic) and stopping distance (quadratic). A slider sets the input and a point marks it on the curve; another slider sets a requirement line. The readout gives the output and the range of inputs that meet the requirement, and a table lists five input–output pairs.

Interactive figure (online). Description: The function grapher offers four examples: spring extension (linear), lever effort (inverse), arm tip height (periodic) and stopping distance (quadratic). A slider sets the input and a point marks it on the curve; another slider sets a requirement line. The readout gives the output and the range of inputs that meet the requirement, and a table lists five input–output pairs.

Laboratory

Everything runs in your browser. No kit, nothing mains-powered. Simulations are simplified educational models.

  • Simulation OS experiment

    Simulation OS: LED current limiting

    Predict the current for three resistor values with your rearranged formula, then check each against the model.

    Open Simulation OS: LED current limiting →
  • Equation Lab exploration

    Equation Lab: Functions

    Fit a straight line to a linear sensor and read the gradient with its units.

    Open Equation Lab: Functions →
  • Studio

    Code Lab

    Write a function that returns the LED resistor for any supply, forward voltage and current, and test it on the 5 V case.

    Open Code Lab →

Guided practice

Answers are checked on the server; wrong answers get a hint and another try. Signed in, solved items also count towards the source lesson.

Practice 1

Which Python line correctly computes V_out = V_in·R2/(R1 + R2)?

Practice 2

A robot drives 300 m in 100 s, then 100 m in 100 s. What is its average speed, in m/s?

m/s

Practice 3

Someone writes power_w = voltage_v / current_a. What does a units check say?

Practice 4 · a fresh version every time

An LED with a forward voltage of 1.8 V should carry 15 mA from a 9 V supply. Using r_ohm = (v_supply - v_forward) / (current_ma / 1000), what resistance is needed, in ohms?

Ω

Practice 5

Rearrange V = I · R to find I.

Practice 6

There are 6 V across a 1.5 kΩ resistor. What current flows, in milliamps?

mA

Practice 7

5 mA flows through a 2.2 kΩ resistor. What is the voltage across it, in volts?

V

Practice 8

A spring's extension is e(F) = 2.5·F mm, with F in newtons. What is the extension for a 12 N load, in mm?

mm
  1. Which Python line correctly computes V_out = V_in·R2/(R1 + R2)?
    • v_out = v_in * r2 / r1 + r2
    • v_out = v_in * r2 / (r1 + r2)
    • v_out = (v_in * r2 / r1) + r2
  2. A robot drives 300 m in 100 s, then 100 m in 100 s. What is its average speed, in m/s? (m/s)
  3. Someone writes power_w = voltage_v / current_a. What does a units check say?
    • Fine: V/A is watts
    • Wrong: V/A is ohms; power is V × A
    • Fine if the numbers are small
  4. An LED with a forward voltage of 1.8 V should carry 15 mA from a 9 V supply. Using r_ohm = (v_supply - v_forward) / (current_ma / 1000), what resistance is needed, in ohms? (Ω)
  5. Rearrange V = I · R to find I.
    • I = V · R
    • I = V / R
    • I = R / V
  6. There are 6 V across a 1.5 kΩ resistor. What current flows, in milliamps? (mA)
  7. 5 mA flows through a 2.2 kΩ resistor. What is the voltage across it, in volts? (V)
  8. A spring's extension is e(F) = 2.5·F mm, with F in newtons. What is the extension for a 12 N load, in mm? (mm)

Engineering applications

  • Choosing parts

    Rearranged formulas pick resistors, gear ratios and battery sizes. The computed value is then rounded to a part that exists, and the formula is run again forwards to check the rounded part still works.

  • Unit bugs

    Writing 20 instead of 0.020 for a current in amperes makes the resistor a thousand times too small. Converting every quantity to SI units in one place, before calculating, prevents a whole class of mistakes.

Watch

Optional verified videos. Nothing loads from YouTube until you press play.

A calm walkthrough of how voltage, current and resistance relate, with simple worked examples.

12 min 17 s · captions on YouTube · source

Nothing loads from YouTube until you press play.

Defines a function as a rule that gives exactly one output for each input, the idea behind every simulation model.

Length: see YouTube · captions on YouTube · source

Nothing loads from YouTube until you press play.

  • Ohm's law | Physics | Khan Academy (Khan Academy)
  • What is a function? | Functions and their graphs | Algebra II | Khan Academy (Khan Academy)

Chapter summary

  • A formula is a model: each symbol is a quantity with a unit and a meaning.
  • Rearranging means doing the same operation to both sides until the unknown stands alone.
  • Convert to SI units first, compute, then check the size of the answer with an estimate.
  • A model is a function: one input gives one output, and its graph shows how the output responds.

Glossary

Ohm's law
For a resistor, the voltage across it equals the current through it multiplied by its resistance.
LED current-limiting resistor
An LED needs a series resistor to set its current, chosen so that the supply voltage minus the LED's forward voltage, divided by the resistance, gives the desired current.
SI prefixes and unit conversion
SI prefixes are powers of ten written in front of a unit symbol, such as k for 10^3 and m for 10^-3, so that very large and very small quantities stay readable.
Gradient of a straight line
The gradient of a straight line is the change in y divided by the change in x between any two points on it; in y = mx + c it is m, and c is where the line crosses the y-axis.
Hooke's law (springs)
For a spring within its elastic limit, the force needed to stretch or compress it is proportional to the change in length: F = k × x.

Definitions from the Field Guide.

Project: A resistor calculator you can trust

Write a small program that chooses an LED resistor for any supply between 3 V and 12 V. It must convert units in one place, round up to a standard resistor value of your choice, and report the resulting current and the resistor's power.

Deliverables

  • The rearranged formula with units
  • The program with at least three test cases
  • A note on what happens if the supply is below the LED's forward voltage

Keep your work in your Engineering Journal; it stays private unless you choose to share it.

References

  • Jay Abramson (2015). Algebra and Trigonometry. OpenStax. Link ↗
  • Python Software Foundation. The Python Language Reference: Operator precedence. Python Software Foundation. Link ↗
  • K. A. Stroud and Dexter J. Booth (2013). Engineering Mathematics, 7th edition. Palgrave Macmillan.

Further reading from the source lessons

Publication record

Version
1
Status
Technically checked (automated checks only)
Technical review
Automated checks only, last run 2026-11-29. No human, educator or mentor review is claimed.src/content/textbooks/textbooks.test.ts: schema, every lesson, diagram, practice item, video, Field Guide entry, lab and reference resolves; figure numbers recomputed; no practice answers in client payloads.
Written by
Compiled and written by the Tactiverge team with AI assistance, from Tactiverge School lessons that were themselves written with AI assistance.
Licence
All rights reserved by the founders unless a licence is approved.
Corrections
None recorded yet.Spotted a mistake? Use “Report a problem” on any chapter, or see the corrections page.