Direct and Inverse Variation
Two quantities vary directly when one is always a fixed multiple of the other (double one, the other doubles). They vary inversely when their product stays fixed (double one, the other halves). This lesson writes both relationships as formulas, finds the constant from data, draws the two graphs, and shows where each appears in programs.
Direct variation
varies directly with (or " is proportional to ") when
Equivalently, the ratio is the same for every pair: . That makes every pair of values a proportion.
Example. A video streams at 5 MB per minute. Data used varies directly with time : . Ten minutes use 50 MB, twenty minutes 100 MB.
Properties:
- If is multiplied by some number, is multiplied by the same number.
- gives : the graph is a straight line through the origin.
- is the slope of that line.
Inverse variation
varies inversely with when
The product stays the same.
Example. A 600 km trip. Travel time varies inversely with speed : . At 60 km/h it takes 10 h, at 120 km/h 5 h, at 100 km/h 6 h. Every pair multiplies to 600.
Properties:
- If is multiplied by some number, is divided by it.
- can never be 0, and never reaches 0; the graph is a curve (a hyperbola) that hugs both axes.
Finding k from data
Given a table, test both: if is constant, it is direct; if is constant, it is inverse.
from fractions import Fraction as F
tables = {
"A": [(2, 7), (4, 14), (10, 35)],
"B": [(2, 30), (3, 20), (12, 5)],
"C": [(1, 3), (2, 5), (3, 7)],
}
for name, pairs in tables.items():
ratios = {F(y, x) for x, y in pairs}
products = {x * y for x, y in pairs}
if len(ratios) == 1:
print(name, "direct, k =", ratios.pop())
elif len(products) == 1:
print(name, "inverse, k =", products.pop())
else:
print(name, "neither (ratios", sorted(ratios), ")")A direct, k = 7/2
B inverse, k = 60
C neither (ratios [Fraction(7, 3), Fraction(5, 2), Fraction(3, 1)] )
Table C is : a straight line, but it does not pass through the origin, so it is not direct variation. You will study lines like that in The Coordinate Plane and in Algebra.
The two graphs
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0.5, 10, 200)
plt.figure(figsize=(6, 4))
line_x = np.array([0, 10])
plt.plot(line_x, 2 * line_x, label="direct: y = 2x")
plt.plot(x, 12 / x, label="inverse: y = 12/x")
plt.xlim(0, 10)
plt.ylim(0, 20)
plt.xlabel("x")
plt.ylabel("y")
plt.grid(alpha=0.3)
plt.legend()
plt.title("Direct vs inverse variation")
for xv in [1, 2, 3, 4, 6]:
print(f"x = {xv}: direct y = {2 * xv:2}, inverse y = {12 / xv:4.1f}")x = 1: direct y = 2, inverse y = 12.0
x = 2: direct y = 4, inverse y = 6.0
x = 3: direct y = 6, inverse y = 4.0
x = 4: direct y = 8, inverse y = 3.0
x = 6: direct y = 12, inverse y = 2.0
The table shows the pattern: from to the direct value doubles and the inverse value halves. On the graph, the straight line climbs steadily from the origin; the curve falls fast at first and then flattens out, never touching the axes.
Variation with powers
The same idea works with powers of :
| Relationship | Formula | Double and … |
|---|---|---|
| direct | doubles () | |
| direct with the square | quadruples () | |
| inverse | halves () | |
| inverse square | quarters () |
The area of a circle varies directly with the square of its radius (). The brightness of a light, the loudness of a sound and gravity all follow an inverse-square law: twice as far away, a quarter as strong.
In software
- Direct: cost scales with usage (), render time with pixel count, file size with recording length. Doubling a texture's width and height quadruples its memory (direct with the square).
- Inverse: ; (ideal case); bits per symbol vs symbols per second at a fixed bandwidth.
- Inverse square in games: sound attenuation and light falloff often use (clamped near 0 so it does not blow up).
def falloff(distance, k=100.0, min_d=1.0):
d = max(distance, min_d) # avoid dividing by ~0
return k / d**2
for d in [0.2, 1, 2, 4, 8]:
print(f"distance {d:>3}: intensity {falloff(d):7.3f}")distance 0.2: intensity 100.000
distance 1: intensity 100.000
distance 2: intensity 25.000
distance 4: intensity 6.250
distance 8: intensity 1.562
Each doubling of distance divides the intensity by 4. (The last value is 1.5625, shown with three decimals.)
Exercises
Exercise 1: Direct
varies directly with , and when . Find and when .
Answer
(),
Solution
Exercise 2: Inverse
8 workers can paint a fence in 6 hours. Assuming time varies inversely with the number of workers, how long would 12 workers take?
Answer
4 hours
Solution
Exercise 3: Which kind?
Classify: (a) the cost of concert tickets at 35 each; (b) the number of equal slices when a cake is cut into pieces of width ; (c) a taxi fare of 3.00 plus 2.00 per km.
Answer
(a) direct, (b) inverse, (c) neither.
Solution
(a) , a fixed multiple: direct with . (b) , a fixed product: inverse. (c) ; at the fare is 3, not 0, so it is a line that misses the origin: neither.
Exercise 4: Texture memory
A texture uses 1 MiB. Memory varies directly with the number of pixels. Write Python that prints the memory of square textures with sides 256, 1024, 2048 and 4096, and say how memory changes when the side doubles.
Answer
0.25, 4, 16 and 64 MiB; doubling the side multiplies memory by 4.
Solution
, so with MiB per pixel.
k = 1 / 512**2
for side in [256, 1024, 2048, 4096]:
print(side, k * side**2, "MiB")256 0.25 MiB
1024 4.0 MiB
2048 16.0 MiB
4096 64.0 MiB
Test yourself
varies inversely with . If triples, …
- triples
- is divided by 3
- stays the same
- is multiplied by 9
Which table shows direct variation?
- (1, 4), (2, 6), (3, 8)
- (2, 10), (5, 4), (10, 2)
- (3, 12), (5, 20), (8, 32)
- (1, 1), (2, 4), (3, 9)
Sound intensity follows an inverse-square law. Moving 3 times farther away makes it…
- as strong
- as strong
- as strong
- 3 times stronger