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

Question about intervals of exp #80

Closed
FavioVazquez opened this issue Nov 4, 2015 · 5 comments
Closed

Question about intervals of exp #80

FavioVazquez opened this issue Nov 4, 2015 · 5 comments

Comments

@FavioVazquez
Copy link
Contributor

Hello, I have a question about using the implemented function exp and the e number in Julia. I was trying some stuff and I found this,

julia> println(@interval(e))
[2.718281828459045, 2.7182818284590455]
julia> println(exp(@interval(1)))
[2.718281828459045, 2.718281828459045]

And of course:

julia> @interval(e) == exp(@interval(1))
false

There is an extra 5 in the the println(@interval(e)) as you can see.

So I was wondering, shouldn't this be equal? or this I'm thinking the wrong way about this.

@lbenet
Copy link
Member

lbenet commented Nov 4, 2015

Thanks for reporting! I get the same as you using the tagged version v0.1.3.

Switch to master and you get the expected tight interval. Lot is going on at the moment, and we are getting close to full compliance with the ITF1788 Std for interval arithmetic; then, a new version will be released (see #31).

This is what I get in master:

julia> Pkg.checkout("ValidatedNumerics")
INFO: Checking out ValidatedNumerics master...
INFO: Pulling ValidatedNumerics latest master...
INFO: No packages to install, update or remove

julia> Pkg.status("ValidatedNumerics")
 - ValidatedNumerics             0.1.3+             master

julia> using ValidatedNumerics
INFO: Recompiling stale cache file /Users/benet/.julia/lib/v0.5/ValidatedNumerics.ji for module ValidatedNumerics.

julia> println(@interval(eu))
[2.718281828459045, 2.7182818284590455]

julia> println(exp(@interval(1)))
[2.718281828459045, 2.7182818284590455]

@FavioVazquez
Copy link
Contributor Author

Great thanks for answering, switching to master

@dpsanders
Copy link
Member

Thanks for trying out the package.

Note that in Julia, every expression returns an answer, so you don't need to use println. Also, since v0.1 you can use @interval outside an expression and it will replace all literal values, e.g. the 1 above, with interval versions. Using the current master branch:

julia> @interval(eu)
[2.718281828459045, 2.7182818284590455]

julia> @interval exp(1)
[2.718281828459045, 2.7182818284590455]

@dpsanders
Copy link
Member

[We have used the (built-in) name eu instead of e for the Euler constant since you often want to define a variable called e in your code, which will override the built-in e, whereas you (almost) never want to define something called eu. In any case, it is safer to use exp(1).]

@FavioVazquez
Copy link
Contributor Author

Oh I see. Thanks for the tip! I'll let you know later about what I'm doing with it and the results.

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

3 participants