Skip to content

Instantly share code, notes, and snippets.

@ianliu
Created March 25, 2013 13:29
Show Gist options
  • Select an option

  • Save ianliu/5237092 to your computer and use it in GitHub Desktop.

Select an option

Save ianliu/5237092 to your computer and use it in GitHub Desktop.
X = 8.95
xx = [1.4, 2.3, 4.0, 5.9, 10.0, 10.1]
n = len(xx)
ff = [x*x for x in xx]
ww = [1.0 for i in range(n)]
for i in range(n):
for j in range(n):
if i != j:
ww[i] /= xx[i] - xx[j]
s1 = 0.0
s2 = 0.0
for i in range(n):
p = ww[i] / (X - xx[i])
s1 = s1 + p
s2 = s2 + p * ff[i]
Y = s2 / s1
print Y, X*X
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment