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.
# A car braking hard from 108 km/hspeed = 108 km/h in m/s gives 30 m/sdeceleration = 6 m/s²braking distance = speed^2 / (2 * deceleration) gives 75 mstopping time = speed / deceleration gives 5 smass = 1200 kgkinetic energy = 0.5 * mass * speed^2 in kJ gives 540 kJbraking force = mass * deceleration gives 7,200 Nbraking force * braking distance in kJ gives 540 kJConverting 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.
# Pendulum measurements of greadings = [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.
# Roots of x^2 + 3x - 10 = 0solve(x^2 + 3x - 10 = 0, x, 0, 5) gives 2solve(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 = -1solve_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.
# Sum of the first 20 squares, two wayssum(k^2, k, 1, 20) gives 2,87020 * 21 * 41 / 6 gives 2,870# Slope of x^3 - 4x at x = 2derivative(x^3 - 4*x, x, 2) gives 8# Area under x^2 from 0 to 3integrate(x^2, x, 0, 3) gives 9# Ways to choose 3 people from 1010 choose 3 gives 120# Ways to line up 5 people5! gives 120sind(30) gives 0.5When 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 givingaandba value first. See Symbolic differentiation. - Check a circuit:
12 V * 2 Agives 24 W, and5000 mAh / 500 mAshows 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 sfgives 29.7 m/s. - Turn a period into a frequency:
1 / 0.02 s in Hzgives 50 Hz. - Save a formula you use often as a function:
ke(mass, speed) = 0.5 * mass * speed^2, thenke(1200 kg, 30 m/s) in kJ. See Your own functions.