Skip to content
DeepForgeby svx
All problems
EasyCalculusca-057

Marginal Cost

Problem

The marginal cost is the derivative of the total cost function with respect to quantity.

Given cost coefficients as a polynomial C(q) = sum(coeffs[i] * q^i), return C'(q) evaluated at q. Assume q >= 0.

Hint

Differentiate each term of the cost polynomial and evaluate at q.

Test cases

case 1
in: [[100,5,1],10]
expected: 25
case 2
in: [[50,2],3]
expected: 2
case 3
in: [[0,0,0,1],2]
expected: 12
case 4
in: [[1000],5]
expected: 0
Starter codePython
def marginal_cost(coeffs, q):
    # Your code here
    pass

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