GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Python/arithmetic_analysis/intersection.py at master · netbits/Python Expand file tree/ Copy pathintersection.pyMore file actions 17 lines (14 loc) · 469 Bytes / Copy pathintersection.pyFile metadata and controls17 lines (14 loc) · 469 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 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) < 10**-5: return x_n2 x_n=x_n1 x_n1=x_n2 def f(x): return math.pow(x , 3) - (2 * x) -5 if __name__ == "__main__": print(intersection(f,3,3.5)) |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |