Skip to content
Varlig Guide
Varlig home

Study and science

Check homework and lab work with units that carry through every step, run statistics on your results and solve equations that are awkward to rearrange by hand. When the units in an answer come out wrong, you know to look again at the formula.

Physics with units

Give every quantity its unit and let Varlig keep track. Kilometres per hour, metres per second squared and kilograms combine into the right unit for each answer.

calc
# A car braking hard from 108 km/h
speed = 108 km/h in m/s gives 30 m/s
deceleration = 6 m/s²
braking distance = speed^2 / (2 * deceleration) gives 75 m
stopping time = speed / deceleration gives 5 s
mass = 1200 kg
kinetic energy = 0.5 * mass * speed^2 in kJ gives 540 kJ
braking force = mass * deceleration gives 7,200 N
braking force * braking distance in kJ gives 540 kJ

Converting the speed to metres per second first keeps every later answer in SI units, and a force times a distance comes out as work, so the last two lines confirm that the brakes remove all the kinetic energy. If you multiply where the formula should divide, the answer shows a tangled unit such as (m/s)²·m/s² instead of metres, a quick sign to check your working. See Arithmetic with units and Powers and roots.

Statistics on lab results

Put repeated measurements in a list to get the mean, the spread and how far you are from the accepted value.

calc
# Pendulum measurements of g
readings = [9.74 m/s², 9.86 m/s², 9.79 m/s², 9.83 m/s², 9.88 m/s²]
measured = average(readings) gives 9.82 m/s²
spread = stddev(readings)
spread to 2 sf gives 0.056 m/s²
Standard error: spread / sqrt(count(readings)) to 2 sf gives 0.025 m/s²
accepted = 9.81 m/s²
Difference: (measured - accepted) / accepted as % to 2 dp gives 0.1%

average and stddev keep the units of your readings. stddev is the sample standard deviation, the usual choice for repeated measurements. A label before the colon says what each line is, and to 2 sf rounds any line to significant figures, whether it’s a name, a formula or a function’s answer. to 2 dp rounds to decimal places instead. See Summary statistics, Spread and Significant figures.

Solving equations

Give solve an equation, the unknown and a range to search. For simultaneous linear equations, use solve_system.

calc
# Roots of x^2 + 3x - 10 = 0
solve(x^2 + 3x - 10 = 0, x, 0, 5) gives 2
solve(x^2 + 3x - 10 = 0, x, -10, 0) gives -5
# A stone dropped from 45 m: when does it land?
solve(4.9t^2 = 45, t, 0, 10) to 2 dp gives 3.03
# 2x + 3y = 13 and x - y = -1
solve_system([[2, 3], [1, -1]], [13, -1]) gives [2, 3]

solve finds one root between the two limits, so choose limits either side of the root you want. Write the equation the way it looks on paper: 4.9t^2 squares t before multiplying. solve_system takes the coefficients row by row and gives x and y in order. See Find one numerical root and Solve a linear system.

Quick maths checks

Check a formula against a direct calculation, or confirm a derivative or an integral before you hand in your work.

calc
# Sum of the first 20 squares, two ways
sum(k^2, k, 1, 20) gives 2,870
20 * 21 * 41 / 6 gives 2,870
# Slope of x^3 - 4x at x = 2
derivative(x^3 - 4*x, x, 2) gives 8
# Area under x^2 from 0 to 3
integrate(x^2, x, 0, 3) gives 9
# Ways to choose 3 people from 10
10 choose 3 gives 120
# Ways to line up 5 people
5! gives 120
sind(30) gives 0.5

When the direct sum and the formula agree, you can trust the formula for bigger numbers. derivative with a point gives the slope there, and integrate gives the area between two limits. See Finite sums and products, Numerical differentiation and Definite integration.

Make it your own

  • Turn test marks out of 40 into percentages in one line: [34, 29, 38] / 40 * 100.
  • Differentiate a formula with constants in it, such as differentiate(a*x^2 + b*x, x), without giving a and b a value first. See Symbolic differentiation.
  • Check a circuit: 12 V * 2 A gives 24 W, and 5000 mAh / 500 mA shows a battery lasts 10 hours.
  • Find how fast a stone dropped from 45 m lands: sqrt(2 * 9.81 m/s² * 45 m) to 3 sf gives 29.7 m/s.
  • Turn a period into a frequency: 1 / 0.02 s in Hz gives 50 Hz.
  • Save a formula you use often as a function: ke(mass, speed) = 0.5 * mass * speed^2, then ke(1200 kg, 30 m/s) in kJ. See Your own functions.