Table of contents
CSPICE_QDERIV estimates the derivative of a function by finding the
derivative of a quadratic approximating function. This derivative
estimate is equivalent to that found by computing the average of forward
and backward differences.
Given:
f0 an array of NDIM function values at a point on the real line;
we'll refer to this point as `x0'.
help, f0
DOUBLE = Array[NDIM]
f2 an array of NDIM function values at a second point on the real
line; we'll refer to this point as `x2'.
help, f2
DOUBLE = Array[NDIM]
The points `x0' and `x2' must satisfy
x2 = x0 + 2 * delta
delta one half of the difference between `x2' and `x0':
delta = ( x2 - x0 ) / 2
`delta' may be negative but must be non-zero.
help, delta
DOUBLE = Scalar
the call:
cspice_qderiv, f0, f2, delta, dfdt
returns:
dfdt an N-dimensional vector representing an estimate of the
derivative of the input function at the midpoint `x1' of the
interval between `x0' and `x2'.
help, dfdt
DOUBLE = Array[NDIM]
The ith component of `dfdt' is
( 1 / (2*delta) ) * ( f2(i) - f0(i) )
We may regard this estimate as the derivative
at `x1' of a parabola fitted to the points
( x0, f0(i) ), ( x2, f2(i) )
We may also regard this derivative as the average
of the forward and backward first-order
differences of the input function defined by
f0(i), f2(i), and `delta'.
None.
Any numerical results shown for this example may differ between
platforms as the results depend on the SPICE kernels used as input
and the machine specific arithmetic implementation.
1) Estimate the derivative of x**2 at x = 2.
Example code begins here.
PRO qderiv_ex1
delta = 1.D-3
f0 = [ ( 2.0 - delta ) ^ 2.0 ]
f2 = [ ( 2.0 + delta ) ^ 2.0 ]
cspice_qderiv, f0, f2, delta, dfdt
print, format='(A,E25.16)', ' 4 - DFDT(1) = ', 4 - dfdt[0]
END
When this program was executed on a Mac/Intel/IDL8.x/64-bit
platform, the output was:
4 - DFDT(1) = 4.5474735088646412E-13
Note that the difference displayed is platform-dependent, but
should be on the order of 1.E-12.
This routine estimates the derivative of a vector-valued function
using the average of forward and backward differences.
The derivative estimate computed by this routine is equivalent to
that obtained by fitting each component of the function with a
parabola at the points
(x0, f(x0)), (x1, f(x1)), (x2, f(x2))
where
x0 = x1 - delta
x2 = x1 + delta
and finding the derivative of the parabolas at `x1'.
1) If `delta' is zero, the error SPICE(DIVIDEBYZERO) is signaled by
a routine in the call tree of this routine.
2) If any of the input arguments, `f0', `f2' or `delta', is
undefined, an error is signaled by the IDL error handling
system.
3) If any of the input arguments, `f0', `f2' or `delta', is not
of the expected type, or it does not have the expected
dimensions and size, an error is signaled by the Icy
interface.
4) If the input vector arguments `f0' and `f2' do not have the
same dimension (N), an error is signaled by the Icy interface.
5) If the output argument `dfdt' is not a named variable, an
error is signaled by the Icy interface.
None.
None.
ICY.REQ
None.
J. Diaz del Rio (ODC Space)
-Icy Version 1.0.0, 09-AUG-2021 (JDR)
Estimate function derivative using quadratic fit
|