real x(20),f(20) print*,'number of data points' read(*,*)m print*,'input data points x, f(x)' do i=1,m read(*,*)x(i),f(i) end do print*,'input x-coordinate of interpolation point' read(*,*)xx print*,'largest second derivative in interpolation interval, if known' read(*,*)curve c find closest interval to interpolation point do i=1,m-1 if(xx.gt.x(i).and.xx.lt.x(i+1)) then i1=i i2=i+1 end if end do print*,'interpolation interval between',x(i1),'and',x(i2) c find linear interpolation at point xx fx=f(i1)+(f(i2)-f(i1))*(xx-x(i1))/(x(i2)-x(i1)) print*,'interpolated value at point',xx,'=',fx c estimate error if(curve.eq.0.0) curve=max(f(x(i1)),f(x(i2))) error=curve*((x(i2)-x(i1))**2.0)/8.0 print*,'estimated maximum error=',error stop end