-
-
Save hamzaavvan/a874dfb6769ee8b3db93ea829025535c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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