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

Construction of interval when mixing real and complex arguments #611

Merged
merged 1 commit into from
Jan 8, 2024

Conversation

Joel-Dahne
Copy link
Contributor

When constructing an interval from one real and one complex argument I expected it to treat the imaginary part of the real argument as zero. What happens is instead that it takes the imaginary part of the interval to only depend on the complex argument, e.g.

julia> interval(0, complex(1, 1))
[0.0, 1.0]_com + ([1.0, 1.0]_com)im

Compare this to what we get if we make the first argument complex

julia> interval(complex(0), complex(1, 1))
[0.0, 1.0]_com + ([0.0, 1.0]_com)im

This behavior could of course be by design, but since there are no tests for it I would guess that it is just a mistake. Since we have isequal(0, complex(0)) it seems natural that they would both give the same result.

This PR changes it so that the real argument is treated as a complex argument with imaginary part zero. So we would get identical results for the two above constructors. Feel free to discard this if the original behavior is indeed intended.

I also noticed that there are no constructors for BareInterval from Complex. This would maybe be by design though? Since in general BareInterval is intended to be very "bare".

With the update it treats the real argument as having imaginary part
zero. The previous behaviour was to only consider the imaginary part
of the complex argument.
@OlivierHnt
Copy link
Member

Good catch, thx for opening this PR 🙂
We are still lacking a thorough complex support (see e.g. #41 and #295).

LGTM

@Joel-Dahne
Copy link
Contributor Author

Constructing them is a good first step at least! 😃

@OlivierHnt
Copy link
Member

For sure 😆

@OlivierHnt OlivierHnt merged commit b2cad99 into JuliaIntervals:master Jan 8, 2024
16 checks passed
@Joel-Dahne Joel-Dahne deleted the complex-constructor branch January 8, 2024 15:04
@Joel-Dahne Joel-Dahne restored the complex-constructor branch January 8, 2024 15:07
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