-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid convert
in ^
for literal powers
#619
Conversation
This is related to the test that fails: julia> f(x) = interval(2)^x
f (generic function with 1 method)
julia> f′(x) = log(interval(2)) * f(x)
f′ (generic function with 1 method)
julia> df(t) = ForwardDiff.derivative(f, t)
df (generic function with 1 method)
julia> f′(0) === df(0)
false
# But
julia> isequal_interval(f′(0), df(0))
true The subtlety in |
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #619 +/- ##
==========================================
- Coverage 83.56% 83.41% -0.16%
==========================================
Files 25 25
Lines 2142 2146 +4
==========================================
Hits 1790 1790
- Misses 352 356 +4 ☔ View full report in Codecov by Sentry. |
I will need to add tests. Perhaps it is also good time to increase the tests related to all the power functions and power modes. |
I have reverted previous changes too
071b285
to
255d9b2
Compare
Followed @OlivierHnt suggestion here; it seems to work nicely, distinguishing literal powers from whatever. (All previous changes have been reverted.) |
Looks good to me! Note (just as a memo): while julia> interval(1)^2305843009213693951
[1.0, 1.0]_com
julia> interval(1)^2305843009213693952 # any integer larger than this one will also have the NG flag
[1.0, 1.0]_com_NG Whether or not this is a bug, it is on Julia's side. |
I am on board with merging this PR. @Kolaru any thoughts? |
Good catch! I will check if I can find what's going on, but I guess this is some sort of rounding issue (due perhaps to the conversion to Float64), as commented here. |
For me it can be merged once the tests are there :) |
At the end of test/interval_tests/power.jl, we can just add something like @testset "Literal powers" begin
x = interval(1)
n = 2
@test isguaranteed(x ^ 2)
@test !isguaranteed(x ^ n)
@test_broken isguaranteed(x ^ 2.0)
@test_broken isguaranteed(x ^ 2305843009213693952)
end |
Co-autored by: Olivier Hénot <[email protected]>
Fix #618