SigmaField
Mathematical Foundations for Quant Finance
0 of 256 lessons

Level 0, Orientation and fluency 0.3 Algebra fluency Lesson 1 of 5

ConceptLesson 0.3.1 in Level 0, Orientation and fluency. About 15 minutes.

Fractions, percentages and order of operations

Order of operations

An expression like 2+3×42 + 3 \times 4 could mean 20 or 14, depending on which operation you do first. Maths and Python agree on one order, so it always means 14.

Rule: Order of operations

brackets  →  powers→  × ÷  →  + −\begin{gathered} \text{brackets} \;\to\; \text{powers} \\ \to\; \times\ \div \;\to\; +\ - \end{gathered}

Work out brackets first, then powers. Then multiply and divide, from left to right. Last, add and subtract, from left to right.

ExpressionValueWhy
2+3×42 + 3 \times 414multiply before adding
(2+3)×4(2 + 3) \times 420brackets first
2×322 \times 3^218the power applies to the 3 only
12÷4÷312 \div 4 \div 31divide left to right: 3÷33 \div 3
−32-3^2−9-9the power comes before the minus sign

A fraction bar groups everything above it and everything below it, as if in brackets. So 6+42=5\dfrac{6 + 4}{2} = 5, and in code that is (6 + 4) / 2. Leave out the brackets and Python works out 6 + 4 / 2 = 8.

Try it

Python follows the same order. Run the cell and match each line to the table. Division always gives a decimal, so 12÷4÷312 \div 4 \div 3 prints as 1.0.

The last two lines show why a fraction typed into code needs brackets around its top.

⌘/Ctrl + Enter runs the cell

Fractions

A fraction ab\frac{a}{b} is aa divided by bb. The top is the numerator and the bottom the denominator. Multiplying and dividing are the easy cases.

Rule: Multiplying and dividing fractions

ab×cd=acbdab÷cd=ab×dc\begin{gathered} \frac{a}{b} \times \frac{c}{d} = \frac{ac}{bd} \\ \frac{a}{b} \div \frac{c}{d} = \frac{a}{b} \times \frac{d}{c} \end{gathered}

Multiply tops together and bottoms together. To divide, flip the second fraction and multiply. For example, 23÷45=23×54=1012=56\frac{2}{3} \div \frac{4}{5} = \frac{2}{3} \times \frac{5}{4} = \frac{10}{12} = \frac{5}{6}.

To add, the bottoms must match first. Rewrite each fraction over a common denominator, then add the tops. For 14+16\frac{1}{4} + \frac{1}{6}, both 4 and 6 go into 12:

14+16=312+212=512\frac{1}{4} + \frac{1}{6} = \frac{3}{12} + \frac{2}{12} = \frac{5}{12}

Rule: Adding fractions

ab+cd=ad+bcbd\frac{a}{b} + \frac{c}{d} = \frac{ad + bc}{bd}

Bring both fractions over the same bottom, then add the tops. Simplify at the end by dividing top and bottom by any common factor: 1012=56\frac{10}{12} = \frac{5}{6}.

Try it

Ordinary Python numbers are decimals with a tiny rounding error, so 0.1 + 0.2 is not exactly 0.3.

Fraction from the standard library keeps fractions exact and simplifies them for you. It is a handy answer-checker.

⌘/Ctrl + Enter runs the cell

Percentages

Percent means "per hundred", so 7% is 7100=0.07\frac{7}{100} = 0.07. Turn a percentage into a decimal before you calculate: 7% of 250 is 0.07×250=17.50.07 \times 250 = 17.5.

The change from an old value to a new one is usually given as a percentage of the old value.

Rule: Percentage change

change=new−oldold\text{change} = \frac{\text{new} - \text{old}}{\text{old}}

From 80 to 92 is a change of 92−8080=0.15\frac{92 - 80}{80} = 0.15, a rise of 15%. Always divide by the value you started from.

Growing by a percentage pp multiplies by 1+p1 + p, and falling by pp multiplies by 1−p1 - p. So a rise of 25% multiplies by 1.25, and a fall of 20% multiplies by 0.80.

Rule: Undoing a percentage rise

new=old×(1+p)old=new1+p\begin{gathered} \text{new} = \text{old} \times (1 + p) \\ \text{old} = \frac{\text{new}}{1 + p} \end{gathered}

Here pp is the rise as a decimal. To undo it, divide by 1+p1 + p. Do not take pp off the new value. After a 20% rise a value is 120. It started at 120/1.2=100120 / 1.2 = 100, not 120×0.8=96120 \times 0.8 = 96.

Try it

The cell works through the examples. A rise of 25% followed by a fall of 20% lands back where it started, because 1.25×0.8=11.25 \times 0.8 = 1.

Percentage changes are not symmetric: 80 to 92 is +15%, but 92 back to 80 is about −13.04%.

⌘/Ctrl + Enter runs the cell

Percent or percentage points?

If a rate moves from 4% to 5%, it rose by 1 percentage point: the plain difference, 5%−4%5\% - 4\%. As a percentage change it rose by 25%, because 0.05−0.040.04=0.25\frac{0.05 - 0.04}{0.04} = 0.25. Both statements are true, and people mix them up constantly. Say which one you mean.

Common mistakes

Try it

  1. Fractions do not add top-plus-top over bottom-plus-bottom. 12+13=56\frac{1}{2} + \frac{1}{3} = \frac{5}{6}, not 25\frac{2}{5}.
  2. Undo a rise by dividing. 120 after a 20% rise came from 100, not 96.
  3. Divide by the old value. A percentage change is measured against where you started.
  4. Bracket the top of a fraction in code. 6+42\frac{6 + 4}{2} is (6 + 4) / 2.
⌘/Ctrl + Enter runs the cell

Fractions, percentages and order of operations

0 of 8 correct

  1. 1.
  2. 2.
  3. 3.
  4. 4.
  5. 5.
  6. 6.
  7. 7.
  8. 8.
How to type answers
  • Powers with ^: x^7, 2^(1/3), a^-2.
  • Multiply with * or by writing side by side: 3x^2, 2(x+1).
  • ln(x) is the natural log, log(x, 2) is log base 2, e is Euler's number, sqrt(x) is a square root.
  • sin(x), cos(x) and tan(x) take radians; write pi for π and sin(x)^2 for sin²x.
  • Your first answer to each question is saved: it counts towards your score and brings the question back for review.
  • Exact answers like ln(20)/ln(3) are best. Decimals need about 4 significant figures.

Summary card

  • Order: brackets, powers, then × ÷\times\ \div left to right, then + −+\ - left to right. A fraction bar brackets its top and its bottom.
  • ab×cd=acbd\frac{a}{b} \times \frac{c}{d} = \frac{ac}{bd}; to divide, flip and multiply; to add, use a common denominator.
  • Fraction from fractions gives exact answers in Python.
  • Percentage change is (new−old)/old(\text{new} - \text{old}) / \text{old}. A rise of pp multiplies by 1+p1 + p; undo it by dividing by 1+p1 + p.
  • Percentage points are a plain difference of two rates; a percentage change is relative.

Free further reading

Optional. This lesson covers what you need; these add more examples and practice. All are free to read.