aerosandbox.numpy.finite_difference_operators ============================================= .. py:module:: aerosandbox.numpy.finite_difference_operators Functions --------- .. autoapisummary:: aerosandbox.numpy.finite_difference_operators.finite_difference_coefficients Module Contents --------------- .. py:function:: finite_difference_coefficients(x, x0 = 0, derivative_degree = 1) Computes the weights (coefficients) in compact finite differece formulas for any order of derivative and to any order of accuracy on one-dimensional grids with arbitrary spacing. (Wording above is taken from the paper below, as are docstrings for parameters.) Modified from an implementation of: Fornberg, Bengt, "Generation of Finite Difference Formulas on Arbitrarily Spaced Grids". Oct. 1988. Mathematics of Computation, Volume 51, Number 184, pages 699-706. PDF: https://www.ams.org/journals/mcom/1988-51-184/S0025-5718-1988-0935077-0/S0025-5718-1988-0935077-0.pdf More detail: https://en.wikipedia.org/wiki/Finite_difference_coefficient :param derivative_degree: The degree of the derivative that you are interested in obtaining. (denoted "M" in the :param paper): :param x: The grid points (not necessarily uniform or in order) that you want to obtain weights for. You must :param provide at least as many grid points as the degree of the derivative that you're interested in: The order of accuracy of your derivative depends in part on the number of grid points that you provide. Specifically: order_of_accuracy = n_grid_points - derivative_degree (This is in general; can be higher in special cases.) For example, if you're evaluating a second derivative and you provide three grid points, you'll have a first-order-accurate answer. (x is denoted "alpha" in the paper) :param plus 1.: The order of accuracy of your derivative depends in part on the number of grid points that you provide. Specifically: order_of_accuracy = n_grid_points - derivative_degree (This is in general; can be higher in special cases.) For example, if you're evaluating a second derivative and you provide three grid points, you'll have a first-order-accurate answer. (x is denoted "alpha" in the paper) :param x0: The location that you are interested in obtaining a derivative at. This need not be on a grid point. Complexity is O(derivative_degree * len(x) ^ 2) Returns: A 1D ndarray corresponding to the coefficients that should be placed on each grid point. In other words, the approximate derivative at `x0` is the dot product of `coefficients` and the function values at each of the grid points `x`.