A cinema changed its ticket price from p1 to p2 dollars, and weekly attendance went from q1 to q2 tickets. The manager wants to know how strongly attendance reacted, and whether the till took in more or less.
The price elasticity of demand measures the reaction as a ratio of percentage changes. Using the midpoint formula, each change is taken relative to the average of its two values:
e = \frac{(q_2 - q_1) \,/\, \frac{q_1 + q_2}{2}}{(p_2 - p_1) \,/\, \frac{p_1 + p_2}{2}}
For demand e is usually negative (dearer tickets, fewer viewers). Its size |e| gives the label:
"elastic"when|e| > 1: attendance moves proportionally more than the price;"inelastic"when|e| < 1;"unit"when|e|is within1e-9of1.
Total revenue is price times quantity. Its change is "rises" if p2 * q2 is larger than p1 * q1, "falls" if smaller, and "same" if the two differ by at most 1e-9.
Write price_test(p1, q1, p2, q2) that returns the tuple (e, label, revenue_change).
Examples
Input: p1 = 8, q1 = 1200, p2 = 10, q2 = 1000
Output: (-0.8181818181818182, 'inelastic', 'rises')
Explanation: quantity -200 / 1100 = -18.2 %, price 2 / 9 = +22.2 %.
Revenue goes from 9600 to 10000 dollars.
Input: p1 = 3, q1 = 400, p2 = 2.5, q2 = 560
Output: (-1.8333333333333333, 'elastic', 'rises')
Input: p1 = 4, q1 = 300, p2 = 6, q2 = 200
Output: (-1.0, 'unit', 'same')
Constraints
p1 != p2eis compared with a tolerance of1e-6
Goals
- Compute the midpoint (arc) elasticity between two price-quantity observations
- Classify demand as elastic, inelastic or unit elastic by the size of the elasticity
- Compare total revenue before and after a price change