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

domain_error/3 for floats? #2767

Open
dcnorris opened this issue Jan 11, 2025 · 3 comments
Open

domain_error/3 for floats? #2767

dcnorris opened this issue Jan 11, 2025 · 3 comments

Comments

@dcnorris
Copy link

dcnorris commented Jan 11, 2025

In implementing some numeric predicates, I would like to be able to throw useful errors when arguments fall outside their domains. It looks to me as if the number-related predicates in library(error) deal only with integers.

Related to #1309 perhaps.

@UWN
Copy link

UWN commented Jan 11, 2025

Examples? Often, there is an evaluation_error like in 9.3.1.3 Errors (of (**)/2)

@dcnorris
Copy link
Author

dcnorris commented Jan 11, 2025

In gamma/2 as implemented here, it might be reasonable to reject negative integral values of X, where the function is undefined. Letting the Rust code in crate puruspe be in charge of matters results in this:

?- use_module(library(numerics/special_functions)).
   true.
?- gamma(-1, Gamma).
   Gamma = -2.5653050788007548e16.

image

@UWN
Copy link

UWN commented Jan 13, 2025

This looks very similar to 1/x where at x = 0 there is one such point which can be seen as being both +∞ and -∞.

?- X = 0, Y is X ** -1.
   error(evaluation_error(undefined),(is)/2).
?- X = 0, Y is 1/X.
   error(evaluation_error(zero_divisor),(/)/2).

Assigning to this a domain seems to be quite artificial, as in some sense there are two values. There used to be that +−∞ in proximity to some Unum version. Not sure how Type III takes it.

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