Hi Choi!



 geunseok_choi:

Is there any way to use the numerical form of c-function-A
Like for example, can I make [ c-function-A(x-delta x) / x-delta x ] as a backward part?


I’ve never tried this approach – using numerical differentiation to
calculate .backward() – but I have thought about it.
Advantages:  Numerical differentiation is a very general-purpose tool,
so you can apply it to lots of use cases.
Disadvantages:  A sledgehammer is also a general-purpose tool that
can be “applied” to almost anything.  But it is a crude tool, so you
may not get the results you want …
More concretely, numerical differentiation can be numerically tricky.
The core issue is how do you choose your step size, delta_x so
that you get a good estimate of the local derivative, but you don’t
get too much round-off error when you take the finite differences?
(Consider numerically differentiating abs (x) when your step size
crosses x = 0.)
(This is a well-studied problem:  Many scientific subroutine libraries
include numerical-differentiation algorithms, but if you look at them
you will see that they are much more involved than the simple
approach you outlined above.)


If I can, is it too slower than the analytic way?


It is likely to be slower than a numerical implementation of the analytic
derivative (by possibly a lot).
If you can calculate the derivative analytically – even if doing so is a
fair amount of work – it will be worth doing it that way.  If it were me, I
would only calculate .backward() numerically as a quick-and-dirty
hack to test something or if I were really struggling with the analytic
derivative.
Best.
K. Frank