maroba / findiff

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

what is the relationship between the smallest length, order and accuracy? #16

Closed luckystarufo closed 5 years ago

luckystarufo commented 5 years ago

In general, is there a way to determine the shortest length of a dimension if I want to apply an operator dk_dx = Findiff(dim, dx, k, acc=d)?

In other words, can k and d directly determine the shortest length required?

maroba commented 5 years ago

I assume, you mean the shortest length required for a given absolute accuracy on a given domain. That's not possible, because it strongly depends on the function you are sampling. In principle, the error can be estimated by the residual term in the Taylor expansion, which not only depends on the grid spacing, but also on the next higher derivative of the function. To determine the optimum grid spacing, you should refine the grid until the change in the results are smaller than a desired threshold.

luckystarufo commented 5 years ago

I see, thank you!