! lagrange.f90 simple definition and build ! L_n,j(x) = product i=0,n i!=j (x-x_i)/(x_j-x_i) ! let 0 < x < 1 for points x_0, x_1, ... , x_n ! let h = x_i - x_i-1, x_i = i * h, h = 1/n ! L_n(x) = sum j=0,n f(x_j) L_n,j(x) ! This L_n(x) fits f(x) with a n th order polynomial ! ! generate L_n,j(x) for n=1,6 j=0,n program lagrange implicit none integer :: NN = 6 integer :: i, j, k, n, m double precision :: h, termx, termc double precision, dimension(0:20) :: p ! coefficients of polynomial double precision, dimension(0:20) :: q ! temp double precision, dimension(0:20) :: L ! accumulate fit of e^x double precision :: x, fit, err, maxerr, rmserr print *, "lagrange.f90 running on 0