psf/black code formatting (#1277)

This commit is contained in:
William Zhang
2019-10-05 01:14:13 -04:00
committed by Christian Clauss
parent 07f04a2e55
commit 9eac17a408
291 changed files with 6014 additions and 4571 deletions

View File

@ -1,17 +1,24 @@
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
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) < 10**-5:
x_n2 = x_n1 - (
function(x_n1) / ((function(x_n1) - function(x_n)) / (x_n1 - x_n))
)
if abs(x_n2 - x_n1) < 10 ** -5:
return x_n2
x_n=x_n1
x_n1=x_n2
x_n = x_n1
x_n1 = x_n2
def f(x):
return math.pow(x , 3) - (2 * x) -5
return math.pow(x, 3) - (2 * x) - 5
if __name__ == "__main__":
print(intersection(f,3,3.5))
print(intersection(f, 3, 3.5))