Calculus.jl
Calculus.jl copied to clipboard
Disallow second_derivative and hessian functions to be called without g
Currently, derivative.jl has the two following definintions
second_derivative(f::Function) = second_derivative(f, derivative(f), :scalar, :central)
hessian(f::Function) = second_derivative(f, gradient(f), :vector, :central)
however we discussed that by estimating the first derivative to hand to the second derivative is error prone and subject to possibly large round off error.
I think it's simple enough for a user to input second_derivavitve(f,derivative(f)) explicitly if they want to take this risk.
Thoughts? @johnmyleswhite
I think it is good to remove functions with poor mathematical properties, especially when it is so simple to write the full version which makes it clear what is happening, and that the accuracy might be bad.
Should the ctranspose alias that allows sin'''(x) should be warned against in the documentation, or removed? Differentiating several times with finitie_difference gets very inaccurate quickly, and when ' is chained the resulting algorithm is very bad because eps is the same for each order.
Would it be reasonable to reserve the ' marker for algorithmic differentiation if someone will implement algorithmic differentiation of functions by reading the AST. Then it can be applied multiple times without losing accuracy. It might be convenient and improve readability if you can write sin'(x) instead of cos(x)