Module coefs

This module determines finite difference coefficients for uniform and non-uniform grids for any desired even accuracy order.

Most important function:

coefficients(deriv, acc=None, offsets=None, symbolic=False)

to calculate the finite difference coefficients for a given derivative order and given accuracy order to given offsets.

findiff.coefs.coefficients(deriv, acc=None, offsets=None, symbolic=False, analytic_inv=False)

Calculates the finite difference coefficients for given derivative order and accuracy order.

If acc is given, the coefficients are calculated for central, forward and backward schemes resulting in the specified accuracy order.

If offsets are given, the coefficients are calculated for the offsets as specified and the resulting accuracy order is computed.

Either acc or offsets must be given.

Assumes that the underlying grid is uniform. This function is available at the findiff package level.

Parameters
  • deriv (int > 0) – The derivative order.

  • acc (even int > 0:) – The accuracy order.

  • offsets (list of ints) – The offsets for which to calculate the coefficients.

Raises

ValueError – if invalid arguments are given

Returns

dict with the finite difference coefficients and corresponding offsets

findiff.coefs.coefficients_non_uni(deriv, acc, coords, idx)

Calculates the finite difference coefficients for given derivative order and accuracy order. Assumes that the underlying grid is non-uniform.

Parameters
  • deriv – int > 0: The derivative order.

  • acc – even int > 0: The accuracy order.

  • coords – 1D numpy.ndarray: the coordinates of the axis for the partial derivative

  • idx – int: index of the grid position where to calculate the coefficients

Returns

dict with the finite difference coefficients and corresponding offsets

findiff.coefs.compute_inverse_Vandermonde(column, offsets, symbolic)

Computes a given column of the inverse of the Vandermonde matrix that belongs to given offsets, multiplied by the factorial of the column index.

This code implements the first equation for b_kj under “Proof 1” in https://proofwiki.org/wiki/Inverse_of_Vandermonde_Matrix Note that the result has to be transposed because the original Vandermonde matrix is defined transposed as compared to _build_matrix.

Also, we have 0-based indexing here, whereas the formulae in the wiki entry are 1-based.