JuliaDiff / DualNumbers.jl

Julia package for representing dual numbers and for performing dual algebra

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

don't use imag() for second component?

mlubin opened this issue · comments

@johnmyleswhite suggested and I agree that it's awkward to use imag to access the second component of the dual number. What about epsilon?

epsilon is the one I like the best from my list.

I agree with the choice of epsilon, it seems a better name indeed. I made the relevant change, so I will now close this issue.

Further to this: is conj standard terminology for using dual numbers?

conj may cause some confusion considering that it brings in mind complex conjugate, but if it is standard terminology for dual numbers, then it won't be confusing to users. To me dual sounds a bit more traditional, but I am not sure which one is better. Do you suggest that we change dual to conj?

I'm a bit confused about conj, abs, abs2, and inv. One should be able to drop in a Dual number into any function that takes a number and have it compute the derivative. Most use cases of dual numbers will be in user functions that don't know what dual numbers are, so the specialized meaning of conj, abs, etc., doesn't seem right.

Consider two different cases:
f(x) = abs(x)
Here to properly compute the derivative of f we want abs(x) = (real(x) >= 0.0) ? x : -x (returns a Dual)
f(x) = abs(x) < 1.0 ? 2x : -x
Here we want the result of abs to be comparable with a float.

Probably the right solution is to have abs return a Dual and implement comparison operators for Dual with Number that compares the real term of the Dual.

I agree with Miles: every generic function should mean the same thing for Dual Numbers as for real numbers.

I agree too with Miles' suggestion, John.

I'll set up a pull request.

The readme still talks about the "imaginary" part of Duals

while the imaginary part represents the fermionic direction

Updated, thanks @goretkin!