Scenario
A company wants to understand how changes in the price of a product affect its demand.
The demand function is estimated from past data as:
$$
Q_d = 500 - 20P
$$
- $( Q_d )$ is the quantity demanded.
- $( P )$ is the price.
We will calculate the price elasticity of demand (PED) for different price levels using the formula:
$$
\text{PED} = \left( \frac{\Delta Q_d}{Q_d} \right) / \left( \frac{\Delta P}{P} \right)
$$
Python Implementation
Here is the $Python$ code to compute and visualize the elasticity of demand for a range of prices:
1 | import numpy as np |
Explanation of the Code
- Demand Function:
The functiondemand_function(price)represents the relationship between price and quantity demanded. - Elasticity Calculation:
Theprice_elasticityfunction uses a small change in price $(\Delta P)$ to calculate the corresponding change in quantity $(\Delta Q_d)$, then computes elasticity. - Data Generation:
A range of prices is simulated to compute demand and elasticity values. - Visualization:
- The demand curve shows the relationship between price and quantity demanded.
- The elasticity plot demonstrates how elastic or inelastic demand is at different price points.
Unit elasticity is marked for reference.
Graphical Results

- Demand Curve:
- Downward-sloping curve indicates that higher prices reduce quantity demanded.
- Elasticity Curve:
- Shows the PED at different price points.
- When PED > -1: Demand is inelastic (less sensitive to price changes).
- When PED < -1: Demand is elastic (more sensitive to price changes).
- PED = -1: Unit elastic, where the percentage change in quantity equals the percentage change in price.
This analysis provides insights into pricing strategies.
For example:
- Inelastic demand suggests raising prices to increase revenue.
- Elastic demand suggests lowering prices might increase revenue by boosting demand.








