Skip to content
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

Problems with trigonometric functions for Float32 intervals #336

Closed
mfherbst opened this issue Nov 28, 2019 · 2 comments
Closed

Problems with trigonometric functions for Float32 intervals #336

mfherbst opened this issue Nov 28, 2019 · 2 comments

Comments

@mfherbst
Copy link
Contributor

I'm interested in using IntervalArithmetic with Float32 data types. At the moment I'm not that much interested in speed, more to get it to work.

There are currently some issues with some functions for Float32 intervals. For example

cos(Interval{Float32}(0.1))
ERROR: MethodError: no method matching pi_interval(::Type{Float32})
Closest candidates are:
  pi_interval(::Type{BigFloat}) at /home/herbstm/.julia/packages/IntervalArithmetic/1T5or/src/intervals/precision.jl:74
  pi_interval(::Type{Float64}) at /home/herbstm/.julia/packages/IntervalArithmetic/1T5or/src/intervals/precision.jl:75
Stacktrace:
 [1] two_pi(::Type{Float32}) at /home/herbstm/.julia/packages/IntervalArithmetic/1T5or/src/intervals/trigonometric.jl:18
 [2] cos(::Interval{Float32}) at /home/herbstm/.julia/packages/IntervalArithmetic/1T5or/src/intervals/trigonometric.jl:151
 [3] top-level scope at REPL[10]:1

Similarly

exp(Interval{Float32}(0.1))
ERROR: StackOverflowError:
Stacktrace:
 [1] exp(::Float32, ::RoundingMode{:Down}) at /home/herbstm/.julia/packages/CRlibm/2S9DB/src/CRlibm.jl:137 (repeats 80000 times)

which I have also reported here: JuliaIntervals/CRlibm.jl#32. There might be more things, but this is what I found so far.

@dpsanders
Copy link
Member

dpsanders commented Dec 13, 2019

This is now working with version 0.8 of CRlibm.
No changes were required to IntervalArithmetic!

julia> exp(Interval{Float32}(0.1))
[1.10517, 1.10518]

julia> cos(Interval{Float32}(0.1))
[0.995004, 0.995005]

julia> sin(Interval{Float32}(0.1))
[0.0998334, 0.0998335]

julia> log(Interval{Float32}(0.1))
[-2.30259, -2.30258]

julia> typeof(ans)
Interval{Float32}

@dpsanders
Copy link
Member

We may want to change show to show that these are intervals of Float32.

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

No branches or pull requests

2 participants