Skip to content
DeepForgeby svx
All problems
EasyCalculusca-061

Elasticity of Demand

Problem

The price elasticity of demand is E(p) = (p / q(p)) * q'(p), where q(p) is the demand function.

Given q as a polynomial in p via coefficient list, return E(p). Assume q(p) != 0.

Hint

It is the ratio of the percentage change in quantity to the percentage change in price.

Test cases

case 1
in: [[100,-2],20]
expected: -0.6666666666666666
case 2
in: [[0,-1],5]
expected: 1
case 3
in: [[50,0,-1],5]
expected: -2
case 4
in: [[10],2]
expected: 0
Starter codePython
def elasticity(coeffs, p):
    # Your code here
    pass

4 test cases · run your code against them in the editor