## orthogonal  polynomial least square function
## A First Course in Numerical Analysis, 
## Anthony Ralston,Philip Rabinowitz, Mc Graw Hill ISBN 0-07-051158-6” 
## Author: M. Turhan ÇOBAN
## Created: 2021-08-22

function retval = orthogonal_func(a,x)
    #polynomial value calulation
    yy=0.0;
    k=0;
    a1=a(1,:);
    a2=a(2,:);
    a3=a(3,:);
    m=length(a1);
    mp2=m+1;
    q=zeros(mp2);
    for k=m-1:-1:1
        q(k)=a1(k)+(x-a2(k+1))*q(k+1)-a3(k+1)*q(k+2);
        yy=q(k);
    end 
    retval =yy;
endfunction
