Advertisement
Guest User

Untitled

a guest
Nov 26th, 2015
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. # -*- coding: cp1250 -*-
  2. wektor_xi=[1,2,4,5]
  3. wektor_fxi=[1,4,16,25]
  4. x=input("podaj wartosc x dla której szukamy wartosci: ")
  5.  
  6. def Interpolacja_lagrangea(vektor_miejsc,vektor_wartosci,poszukiwany_x):
  7. suma=0
  8. for i in range(len(vektor_wartosci)):
  9. lxi=1
  10. for j in range(len(vektor_miejsc)):
  11. if i!=j:
  12. #print x,wektor_xi[i],wektor_xi[i],wektor_xi[j]
  13. lxi*=((((poszukiwany_x-vektor_miejsc[j])*1.0)/(vektor_miejsc[i]-vektor_miejsc[j])))
  14. suma+=vektor_wartosci[i]*lxi
  15. return suma
  16. print Interpolacja_lagrangea(wektor_xi,wektor_fxi,x)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement