Given the data points for ( is large),
we want to find a degree polynomial that fits the data in the least
squares sense. This polynomial is
The system of normal equations is
For the right hand side vector, we have
! Compute P
DO i=1,n+1
DO j=1,i
P(i,j) = 0.0
ipower=i+j-2
DO k=1,m
P(i,j) = P(i,j) + t(k)**ipower
END DO
P(j,i) = P(i,j)
END DO
END DO
! Compute b
DO i=1,n+1
b(i) = 0.0
DO k=1,m
b(i) = b(i) + t(k)**(i-1)*y(k)
END DO
END DO
! Solve the system Pa=b etc.