Updated differentiate.jl to be make finite differences based on a symbolic expression
Does doing this make more sense than putting it into finite_difference and having it called by derivative()?
julia> differentiate(:(e^x),:(x))
:(*(^(e,x),log(e)))
julia> using Calculus
julia> differentiate(:(e^x),:(x),1.0)
2.718281828459045
julia> differentiate(:(e^x),:(x),0.0)
1.0
Admittedly, in its current form it messes with global variables.
We should definitely call this differentiate for now to stick with the distinction that's been drawn between symbolic and numeric differentation. I wonder whether we should provide a macro as well as a function.
I just updated the proposed function to use local vars, and what I think is a safer use of eval, given the assertions, though I'm no expert -- what do you think?
julia> using Calculus
julia> differentiate(:(e^x),:x,1.0)
2.718281828459045
julia> differentiate(:(e^x),:x,2.0)
7.3890560989306495
julia> x
ERROR: x not defined
How do you think a macro can help?
Also, what do you think about the hessian and jacobian matrix functions? Should there be a symbolic and numeric version, should they be kept to one or the other type of differentiation, or should the user be able to specify which to use? Like:
julia> derivative(x->x^2, 1.0, :central)
1.9999999999829379
julia> derivative(x->x^2, 1.0, :forward)
2.000000014901161
julia> derivative(x->x^2, 1.0, :symbolic)
2.0
(The same applying to hessian/jacobians as well).