﻿function Q = DannyNeviles(xhat,x,y)
    n=length(x);
    for i=1:n
        Q(i,1)=y(i);
        %makes a matrix out of the y values of the function, making it vertical instead of the default imput of horizontal, will eventually be filled in to become the final answer
    end%for

    for j=2:n
        for i=1:n+1-j
            %this part is cool as it fills in the neviles matrix, starting with the first collum it constructed in the last portion, and  using that to calculate the next collumn, with 1 less value, which it then uses to find the next collumn etc. till it gets one answer
            
            Q(i,j)=((xhat-x(i))*Q(i+1,j-1)-(xhat-x(i+j-1))*Q(i,j-1))/(x(i+j-1)-x(i));
        end%for
    end%for
    
end%function