0

I'm learning about the numerical differentiation and is trying out some examples with mpmath library.

On it's documentation page, it suggested that the mpmath.diff used either

method
    Supported methods are 'step' or 'quad': derivatives may be computed using either 
        a finite difference with a small step size (default), or 
        numerical quadratur

However, when I tried it out, the function showed unreasonable stability regarding to the "round off error". On the first derivatives, it's as accurate as the complex step method. On the higher order derivatives, for mp.cos function, it's more stable than complex contour type of algorithms up to hundreds of order. If some special optimization might be given to the mp.cos function, I tried the derivatives of other functions. The results were much more stable than finite difference should be up to very high orders.

These seemed to indicate that the numerical differentiation function implemented in mpmath library had taken automatic differentiation. (Since the other stable method, the higher order complex step methods was much more complicated.)

Could you confirm if the automatic differentiation was implemented for mpmath.diff or not, please?

  • Updates: based on numerical results, there's a strong suspicion that the higher order derivative might implemented some types of contour integral types of algorithms. – ShoutOutAndCalculate Jul 21 '23 at 22:26

0 Answers0