title: Newton Interpolation
body: <p>Hi I have this function to calculate the coefficient list for the Newton polynomial:</p>
  
  <pre><code>function p = polynom(x,y,c)
  m = length(x);
  p = c(m)*ones(size(y));
  for k = m-1:-1:1
   p = p.*(y-x(k)) + c(k);
  end
  </code></pre>
  
  <p>I already have another program that finds the divided differences c correctly. For <code>x=[3 1 5 6]</code>, <code>y=[1 -3 2 4]</code> I get <code>c=[1.0000    2.0000   -0.3750    0.1750]</code> which is correct. </p>
  
  <p>But when I use the above function it gives as a result:</p>
  
  <pre><code>p =
  
     -3.0000  -53.6000   -0.1000    1.3500
  </code></pre>
  
  <p>But the correct answer should be:</p>
  
  <pre><code>p = 
  
     0.1750   -1.9500    7.5250   -8.7500
  </code></pre>
  
  <p>What is wrong with my function?</p>