TExcelTAD
Home › Basic Math & Pre-Algebra › Ratios and Rates

Ratios and Rates

A ratio compares two quantities, like 3 cups of flour to 2 cups of milk (3:23 : 2). A rate is a ratio of two different kinds of quantity, like 60 kilometres per hour or 144 frames per second. This lesson writes and simplifies ratios, splits amounts in a given ratio, computes unit rates, and meets the ratios programmers use every day: aspect ratios, frame rates and pixel densities.

Writing a ratio

A ratio of aa to bb can be written three ways:

a:ba to baba : b \qquad a \text{ to } b \qquad \frac{a}{b}

A bag has 12 red and 8 blue marbles. The ratio of red to blue is 12:812 : 8. The order matters: blue to red is 8:128 : 12. A ratio can also compare part to whole: red to all marbles is 12:2012 : 20.

Simplifying ratios

Like fractions, ratios simplify by dividing both sides by their greatest common factor:

12:8gcd⁡4→3:245:60gcd⁡15→3:41.5:2×2→3:4(clear decimals first)12:13×6→3:2(clear fractions with the LCD)\begin{aligned} 12 : 8 &\quad \gcd 4 && \to 3 : 2 \\ 45 : 60 &\quad \gcd 15 && \to 3 : 4 \\ 1.5 : 2 &\quad \times 2 && \to 3 : 4 && \text{(clear decimals first)} \\ \tfrac{1}{2} : \tfrac{1}{3} &\quad \times 6 && \to 3 : 2 && \text{(clear fractions with the LCD)} \end{aligned}

A ratio with three parts works the same way: 10:15:25→2:3:510 : 15 : 25 \to 2 : 3 : 5.

Splitting in a ratio

Share 150 in the ratio 2:3:52 : 3 : 5. There are 2+3+5=102 + 3 + 5 = 10 parts, so one part is 150÷10=15150 \div 10 = 15:

2×15=303×15=455×15=75check: 30+45+75=1502 \times 15 = 30 \qquad 3 \times 15 = 45 \qquad 5 \times 15 = 75 \qquad \text{check: } 30 + 45 + 75 = 150
python · try it yourself
from fractions import Fraction
import math

def simplify(*parts):
    g = math.gcd(*parts)
    return tuple(p // g for p in parts)

def split(total, *ratio):
    whole = sum(ratio)
    return [Fraction(total) * r / whole for r in ratio]

print(simplify(12, 8), simplify(45, 60), simplify(10, 15, 25))
print([str(x) for x in split(150, 2, 3, 5)])
print([str(x) for x in split(100, 1, 2)])        # exact thirds
(3, 2) (3, 4) (2, 3, 5)
['30', '45', '75']
['100/3', '200/3']

Rates and unit rates

A rate compares different units: 240 km in 3 hours, 18.00 for 4 kg. A unit rate has 1 in the denominator ("per one"):

240 km/3 h=80 km per hour (80 km/h)18.00/4 kg=4.50 per kg\begin{aligned} 240\ \text{km} / 3\ \text{h} &= 80\ \text{km per hour}\ (80\ \text{km/h}) \\ 18.00 / 4\ \text{kg} &= 4.50\ \text{per kg} \end{aligned}

Unit rates make comparison easy. Which is the better buy, 500 g for 3.40 or 750 g for 4.95?

3.40/500 g=0.0068 per g→0.68 per 100 g4.95/750 g=0.0066 per g→0.66 per 100 gthe bigger pack is cheaper per gram\begin{aligned} 3.40 / 500\ \text{g} &= 0.0068\ \text{per g} \to 0.68\ \text{per 100 g} \\ 4.95 / 750\ \text{g} &= 0.0066\ \text{per g} \to 0.66\ \text{per 100 g} && \text{the bigger pack is cheaper per gram} \end{aligned}

Ratios and rates in software

Aspect ratio is width:height\text{width} : \text{height}. A 16:916 : 9 video in a 1280-pixel-wide player must be 1280×916=7201280 \times \frac{9}{16} = 720 pixels tall.

Frame rate is frames per second, and frame time is its reciprocal, seconds per frame. Monitors and games quote both.

Pixel density (PPI, pixels per inch) is pixels along the diagonal divided by the diagonal in inches.

python · try it yourself
import math

# frame rate <-> frame time
for fps in [30, 60, 144, 240]:
    print(f"{fps:3} fps -> {1000 / fps:6.2f} ms per frame")

# height for a given width and aspect ratio
w, (aw, ah) = 1280, (16, 9)
print("height for 1280 at 16:9 =", w * ah // aw)

# pixel density of a 27-inch 2560x1440 monitor and a 6.1-inch 2532x1170 phone
for name, px_w, px_h, inches in [("monitor", 2560, 1440, 27), ("phone", 2532, 1170, 6.1)]:
    ppi = math.hypot(px_w, px_h) / inches
    print(f"{name}: {ppi:.0f} PPI")
 30 fps ->  33.33 ms per frame
 60 fps ->  16.67 ms per frame
144 fps ->   6.94 ms per frame
240 fps ->   4.17 ms per frame
height for 1280 at 16:9 = 720
monitor: 109 PPI
phone: 457 PPI

math.hypot computes the diagonal with the Pythagorean theorem.

More rates you will meet:

Rate Unit Where
bandwidth megabits per second networking, video streaming
throughput requests per second web servers, load tests
sample rate samples per second (Hz) audio: 44 100 or 48 000 Hz
tick rate updates per second game servers (e.g. 64 tick)
exchange rate currency A per currency B payment and travel apps

Note: Watch the direction of a rate. 0.92 EUR per USD and 1.087 USD per EUR describe the same exchange rate; one is the reciprocal of the other.

Exercises

Exercise 1: Simplify

Simplify 84:3684 : 36 and 2.5:42.5 : 4.

Answer

7:37 : 3 and 5:85 : 8

Solution
84:36gcd⁡12→7:32.5:4×2→5:8(gcd 1, done)\begin{aligned} 84 : 36 &\quad \gcd 12 && \to 7 : 3 \\ 2.5 : 4 &\quad \times 2 \to 5 : 8 && \text{(gcd 1, done)} \end{aligned}

Exercise 2: Share the prize

Three players share 360 coins in the ratio 1:3:51 : 3 : 5. How many coins does each get?

Answer

40, 120 and 200

Solution

1+3+5=91 + 3 + 5 = 9 parts; one part=360÷9=40\text{one part} = 360 \div 9 = 40. Shares: 40, 3×40=1203 \times 40 = 120, 5×40=2005 \times 40 = 200. Check: 40+120+200=36040 + 120 + 200 = 360.

Exercise 3: Better buy

Pack A: 6 batteries for 4.20. Pack B: 16 batteries for 10.40. Which is cheaper per battery?

Answer

Pack B: 0.65 per battery vs 0.70.

Solution

A: 4.20÷6=0.704.20 \div 6 = 0.70. B: 10.40÷16=0.6510.40 \div 16 = 0.65. B is cheaper per battery.

Exercise 4: Letterboxing

A 2.39:12.39 : 1 film is shown on a 1920×10801920 \times 1080 screen, filling the full width. Write Python that computes the film's height in pixels (rounded) and the height of each black bar above and below.

Answer

Film height 803 px; bars of about 138.5 px each (138 and 139 in practice).

Solution

Height=width÷aspect=1920÷2.39≈803.3\text{Height} = \text{width} \div \text{aspect} = 1920 \div 2.39 \approx 803.3, so 803 px. The leftover 1080−803=2771080 - 803 = 277 px is split into two bars.

python · try it yourself
width, height, aspect = 1920, 1080, 2.39
film_h = round(width / aspect)
bars = height - film_h
print("film height:", film_h, " bars:", bars // 2, "and", bars - bars // 2)
film height: 803  bars: 138 and 139

Test yourself

In a class of 14 girls and 21 boys, what is the ratio of girls to boys in simplest form?

  1. 3:23 : 2
  2. 2:32 : 3
  3. 14:3514 : 35
  4. 2:52 : 5

A game runs at 120 frames per second. How long is one frame?

  1. 8.33 ms
  2. 12 ms
  3. 0.12 s
  4. 120 ms

A 4:34 : 3 image is 900 pixels tall. How wide is it?

  1. 675
  2. 1200
  3. 1600
  4. 1080