When you encounter some limitation formulas after giving approaching x seems like 00โ or โโโ, you can get its molecular and denominator's first derivative partly, then do this process again and again until you get some limitation value that not seems like 00โ or โโโ
formula = a fractional limitation formula
molecular, denominator = split_fraction(formula)
while True:
i = 0
molecular_limitation_value = get_limitation_value(molecular)
denominator_limitation_value = get_limitation_value(denominator)
if '{m}:{d}'.format(m=molecular_limitation, d=denominator) in ['0:0', 'โ:โ']:
molecular = take_first_derivative(molecular)
denominator = take_first_derivative(denominator)
i += 1
else:
return molecular_limitation_value / denominator_limitation_value
if i > 999:
print("You can't use hospital rule in this formula.")