rendlemr
06-04-2003, 04:59 PM
Let f(x; x1, x2, ... xn, y1, y2,, ... yn) represent the cubic spline function evaluated at a specific value, x, as a function of the inputs x1, x2, ... xn and y1, y2, ... yn. Does anyone know how to evaluate the derivative of this function with respect to one of the y inputs, or df(x; x1, x2, ... xn, y1, y2,, ... yn) / dyi ?
Richard Rendleman
Chaambu
06-07-2010, 03:43 AM
subroutine spldiff(x,y,h,n,u)
c Calculates the numerical derivative using spline interpolation
c Calls the Numerical Recipes routine TRIDIAG (double precision)
c REMARK
c End point behaviour is not so good
c INPUTS
c x(n),y(n) - arrays comprising x & y data (equispaced x)
c h - spacing in x values
c n - array size
c OUTPUT
c u(n) - first order derivative (dy/dx)
c
c P. Arumugam, IIT Roorkee - 07-June-2010
c
implicit double precision (a-h,o-z)
dimension x(n),y(n)
dimension a(n),b(n),c(n),r(n),u(n)
a(n)=1.d0
b(1)=2.d0
b(n)=2.d0
c(n-1)=1.d0
r(1)=3.d0*(y(2)-y(1))/h
r(n)=3.d0*(y(n)-y(n-1))/h
do i=2,n-1
a(i)=1.d0
b(i)=4.d0
c(i-1)=1.d0
r(i)=3.d0*(y(i+1)-y(i-1))/h
end do
call tridag(a,b,c,r,u,n)
end