TactivergeLite

Lite / Textbooks / The Mathematics of Machines / Chapter 1

1. Algebraic modelling

Version 1 · Technically checked (automated checks only) · 4 source lessons · Full interactive version

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.

Figure 1.1. Rearranging for an LED resistor (described in words)

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

Built from 4 School lessons. Each part is the lesson's own explanation.

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

Open the Lite 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

Open the Lite 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

Open the Lite 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

Open the Lite 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, in words

Figure 1.2 from Translate a formula into Python

Pick '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?).

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 × R

Choose 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?

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 out

Try 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.

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.

The interactive versions are in the full chapter.

Laboratory

These run in a browser on the full site (they need a faster connection). Simulations are simplified educational models.

Practice

Each question links to its Lite lesson, where your answer is checked on our server and a wrong answer gets a hint. Answers are never sent to your device.

  1. Which Python line correctly computes V_out = V_in·R2/(R1 + R2)?
    Answer it in “Translate a formula into Python”
  2. A robot drives 300 m in 100 s, then 100 m in 100 s. What is its average speed, in m/s?
    Answer it in “Translate a formula into Python”
  3. Someone writes power_w = voltage_v / current_a. What does a units check say?
    Answer it in “Translate a formula into Python”
  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?
    Answer it in “Rearrange the formula, then compute: an LED resistor”
  5. Rearrange V = I · R to find I.
    Answer it in “Rearrange the formula, then compute: an LED resistor”
  6. There are 6 V across a 1.5 kΩ resistor. What current flows, in milliamps?
    Answer it in “Ohm's law: V = I × R”
  7. 5 mA flows through a 2.2 kΩ resistor. What is the voltage across it, in volts?
    Answer it in “Ohm's law: V = I × R”
  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?
    Answer it in “Models are functions: input in, output out”

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)

Streaming video uses a lot of data. Everything you need is in the text.

Summary

Glossary

Ohm's law
For a resistor, the voltage across it equals the current through it multiplied by its resistance. Field Guide
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. Field Guide
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. Field Guide
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. Field Guide
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. 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

Write it up on paper or in your own notes. Lite never stores what you write.

References

Further reading from the lessons

← Contents2. Functions as models →