Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
| (def step 1E-10) | |
| (def eps 1E-15) | |
| (defn rootNP | |
| [f x] | |
| (let [m (/ (- (f (+ x step)) (f x)) step) | |
| b (- (f x) (* m x)) | |
| x-0 (- (/ b m))] | |
| (if (<= (Math/abs (- x x-0)) eps) | |
| x-0 |
This file contains hidden or 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
| import time | |
| import numpy as np | |
| def rootNR(f, start_x): | |
| step = 1e-10 # small increment | |
| x = start_x | |
| eps = 1e-15 # need eps, on some functions abs(x-x_0) never reaches zero | |
| while True: | |
| m = (f(x+step) - f(x))/step |
NewerOlder