Derivative of a function using the fitted curve

97 Views Asked by At

I have a set of numerical functions (f(x), g(x), h(x)) that can be evaluated at any point. f, g, and h are smooth functions (i.e. no jumps etc). I would like to take the derivative of $$ d(f(x)/(g(x)*h(x))/dx $$ Which of these two options are preferred:

  1. Use curve fitting for all of my functions to get a PCHIP splines for f,g,h. Also obtain the derivative of PCHIP spline curve fits. Then use mathematical differentiation: $$ [f'(x)*g(x)*h(x)-f(x)*(g'(x)*h(x)+h'(x)*g(x))]/[g(x)*h(x)]^2 $$
  2. Define H(x)=f(x)/(g(x)*h(x)). Get numerical samples from H and then fit a new spline to H and finally get the derivative of the fitted spline to H.

Which of these two methods sustainable to less numerical error?