maroba / findiff

Python package for numerical derivatives and partial differential equations in any number of dimensions.
MIT License
412 stars 59 forks source link

Add analytic inversion as option for computing coefficients #67

Closed dwierichs closed 1 year ago

dwierichs commented 1 year ago

This PR adds the functionality suggested in #66 to the findiff.coefficients function as an optional feature, activated via the kwarg analytic_inv (happy for suggestions of a better name).

It implements the first equation for the matrix entries b_{kj} under "Proof 1" at the ProofWiki entry, up to transposition and re-indexing to get to 0-based indices. It supports symbolic=True and symbolic=False.

I also added raising of two tiny ValueError for the cases of

  1. neither acc nor offsets being provided, and
  2. the required differentiation order being to high for the number of given offsets.

Tests are duplicated to use analytic_inv=True.