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

ValueError: intersection of ellipse #15283

Open
Jinchao-Yu opened this issue Sep 24, 2018 · 2 comments
Open

ValueError: intersection of ellipse #15283

Jinchao-Yu opened this issue Sep 24, 2018 · 2 comments
Labels

Comments

@Jinchao-Yu
Copy link

Env: sympy-1.3 (mpmath-1.0.0), on Linux
Issue: The computing of intersection of 2 ellipses can sometimes raise issues. For example,
el1 = Ellipse(Point(0, 0), 2, 1)
el2 = Ellipse(Point(5, 0), 2, 1)
el3 = Ellipse(Point(3, 5), 4, 3)
el1.intersect(el2) # good, no intersection, but has Complex solutions in maths.
el1.intersect(el3) # ValueError: Imaginary coordinates are not permitted

@sylee957
Copy link
Member

sylee957 commented Sep 26, 2018

I think this issue is caused by equation solver giving some overcomplicated solution containing imaginary number like

[(1013/54 - 40*sqrt(669/25 + 1476909/(1250*(1757521827/125000 + 6561*sqrt(30812995)*I/12500)**(1/3)) + 2*(1757521827/125000 + 6561*sqrt(30812995)*I/12500)**(1/3))/27 - 10*(-4 + sqrt(1338/25 - 2*(1757521827/125000 + 6561*sqrt(30812995)*I/12500)**(1/3) + 11664/(25*sqrt(669/25 + 1476909/(1250*(1757521827/125000 + 6561*sqrt(30812995)*I/12500)**(1/3)) + 2*(1757521827/125000 + 6561*sqrt(30812995)*I/12500)**(1/3))) - 1476909/(1250*(1757521827/125000 + 6561*sqrt(30812995)*I/12500)**(1/3)))/2 + sqrt(669/25 + 1476909/(1250*(1757521827/125000 + 6561*sqrt(30812995)*I/12500)**(1/3)) + 2*(1757521827/125000 + 6561*sqrt(30812995)*I/12500)**(1/3))/2)**2/27 - 40*sqrt(1338/25 - 2*(1757521827/125000 + 6561*sqrt(30812995)*I/12500)**(1/3) + 11664/(25*sqrt(669/25 + 1476909/(1250*(1757521827/125000 + 6561*sqrt(30812995)*I/12500)**(1/3)) + 2*(1757521827/125000 + 6561*sqrt(30812995)*I/12500)**(1/3))) - 1476909/(1250*(1757521827/125000 + 6561*sqrt(30812995)*I/12500)**(1/3)))/27, -4 + sqrt(1338/25 - 2*(1757521827/125000 + 6561*sqrt(30812995)*I/12500)**(1/3) + 11664/(25*sqrt(669/25 + 1476909/(1250*(1757521827/125000 + 6561*sqrt(30812995)*I/12500)**(1/3)) + 2*(1757521827/125000 + 6561*sqrt(30812995)*I/12500)**(1/3))) - 1476909/(1250*(1757521827/125000 + 6561*sqrt(30812995)*I/12500)**(1/3)))/2 + sqrt(669/25 + 1476909/(1250*(1757521827/125000 + 6561*sqrt(30812995)*I/12500)**(1/3)) + 2*(1757521827/125000 + 6561*sqrt(30812995)*I/12500)**(1/3))/2), (1013/54 + 40*sqrt(1338/25 - 2*(1757521827/125000 + 6561*sqrt(30812995)*I/12500)**(1/3) + 11664/(25*sqrt(669/25 + 1476909/(1250*(1757521827/125000 + 6561*sqrt(30812995)*I/12500)**(1/3)) + 2*(1757521827/125000 + 6561*sqrt(30812995)*I/12500)**(1/3))) - 1476909/(1250*(1757521827/125000 + 6561*sqrt(30812995)*I/12500)**(1/3)))/27 - 10*(-4 + sqrt(669/25 + 1476909/(1250*(1757521827/125000 + 6561*sqrt(30812995)*I/12500)**(1/3)) + 2*(1757521827/125000 + 6561*sqrt(30812995)*I/12500)**(1/3))/2 - sqrt(1338/25 - 2*(1757521827/125000 + 6561*sqrt(30812995)*I/12500)**(1/3) + 11664/(25*sqrt(669/25 + 1476909/(1250*(1757521827/125000 + 6561*sqrt(30812995)*I/12500)**(1/3)) + 2*(1757521827/125000 + 6561*sqrt(30812995)*I/12500)**(1/3))) - 1476909/(1250*(1757521827/125000 + 6561*sqrt(30812995)*I/12500)**(1/3)))/2)**2/27 - 40*sqrt(669/25 + 1476909/(1250*(1757521827/125000 + 6561*sqrt(30812995)*I/12500)**(1/3)) + 2*(1757521827/125000 + 6561*sqrt(30812995)*I/12500)**(1/3))/27, -4 + sqrt(669/25 + 1476909/(1250*(1757521827/125000 + 6561*sqrt(30812995)*I/12500)**(1/3)) + 2*(1757521827/125000 + 6561*sqrt(30812995)*I/12500)**(1/3))/2 - sqrt(1338/25 - 2*(1757521827/125000 + 6561*sqrt(30812995)*I/12500)**(1/3) + 11664/(25*sqrt(669/25 + 1476909/(1250*(1757521827/125000 + 6561*sqrt(30812995)*I/12500)**(1/3)) + 2*(1757521827/125000 + 6561*sqrt(30812995)*I/12500)**(1/3))) - 1476909/(1250*(1757521827/125000 + 6561*sqrt(30812995)*I/12500)**(1/3)))/2)]

And the solver's assumption checker is not properly working for this specific expression.

@RishobGuhaPatra
Copy link

Hey, I would love to help with this issue! Please guide me to what needs to be done!

sylee957 added a commit to sylee957/sympy that referenced this issue Oct 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants