increment 1

This commit is contained in:
Alex Brown
2018-10-19 07:48:28 -05:00
parent 718b99ae39
commit 564179a0ec
131 changed files with 16252 additions and 0 deletions

View File

@ -0,0 +1,16 @@
import math
def intersection(function,x0,x1): #function is the f we want to find its root and x0 and x1 are two random starting points
x_n = x0
x_n1 = x1
while True:
x_n2 = x_n1-(function(x_n1)/((function(x_n1)-function(x_n))/(x_n1-x_n)))
if abs(x_n2 - x_n1)<0.00001 :
return x_n2
x_n=x_n1
x_n1=x_n2
def f(x):
return math.pow(x,3)-2*x-5
print(intersection(f,3,3.5))