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

Control rounding for many functions #56

Merged
merged 12 commits into from
Oct 14, 2015
Merged

Control rounding for many functions #56

merged 12 commits into from
Oct 14, 2015

Conversation

lbenet
Copy link
Member

@lbenet lbenet commented Sep 20, 2015

This is some work to get tighter control of Interval{Float64}. It involves work in make_interval, in order to get as tight as possible intervals when @interval(a) is used. It also includes some handling of @round, and work to get the correct behavior of the arithmetic operations and the elementary function.

@@ -32,7 +32,3 @@ end
macro biginterval(expr1, expr2...)
make_interval(BigFloat, expr1, expr2)
end

macro make_interval(T, expr1, expr2...)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove this macro? It allows to specify the type of the interval desired.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was never used...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True... But it seemed like it might be useful. Feel free to delete!

lnea = @with_rounding($T, $expr1, RoundNearest)
ldow = @with_rounding($T, $expr1, RoundDown)
lup = @with_rounding($T, $expr1, RoundUp)
lo = ifelse(lnea != ldow && lnea != lup, lnea, ldow)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this line doing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's in the comment above :-) The idea is that the correct rounding should leave on of the roundings fixed to nearest, unless you really get the zero-distance for nearest rounding. It yields quite consistent things with respect to the IRF1788 tests.

@dpsanders
Copy link
Member

I can't check the make_interval stuff in detail right now. What's the overall plan?

@lbenet
Copy link
Member Author

lbenet commented Sep 20, 2015

The simple idea is to get the tightest possible interval for @interval(a) and the other related macros.

The subtle thing, which we will need to discuss (but not now), is make_interval(Float64,x::Irrational), since we use BigFloats to get the correct thing, and this is precision dependent. I decided to construct it with 53-bits BigFloats, but that has consequences in interval_parameters, which I haven't been able to solve.

In my machine tests pass correctly... I'll check this tomorrow.

@lbenet
Copy link
Member Author

lbenet commented Oct 2, 2015

Problems with travis; see #59

@lbenet
Copy link
Member Author

lbenet commented Oct 2, 2015

In ma machine, with v0.4, tests pass...

@lbenet
Copy link
Member Author

lbenet commented Oct 2, 2015

New commit; now all tests in the ITF1788 suite pass, including all the currently defined trigonometric functions and (&^%$!@*) ^. Travis is yielding some problems which I don't understand. Can you take a look on those problems to see what has to be done?

Something to be done is certainly related to #59 ...

@dpsanders
Copy link
Member

Great work!!

This failure is JuliaLang/julia#13399

I don't know what we can do about it.

@dpsanders
Copy link
Member

I have added functions of the form sin(x, RoundUp) etc. in the mpfr_functions branch of
CRlibm.jl These should eventually go in Base but for now they are fine in CRlibm.jl.

This will enable us to go back and simplify the code again. But this will need a new tagged version of CRlibm etc. For the moment we can go ahead with your current version.

@lbenet
Copy link
Member Author

lbenet commented Oct 2, 2015

It certainly would be nice if sin(x, RoundDown) works also for BigFloats; for the time being I think it is fine to leave it like this.

@lbenet
Copy link
Member Author

lbenet commented Oct 2, 2015

I am implementing other functions to get as much compliance with the standard as we can...

@dpsanders
Copy link
Member

👍

@dpsanders
Copy link
Member

I think any actually new functions should go in a new PR.

@lbenet lbenet changed the title WIP: Control rounding ~~WIP:~~ Control rounding for many functions Oct 3, 2015
@lbenet lbenet changed the title ~~WIP:~~ Control rounding for many functions Control rounding for many functions Oct 3, 2015
@lbenet
Copy link
Member Author

lbenet commented Oct 3, 2015

Ok. So I'll stop it here; I already have the hyperbolic functions (sinh and cosh), since the remaining are not supported by CRlibm.

So this is ready for reviewing, but merging it should wait until we deprecate support of version 0.3.

@dpsanders
Copy link
Member

And put the Julia requirement in REQUIRE as julia 0.4- for now.
(Or we can put 0.4 and wait til it comes out in a few days.)

@dpsanders dpsanders mentioned this pull request Oct 6, 2015
@dpsanders
Copy link
Member

There are real test failures on Travis.
Do you have any idea what is happening?

Are these the same kind of inconsistent rounding errors that I was seeing a couple of months ago?

@dpsanders
Copy link
Member

The tests pass on my machine. These things are really annoying.

Luis Benet added 4 commits October 7, 2015 01:24
…tion

Changes in make_interval and convert methods. Currently, the only subtle
case is when make_interval(Interval{T},Interval) is invoked, in the sense
that the resulting interval may become wider due to rounding.
ITF1788 tests of these functions pass
function -{T<:Real}(a::Interval{T}, b::Interval{T})
(isempty(a) || isempty(b)) && return emptyinterval(T)
a + (-b) # @round(a.lo - b.hi, a.hi - b.lo)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a + (-b) will do the same thing, but no harm in being explicit.

@dpsanders
Copy link
Member

Great work, thanks!!

@dpsanders
Copy link
Member

I'm ready to merge this once you've fixed my minor comments!

@lbenet
Copy link
Member Author

lbenet commented Oct 14, 2015

Except for the part about AbstractFloat in this comment, your comments have been implemented in 92ac0b3.

Tests pass (locally) as well as ITF1788 tests. Let's see what travis says...

@lbenet
Copy link
Member Author

lbenet commented Oct 14, 2015

And thanks a lot for the very careful review!

dpsanders added a commit that referenced this pull request Oct 14, 2015
Control rounding for many functions
@dpsanders dpsanders merged commit b5c6070 into master Oct 14, 2015
@dpsanders dpsanders deleted the control_rounding branch October 14, 2015 13:18
@lbenet lbenet mentioned this pull request Oct 14, 2015
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.

2 participants