# Try out NAG Library functions

Explore NAG maths and stats routines with interactive demos
Function ID
E01BGF
Name
nagf_interp_1d_monotonic_deriv
Description
Evaluation of interpolant computed by , function and first derivative
Keywords
Hermite interpolation | monotonicity-preserving spline
This example reads in values of n, x, f and d, and calls e01bgf to compute the values of the interpolant and its derivative at equally spaced points.
    Program e01bgfe

!     E01BGF Example Program Text

!     Mark 26.1 Release. NAG Copyright 2016.

!     .. Use Statements ..
Use nag_library, Only: e01bgf, nag_wp
!     .. Implicit None Statement ..
Implicit None
!     .. Parameters ..
Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
Real (Kind=nag_wp)               :: step
Integer                          :: i, ifail, m, n, r
!     .. Local Arrays ..
Real (Kind=nag_wp), Allocatable  :: d(:), f(:), pd(:), pf(:), px(:),     &
x(:)
!     .. Intrinsic Procedures ..
Intrinsic                        :: min, real
!     .. Executable Statements ..
Write (nout,*) 'E01BGF Example Program Results'

!     Skip heading in data file

Allocate (d(n),f(n),x(n))

Do r = 1, n
End Do

Allocate (pd(m),pf(m),px(m))

!     Compute M equally spaced points from X(1) to X(N).

step = (x(n)-x(1))/real(m-1,kind=nag_wp)

Do i = 1, m
px(i) = min(x(1)+real(i-1,kind=nag_wp)*step,x(n))
End Do

ifail = 0
Call e01bgf(n,x,f,d,m,px,pf,pd,ifail)

Write (nout,*)
Write (nout,*) '                  Interpolated   Interpolated'
Write (nout,*) '       Abscissa          Value     Derivative'

Do i = 1, m
Write (nout,99999) px(i), pf(i), pd(i)
End Do

99999 Format (1X,2F15.4,1P,E15.3)
End Program e01bgfe

The NAG Library
The world’s largest collection of robust, documented, tested and maintained numerical algorithms.