All problems
L Hopital Iteration Count
Problem
To evaluate the limit of num(x) / den(x) at x0, apply L'Hopital's rule repeatedly until the denominator is nonzero at x0, then evaluate the ratio of derivatives.
Given coefficient lists in ascending order and x0, return [applications, limit], where applications is the number of differentiations (capped at 10) and limit is None if the denominator remains zero after the cap.
Hint
Differentiate numerator and denominator together and count the rounds.
Test cases
case 1
in: [[-1,0,1],[-1,1],1]
expected: [1,2]
case 2
in: [[-2,0,0,1],[-1,0,1],1]
expected: [1,1.5]
case 3
in: [[1,0,0],[1,0],0]
expected: [0,1]
Starter codePython
def lhopital_iteration_count(num, den, x0):
# Your code here
pass3 test cases · run your code against them in the editor