jahawk:

Now I manage to obtain my second derivative!


Perfect!

P.S.: I still get though the UsreWarning (in debug mode)

This is weird. I don’t see any warning when running your code on colab.
Can you run your code with python’s argument -W  error to make it raise an error for the warning so that you can get a full stack trace of where it happens?