Updated differentiate.jl to be make finite differences based on a symbolic expression#12
Open
jckt wants to merge 2 commits intoJuliaMath:masterfrom
jckt:master
Open
Updated differentiate.jl to be make finite differences based on a symbolic expression#12jckt wants to merge 2 commits intoJuliaMath:masterfrom jckt:master
jckt wants to merge 2 commits intoJuliaMath:masterfrom
jckt:master
Conversation
… based on a symbolic expression
Collaborator
|
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. |
Author
|
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 definedHow 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). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Does doing this make more sense than putting it into finite_difference and having it called by derivative()?
Admittedly, in its current form it messes with global variables.