def ec_grad2(p, q):
delta = p**2 - 4*q
sqrt_delta = delta**0.5
if delta < 0:
return "No real solutions"
elif delta == 0:
x1 = -p/2
x2 = x1
return (x1, x2)
elif delta > 0:
x1 = -2*q/(p + sqrt_delta)
x2 = 2*q/(sqrt_delta - p)
return (x1, x2)
def printing(function_return):
if type(function_return) == str:
print(function_return)
else:
a, b = function_return
print("x1 = {:.20f} si x2 = {:.20f}".format(a, b))
When I try to find the roots for the quadratic equation for large numbers I get the overflowError. Does anybody have any clue on how to solve this. I tried with the Vieta's formulas and also with Decimal.