SHARE
TWEET

Untitled

a guest Nov 22nd, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def lagrange(f,a,b,epsilone=0.1):
  2.     k = 0
  3.     u,v = [a],[b]
  4.     x = [(u[k]*f(v[k])-v[k]*f(u[k]))/(f(v[k])-f(u[k]))]
  5.     while (v[k]-u[k]>epsilone) or (abs(f(x[k]))>epsilone):
  6.         if f(u[k])*f(x[k])<0:
  7.             u.append(u[k])
  8.             v.append(x[k])
  9.         else:
  10.             u.append(x[k])
  11.             v.append(v[k])
  12.         x.append((u[k+1]*f(v[k+1])-v[k+1]*f(u[k+1]))/(f(v[k+1])-f(u[k+1])))
  13.         k = k + 1
  14.     return x[-1]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top