johnmyleswhite/optim.jl — pull request #1 by andreasnoackjensen (2012-10-11 16:55:00+00:00)
Title: New functions for numerical derivatives

I have written some functions that calculates numerical derivatives more precisely and I think they could be useful in the optim.jl package. I have given an example of the difference below.

julia> load("src/init.jl")

julia> fRosen = x -> (1-x[1])^2+100(x[2]-x[1]^2)^2;

julia> [1602, -400] - estimate_gradient2(fRosen)([2.,2.])
2-element Float64 Array:
4.11091e-6
-2.13392e-6

julia> [1602, -400] - gradient(fRosen)([2.,2.])
2-element Float64 Array:
-1.93563e-9
-7.99218e-11

julia> [1602, -400] - estimate_gradient(fRosen)([2.,2.])
2-element Float64 Array:
-5.1613e-5
-4.83024e-6

julia> [1602, -400] - gradient(fRosen, [2.,2.], 0.0001, false)
2-element Float64 Array:
-9.03242e-9
2.1941e-9