Main approaches
- Manual
- Finite Differences
- Symbolic Differentiation
- Automatic Differentiation
Computational Economics
2025-04-10
Choose small \(\epsilon>0\), typically \(\sqrt{ \textit{machine eps}}\)
Forward Difference scheme:
Central Difference scheme:
Lots of packages
FiniteDiff.jl, FiniteDifferences.jl, SparseDiffTools.jl
SymEngine.jl
Symbolics.jl
does not provide mathematical insights but solves the other problems
can differentiate any piece of code
two flavours
struct DN
x::Float64
dx::Float64
end
+(a::DN,b::DN) = DN(a.x+b.x, a.dx+b.dx)
-(a::DN,b::DN) = DN(a.x-b.x, a.dx-b.dx)
*(a::DN,b::DN) = DN(a.x*b.x, a.x*b.dx+a.dx*b.x)
/(a::DN,b::DN) = DN(a.x/b.x, (a.dx*b.x-a.x*b.dx)/b.dx^2)
...
Can you compute f(x)
using dual numbers?
(it might require some more definitions)
import ForwardDiff: Dual
x = Dual(1.0, 1.0)
a = 0.5*x
b = sum([(x)^i/i*(-1)^(i+1) for i=1:5000])
# compare with log(1+x)
What are the main options for deep learning?
What features are needed?
Julia should be perfecty positioned
But deep learning frameworks might not have reached critical mass. You can still try: