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

Expose domain of functions #661

Open
dpsanders opened this issue May 29, 2024 · 5 comments
Open

Expose domain of functions #661

dpsanders opened this issue May 29, 2024 · 5 comments

Comments

@dpsanders
Copy link
Member

dpsanders commented May 29, 2024

Currently the user has no way of knowing which domain a function is defined over.

We should define e.g.

domain(sqrt) = 0..Inf

or domain_interval(sqrt).

@OlivierHnt
Copy link
Member

I do not think we should do this. Sometimes the domain is not closed, eg for log.

However I think this should appear in the docstring of sqrt.

@dpsanders
Copy link
Member Author

Good point about the domain for log.
Nonetheless I think there ideally should be some way for the user to obtain this information programatically.

@OlivierHnt
Copy link
Member

In the end, this is truly a math question and not interval related.
How the domain relates to intervals (which is what matters for the library) depends on the function (what we do for sqrt is different than what we do for other functions).

That being said, we can leave this issue open for a little while and see if someone comes up with something.
But I suspect that this is a matter of documentation.

@dpsanders
Copy link
Member Author

The reason I was thinking about this is that I wanted to do something like Piecewise(sqrt, extend=0) meaning "extend sqrt with 0 outside its domain of definition", but that requires programmatic access to the domain.

@OlivierHnt
Copy link
Member

OlivierHnt commented May 31, 2024

Oh I see, interesting!

Then Piecewise(log, extend = 0) would also work I think, or even Piecewise(asec; extend = 0).
The logic for this feature is more like a isindomain function (which resolves the issue of having to deal with non closed domains since it does not attempt to return the domain as an interval).

Something in the vein of

isindomain(::typeof(sqrt), x::Float64) = 0 <= x

isindomain(::typeof(sqrt), x::Interval) = issubset_interval(x, interval(0, Inf))

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