The file NumericalApproximation.mth implements approximate numerical first and second derivatives of expressions along with smoothing, numerical differentiation, and integration of data arrays.  It is usually more appropriate to approximate, rather than simplify, these functions.  The function definitions in the file are automatically loaded when any of its functions are first used.


DIF_NUMERIC(y, x, x0, h, n) approximates to the nth partial derivative of expression y(x) with respect to variable x at value x0, using a centered finite difference with step size h.


SMOOTH_VECTOR(v) simplifies to a smoothed copy of vector v in which each internal component is the mean of the corresponding component and the two adjacent components in v.  The end components of the result are the same as in v.


SMOOTH_COLUMN(A, j) simplifies to a copy of matrix A in which column j is smoothed as described for the preceding SMOOTH_VECTOR function.  To smooth all of the columns, simplify the expression  SMOOTH_VECTOR(A`)`.


DIF_DATA(A) approximates to the first derivative of a numerical data matrix A.  A must have two columns and at least three rows, with each successive row being a successive [x, y] coordinate pair.  The result is an analogous data matrix wherein the second column is the approximate first derivative of y with respect to x at successive values of x.  The x values can be unequally spaced.  They can even be nonmonotonic, such as samples from a parametrically-defined curve.  The formula is based on the derivatives of parabolas that fit three successive points.  Such numerical differentiation tends to amplify roundoff or experimental errors, so it is often wise to apply the SMOOTH_COLUMN or SMOOTH_VECTOR function one or more times before applying DIF_DATA, as described in the preceding paragraph.


DIF2_DATA(A) is analogous to DIF_DATA(A), but it approximates the second derivative.  The formula tends to be less accurate at the end points than at the internal points.  The advice about possibly smoothing the data is even more relevant for DIF2_DATA.


INT_DATA(A) is analogous to DIF_DATA(A), but uses the trapezoidal rule to approximate an antiderivative having the value 0 at the first data point.  Such integration tends to smooth away roundoff and experimental errors, so it is usually not necessary to smooth data before applying INT_DATA.


Other Utility File LibraryG5BS2R 

Created with the Personal Edition of HelpNDoc: Full-featured multi-format Help generator