title: Lagrange interpolation method
body: <p>I use convolution and for loops (too much for loops) for calculating the interpolation using 
  <code>Lagrange's method</code> , here's the main code : </p>
  
  <pre><code>function[p] = lagrange_interpolation(X,Y)
  L = zeros(n);
  p = zeros(1,n);
  
  
  % computing L matrice, so that each row i holds the polynom L_i
  % Now we compute li(x) for i=0....n  ,and we build the polynomial 
  
  for k=1:n
      multiplier = 1;
      outputConv = ones(1,1);
      for index = 1:n
          if(index ~= k &amp;&amp; X(index) ~= X(k))
              outputConv = conv(outputConv,[1,-X(index)]);
              multiplier = multiplier * ((X(k) - X(index))^-1);
          end
      end
      polynimialSize = length(outputConv);
      for index = 1:polynimialSize
          L(k,n - index + 1) = outputConv(polynimialSize - index + 1);
      end
      L(k,:) = multiplier .* L(k,:);
  end
  
  % continues 
  
  
  end
  </code></pre>
  
  <p>Those are too much for loops for computing the <code>l_i(x)</code> (this is done before the last calculation of <code>P_n(x) = Sigma of y_i * l_i(x)</code>) . </p>
  
  <p>Any suggestions into making it more matlab formal ? </p>
  
  <p>Thanks  </p>