chbder_c |

## Procedurevoid chbder_c ( ConstSpiceDouble * cp, SpiceInt degp, SpiceDouble x2s[2], SpiceDouble x, SpiceInt nderiv, SpiceDouble * partdp, SpiceDouble * dpdxs ) ## AbstractGiven the coefficients for the Chebyshev expansion of a polynomial, this returns the value of the polynomial and its first nderiv derivatives evaluated at the input X. ## Required_ReadingNone. ## KeywordsINTERPOLATION MATH POLYNOMIAL ## Brief_I/OVARIABLE I/O DESCRIPTION -------- --- -------------------------------------------------- cp I degp+1 Chebyshev polynomial coefficients. degp I Degree of polynomial. x2s I Transformation parameters of polynomial. x I Value for which the polynomial is to be evaluated nderiv I The number of derivatives to compute partdp I-O Workspace provided for computing derivatives dpdxs O Array of the derivatives of the polynomial ## Detailed_Inputcp is an array of coefficients a polynomial with respect to the Chebyshev basis. The polynomial to be evaluated is assumed to be of the form: cp(degp+1)*T(degp,S) + cp(degp)*T(degp-1,S) + ... ... + cp(2)*T(1,S) + cp(1)*T(0,S) where T(I,S) is the I'th Chebyshev polynomial evaluated at a number S whose double precision value lies between -1 and 1. The value of S is computed from the input variables x2s[0], x2s[1] and X. degp is the degree of the Chebyshev polynomial to be evaluated. x2s is an array of two parameters. These parameters are used to transform the domain of the input variable X into the standard domain of the Chebyshev polynomial. x2s[0] should be a reference point in the domain of x; x2s[1] should be the radius by which points are allowed to deviate from the reference point and while remaining within the domain of x. The value of x is transformed into the value S given by S = ( x - x2s[0] ) / x2s[1] Typically x2s[0] is the midpoint of the interval over which x is allowed to vary and x2s[1] is the radius of the interval. The main reason for doing this is that a Chebyshev expansion is usually fit to data over a span from A to B where A and B are not -1 and 1 respectively. Thus to get the "best fit" the data was transformed to the interval [-1,1] and coefficients generated. These coefficients are not re-scaled to the interval of the data so that the numerical "robustness" of the Chebyshev fit will not be lost. Consequently, when the "best fitting" polynomial needs to be evaluated at an intermediate point, the point of evaluation must be transformed in the same way that the generating points were transformed. x Value for which the polynomial is to be evaluated. nderiv is the number of derivatives to be computed by the routine. nderiv should be non-negative. partdp Is a work space used by the program to compute all of the desired derivatives. It should be declared in the calling program as SpiceDouble partdp[3 * (nderiv+1)] ## Detailed_Outputdpdxs(0) The value of the polynomial to be evaluated. It is given by cp(degp+1)*T(degp,S) + cp(degp)*T(degp-1,S) + ... ... + cp(2)*T(1,S) + cp(1)*T(0,S) where T(I,S) is the I'th Chebyshev polynomial evaluated at a number S = ( x - x2s[0] )/ x2s[1]. dpdxs(i) The value of the i'th derivative of the polynomial at x. (I ranges from 1 to nderiv) It is given by [i] (1/x2s[1]**i) ( cp(degp+1)*T (degp,S) [i] + cp(degp)*T (degp-1,S) + ... . . . [i] ... + cp(2)*T (1,S) [i] + cp(1)*T (0,S) ) [i] where T(k,S) and T (i,S) are the k'th Chebyshev polynomial and its i'th derivative respectively, evaluated at the number S = ( x - x2s[0] )/x2s[1]. ## ParametersNone. ## ExceptionsError free No tests are performed for exceptional values ( nderiv negative, degp negative, etc.) This routine is expected to be used at a low level in ephemeris evaluations. For that reason it has been elected as a routine that will not participate in error handling. ## FilesNone. ## ParticularsThis routine computes the value of a Chebyshev polynomial expansion and the derivatives of the expansion with respect to X. The polynomial is given by cp(degp+1)*T(degp,S) + cp(degp)*T(degp-1,S) + ... ... + cp(2)*T(1,S) + cp(1)*T(0,S) where S = ( x - x2s[0] ) / x2s[1] and T(i,S) is the i'th Chebyshev polynomial of the first kind evaluated at S. ## ExamplesDepending upon the user's needs, there are 3 routines available for evaluating Chebyshev polynomials. chbval_c for evaluating a Chebyshev polynomial when no derivatives are desired. chbint_c for evaluating a Chebyshev polynomial and its first derivative. ## RestrictionsThe user must be sure that the provided workspace is declared properly in the calling routine. The proper declaration is: SpiceInt nderiv = the desired number of derivatives; SpiceDouble partdp[3 * (nderiv + 1)]; If for some reason a parameter is not passed to this routine in nderiv, the user should make sure that the value of nderiv is not so large that the work space provided is inadequate. One needs to be careful that the value (X-x2s[0]) / x2s[1] lies between -1 and 1. Otherwise, the routine may fail spectacularly (for example with a floating point overflow). While this routine will compute derivatives of the input polynomial, the user should consider how accurately the derivatives of the Chebyshev fit, match the derivatives of the function it approximates. ## Literature_References"Numerical Recipes -- The Art of Scientific Computing" by William H. Press, Brian P. Flannery, Saul A. Teukolsky, Willam T. Vetterling. (See Clenshaw's Recurrence Formula) "The Chebyshev Polynomials" by Theodore J. Rivlin. "CRC Handbook of Tables for Mathematics" ## Author_and_InstitutionN.J. Bachman (JPL) W.L. Taber (JPL) E.D. Wright (JPL) ## Version-CSPICE Version 1.0.0, 24-AUG-2015 (EDW) ## Index_Entriesderivatives of a chebyshev expansion |

Wed Apr 5 17:54:29 2017