Lagrange Poly

1 function lg(X,Y,Xint)
2
3   n = length(X)
4   L = ones(1:n)  
5
6   for k = collect(1:n) 
7
8       
9       for c = collect(1:n)            
10           if c!=k
11              * L[k] = (L[k]*( Xint - X[c] ))/( X[k] - X[c] ) # problem*
12           end
13       end        
14    end
15   return sum(Y.*L)
16  end


===========================

x = collect(1:10)

y = x.^2 - 2.*x + rand()


When Executed

lg(x,y,2.5)


LoadError: InexactError() while loading In[76], in expression starting on line 1

in lg at In[74]:11?

Reply via email to