Skip to content

Instantly share code, notes, and snippets.

@19007361
Created August 16, 2018 18:32
Show Gist options
  • Save 19007361/a3357f99893d80a754d7eab7b50dddb0 to your computer and use it in GitHub Desktop.
Save 19007361/a3357f99893d80a754d7eab7b50dddb0 to your computer and use it in GitHub Desktop.
def secant(p, pOld, tol, iters):
iters -= 1
pOld = p
pNew = p - (f(p))*(p - pOld)
if abs(pNew - p) < tol or iters == 0:
return pNew
else:
secant(pNew, pOld, tol)
def f(x):
if __name__ == "__main__":
secant(
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment