Demo entry 6682806

newton

   

Submitted by anonymous on Dec 11, 2017 at 04:18
Language: Matlab. Code size: 325 Bytes.

function y=newtoninter(x)
    x0=-1:0.1:1;
    fx0=1./(1+25*x0.^2);
    y=fx0(1);
    w=1;
    dy=0;
    for i=1:length(x0)-1
        for j=i+1:length(x0)
            dy(j)=(fx0(j)-fx0(i))/(x0(j)-x0(i));
        end
        a(i)=dy(i+1);
        w=w*(x-x0(i));
        y=y+a(i)*w;
        fx0=dy;
    end
end

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).