Gradient is zero yet exists
6 views (last 30 days)
Stephen23 on 6 Sep 2017
Why would you expect
ans = 0
to be non-zero? You are asking for the gradient at one point... to be honest I am surprised that it does not return NaN. Did you read the gradient documentation to know what the two arguments are for?
Perhaps you really wanted to do this:
"Also, is diff for calculating the derivative?"
Did you read the diff documentation? It answers your question, right on the very first line.