JuliaMath / Calculus.jl

Calculus functions in Julia
Other
275 stars 78 forks source link

Macro to differentiate function symbolically #149

Closed Luapulu closed 3 years ago

Luapulu commented 4 years ago

Given a function that is simple enough, I'd like to be able to differentiate an existing function symbolically, by simply putting a macro in front of it. It could work something like this:

cubefunc_diff = @differentiate function cubefunc(x)
    return x * x * x
end

# cubefunc_diff(3) would return derivative evaluated at 3

I've started trying to implement this myself, but I'm not sure how best to proceed or if what I'm proposing is even a good idea. Would this be a good idea?

johnmyleswhite commented 4 years ago

I always wanted this, but don't do anything to maintain this repo anymore. Not clear to me where the future for symbolic differentiation is, but probably not here. Also worth noting that people usually would discourage differentiation for serious work since the simplification steps are seldom good enough to provide optimal code relative to automatic differentiation.

Luapulu commented 3 years ago

Interesting, I think trying to implement this might be a hobby project of mine in the future.