JuliaDiff / JuliaDiff/DualNumbers.jl
max when values agree?
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 80
- Forks
- 27
- PR merge metrics
- No merged PRs in 30d
Description
The partial derivative of max currently uses the Julia Base implementation:
max(x,y) = ifelse(y < x, x, y)
Unfortunately, this may cause incorrect results when the Dual values agree but the partials do not:
max(Dual(3,1), Dual(3,-1))
Here, the values are both 3 but the partials have opposite signs. I think the partial here may be undefined.
Maybe something like:
function Base.max(a::Dual, b::Dual)
if value(a) > value(b)
return a
elseif value(a) < value(b)
return b
else # value(a) == value(b)
return ifelse(epsilon(a) == epsilon(b), a, Dual(value(a), NaN))
end
end
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Begin with the Base.max behavior described in issue #53 and reproduce max(Dual(3,1), Dual(3,-1)). Before changing code, establish the expected result for equal values with equal and unequal partials; done means the chosen behavior is covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100