JuliaDiff / DualNumbers.jl

Julia package for representing dual numbers and for performing dual algebra
Other
80 stars 30 forks source link

Consider renaming realpart to value or primalpart or similar #81

Open jwscook opened 3 years ago

jwscook commented 3 years ago

This package works a treat for evaluating the derivative functions at complex locations:

julia> using DualNumbers

julia> f(x) = (1, -2 *x) .* exp(-x^2) # value and derivative
f (generic function with 1 method)

julia> z = 1.0 + im # some complex location to evaluate the derivative
1.0 + 1.0im

julia> f(z)
(-0.4161468365471424 - 0.9092974268256817im, -0.9863011805570786 + 2.650888526745648im)

julia> realpart(f(Dual(z, 1))[1])
-0.4161468365471424 - 0.9092974268256817im

julia> dualpart(f(Dual(z, 1))[1])
-0.9863011805570786 + 2.650888526745648im

In this instance, realpart returns a complex value, which is a little misleading. @goretkin suggested in Slack that primalpart could be a better adjective. Any thoughts?