I'm writing a code for the Secant Method for root finding, but
my code makes an infinite code of the correct answer. Below is my
code, how do I fix it?
def f(x):
return (x**6)+7*(x**5)-15*(x**4)-70*(x**3)+75*(x**2)+175*x-125
def secant():
p0=float(input('Enter an initial guess for the root '))
p1=float(input('Enter another guess '))
TOL=float(input('Enter a tolerance in decimal form '))
n=15
i=1
while i<=n:
p=p1-f(p1)*(p1-p0)/(f(p1)-f(p0))
if abs(p-p1)<TOL:
print(p)
else:
p0=p1
p1=p
i=i+1
else:
print(p)
return p
print(secant())