Is numeric gradient estimation well-posed

3 views (last 30 days)
Henrik Dam
Henrik Dam on 4 Mar 2015
Commented: Chris McComb on 4 Mar 2015
Dear matlabcentral,
I'm working on my thesis in mathematical finance. As a small part of it I am to numerically find a gradient of a function which is pretty demanding to evaluate (involving Fourier inversion and afterwards ordinary inversion of a highly non-linear function, it evaluates pretty fast though). Can I expect accurate results? Can you recommend a function or implementation which generally does a good job? Any package and version can be assumed attainable.
I have done some Matlab programming, but I am probably a novice compared to you guys. I have never formally studied these kind of problems (numerical analysis?), so I have no idea of the well-posedness of numerical differentiation.

Answers (1)

Chris McComb
Chris McComb on 4 Mar 2015
It will depend a great deal on the characteristics of your function. If your function is smooth, then you can generally expect good results with numerical differentiation. However, if your function is noisy or discontinuous numerical differentiation becomes more troublesome.
When first implementing any method for finding the gradient, it may be a good idea to plot the original function in the same axes as the slope, to ensure that it is providing a good estimate.
As a starting point, I'd recommend MATLAB's gradient function.
Chris McComb
Chris McComb on 4 Mar 2015
Yes, I'd suggest plotting one variable at a time to check that the computed gradient matches the function. This will also allow to build up a gradient vector one element at a time.
Since your function is smooth, MATLAB's gradient() should work well (you can decrease the distance between adjacent points to increase accuracy). If you want something else you'll probably have to code it yourself. This is a pretty good reference.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!