Numerical Recipes Forum  

Go Back   Numerical Recipes Forum > Obsolete Editions Forum > Methods: Chapters 3, 4, 5, and 6

Reply
 
Thread Tools Display Modes
  #1  
Old 06-04-2003, 04:59 PM
rendlemr rendlemr is offline
Member
 
Join Date: Jun 2003
Posts: 2
Cubic spline derivative

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
Reply With Quote
  #2  
Old 06-07-2010, 03:43 AM
Chaambu Chaambu is offline
Registered User
 
Join Date: Jun 2010
Posts: 1
Solved with extra coding

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
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 06:59 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.