#------------ Interpolação 

t=c(2,8,12,9,1,13)# x
w=c(3,5,7,3,10,7) # y 

n=length(w)

L<-function(i,s){
p=1
for (j in 1:n){
if ( i!=j){p=p*(s-t[j])/(t[i]-t[j])}
}
p
}

poliLag<-function(s){
p=0
for ( i in 1:n){p=p+w[i]*L(i,s)}
p
}

curve(poliLag,min(t),max(t))
points(t,w,col="red")

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: