Closed andreasnoack closed 10 years ago
conj
is a bit confusing to think about, but I do know that conj{T<:Real}(d::Dual{T})
must be equal to d
, simply because conj(x::Real) = x
. Otherwise the derivative information isn't correct. We've chosen to define functions so that f(d::Dual) = Dual(f(real(d)),dual(d)*f'(real(d)))
always, even if this conflicts with the algebraic definition.
@andreasnoackjensen, @mlubin, what choice would you like us to make? I agree with @andreasnoackjensen' changes, as it seems more natural to me. Nevertheless, I see your point @mlubin, we don't want to violate differentiation.
When you want to use Dual
for differentiation of real functions you shouldn't use conj
in your code, right? Wouldn't it be better to document that instead of having non-standard behaviour?
Yes, I agree with your remark and suggestion @andreasnoackjensen. @mlubin, if you don't object, I would agree for these changes to be merged.
Unfortunately conj
is used in many places in Base, for example, in dot
and other vector operations. If we make this change, then dot
of two Vector{Dual}
s will not give the correct derivatives. I think it makes more sense to define a function conjdual
that has the algebraic definition. Of course, this behavior should be well documented.
@mlubin I see your point, and differentiation is the main point of the DualNumbers
, but it just feels wrong not to have the math definitions right.
I think these are fixes. See e.g. here