Skip to content

Instantly share code, notes, and snippets.

@hamzaavvan
Created October 6, 2019 09:40
Show Gist options
  • Save hamzaavvan/a874dfb6769ee8b3db93ea829025535c to your computer and use it in GitHub Desktop.
Save hamzaavvan/a874dfb6769ee8b3db93ea829025535c to your computer and use it in GitHub Desktop.
x1=int(input("Enter x1: "))
x2=int(input("Enter x2: "))
def f(x):
return x**4 - x - 10
def form(x1, x2):
return ((x1 * f(x2) - x2 * f(x1)) /
(f(x2) - f(x1)))
def secant(x1, x2, E):
xm = 0; xnew = 0
while True:
xnew = form(x1, x2)
x1 = x2
x2 = xnew
xm = form(x1, x2)
print(xnew)
if(abs(xm - xnew) < E):
break
secant(x1, x2, 1e-5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment