answered 8 years ago
Just to add to the list of answers, I'm linking a post I've made which shows how to expand Benjamin Jones' solution to a system of functions and their gradients: http://louisgagnon.com/scBlog/sageCpp.html