Improve code that estimates parameters using max likelihood, optim, differential equations and automatic differentiation?

I just created another question. I modified the code and it is more efficient in both languages, although I still have the same issue of faster convergence in R.

See:
Similar question