Skip to content

ForwardDiff with Interval partials - #769

Open
timholy wants to merge 1 commit into
JuliaIntervals:masterfrom
timholy:teh/fd
Open

ForwardDiff with Interval partials#769
timholy wants to merge 1 commit into
JuliaIntervals:masterfrom
timholy:teh/fd

Conversation

@timholy

@timholy timholy commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

This change supports differentiation of functions with interval-valued partials, like

x, w = 2.0, interval(-0.5, 0.5)
ForwardDiff.derivative(t -> (x + t*w)^4, 0.0)

Previously, those failed due to a short-circuit in ForwardDiff, triggering

ERROR: InconclusiveBooleanOperation: The operation
`[0.0, 0.0]_com == [-0.5, 0.5]_com_NG` cannot be determined
unambiguously.

This short-circuits the short-circuit, by specializing Base.iszero on Interval-containing ForwardDiff.Dual and ForwardDiff.Partials. No behavior change in IntervalArithmetic itself is needed.

This change supports differentiation of functions with interval-valued
partials, like

    x, w = 2.0, interval(-0.5, 0.5)
    ForwardDiff.derivative(t -> (x + t*w)^4, 0.0)

Previously, those failed due to a short-circuit in ForwardDiff,
triggering

    ERROR: InconclusiveBooleanOperation: The operation
    `[0.0, 0.0]_com == [-0.5, 0.5]_com_NG` cannot be determined
    unambiguously.

This short-circuits the short-circuit, by specializing `Base.iszero` on
Interval-containing `ForwardDiff.Dual` and `ForwardDiff.Partials`. No
behavior change in IntervalArithmetic itself is needed.
@codecov-commenter

codecov-commenter commented Jul 23, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 75.35%. Comparing base (63f84ee) to head (b2d8a2b).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
ext/IntervalArithmeticForwardDiffExt.jl 80.00% 1 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #769      +/-   ##
==========================================
- Coverage   75.48%   75.35%   -0.14%     
==========================================
  Files          32       32              
  Lines        3100     3112      +12     
==========================================
+ Hits         2340     2345       +5     
- Misses        760      767       +7     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@OlivierHnt

Copy link
Copy Markdown
Member

I am not sure in what context ForwardDiff.Dual and ForwardDiff.Partials show up. Ideally we probably want the dual and the number to have the same behavior.
Anyways, it's maybe unlikely that someone uses these types in a very different context so this PR can be a quick temporary "hot fix" and paired up with JuliaDiff/ForwardDiff.jl#667 so that _iszero (the helper function that checks exact thin equality with zero) lives inside ForwardDiff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants