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

Solveset fails with trig and symbols #17667

Open
oscarbenjamin opened this issue Sep 29, 2019 · 2 comments
Open

Solveset fails with trig and symbols #17667

oscarbenjamin opened this issue Sep 29, 2019 · 2 comments

Comments

@oscarbenjamin
Copy link
Contributor

Failing example:

In [2]: solveset(cos(x)-y, x, Interval(0, pi))                                                                                                 
Out[2]: {x | x  -y + cos(x) = 0}

Firstly the domain of the ConditionSet is wrong. It should be Interval(0, pi) not Reals.

Secondly cos is invertible over that domain so we should be able to get acos(y). We don't know that y is real and between -1 and 1 but a better answer could be

In [12]: FiniteSet(acos(y)) & Interval(0, pi)                                                                                                  
Out[12]: [0, π]  {acos(y)}
@oscarbenjamin
Copy link
Contributor Author

Also solveset returns very complicated answers with tan and irrational numbers:

In [17]: solveset(tan(x)-S.Half, x, Interval(0, pi/2))       
Out[17]: {atan(1/2)}

In [18]: solveset(tan(x)-sqrt(2), x, Interval(0, pi/2))                                                                                        
Out[18]: 
⎧   ⎛                                                       ⎛   ⎛atan(2⋅√2)⎞⎞⎞⎫
⎪   ⎜   ⎛    _____________________________________⎞         ⎜cos⎜──────────⎟⎟⎟⎪
⎪   ⎜   ⎜   ╱    2atan(2⋅√2)⎞      2atan(2⋅√2)⎞ ⎟         ⎜   ⎝    2     ⎠⎟⎟⎪
⎨-⎜log⎜  ╱  sin ⎜──────────⎟ + cos ⎜──────────⎟ ⎟ +atan⎜───────────────⎟⎟⎬
⎪   ⎜   ⎝╲╱       ⎝    2     ⎠       ⎝    2     ⎠ ⎠         ⎜   ⎛atan(2⋅√2)⎞⎟⎟⎪
⎪   ⎜                                                       ⎜sin⎜──────────⎟⎟⎟⎪
⎩   ⎝                                                       ⎝   ⎝    2     ⎠⎠⎠⎭

In [19]: solveset(tan(x)-pi, x, Interval(0, pi/2))                                                                                             
Out[19]: 
⎧   ⎛   ⎛            ________________________________________________________________________________________________________________________
⎪   ⎜   ⎜           ╱                                                ⎛    ⎛       2π       ⎞⎞                                               
⎪   ⎜   ⎜          ╱                                                 ⎜atan⎜─────────────────⎟⎟                                               
⎪   ⎜   ⎜         ╱                                                  ⎜    ⎜              4  ⎟⎟                                               
⎪   ⎜   ⎜        ╱            __________________________________     ⎜    ⎜    1        π   ⎟⎟           __________________________________  
⎪   ⎜   ⎜       ╱            ╱                                2      ⎜    ⎜- ────── + ──────⎟⎟          ╱                                2   
⎪   ⎜   ⎜      ╱            ╱        22  ⎞       ⎜    ⎜       2        2⎟⎟         ╱        22  ⎞    
⎨   ⎜   ⎜     ╱            ╱      4π      ⎜    1        π   ⎟      2⎜    ⎝  1 + π    1 + π ⎠⎟        ╱      4π      ⎜    1        π   ⎟    
⎪-⎜log⎜    ╱            ╱    ───────── +- ────── + ──────⎟  sin ⎜───────────────────────⎟ +     ╱    ───────── +- ────── + ──────⎟  c
⎪   ⎜   ⎜   ╱            ╱             22        2⎟       ⎝           2           ⎠      ╱             22        2⎟    
⎪   ⎜   ⎜  ╱            ╱      ⎛     2⎞    ⎝  1 + π    1 + π ⎠                                     ╱      ⎛     2⎞    ⎝  1 + π    1 + π ⎠    
⎪   ⎜   ⎝╲╱           ╲╱       ⎝1 + π ⎠                                                          ╲╱       ⎝1 + π ⎠                           
⎪   ⎜                                                                                                                                        
⎪   ⎜                                                                                                                                        
⎩   ⎝                                                                                                                                        

_____________________________⎞                            ⎞⎫
   ⎛    ⎛       2π       ⎞⎞ ⎟                            ⎟⎪
   ⎜atan⎜─────────────────⎟⎟ ⎟         ⎛   ⎛    ⎛ 2π  ⎞⎞⎞⎟⎪
   ⎜    ⎜              4  ⎟⎟ ⎟         ⎜   ⎜atan⎜──────⎟⎟⎟⎟⎪
   ⎜    ⎜    1        π   ⎟⎟ ⎟         ⎜   ⎜    ⎜     2⎟⎟⎟⎟⎪
   ⎜    ⎜- ────── + ──────⎟⎟ ⎟         ⎜   ⎜    ⎝1 - π ⎠⎟⎟⎟⎪
   ⎜    ⎜       2        2⎟⎟ ⎟         ⎜cos⎜────────────⎟⎟⎟⎪
  2⎜    ⎝  1 + π    1 + π ⎠⎟ ⎟         ⎜   ⎝     2      ⎠⎟⎟⎬
os ⎜───────────────────────⎟ ⎟ -atan⎜─────────────────⎟⎟⎪
   ⎝           2           ⎠ ⎟         ⎜   ⎛    ⎛ 2π  ⎞⎞⎟⎟⎪
                             ⎟         ⎜   ⎜atan⎜──────⎟⎟⎟⎟⎪
                             ⎠         ⎜   ⎜    ⎜     2⎟⎟⎟⎟⎪
                                       ⎜   ⎜    ⎝1 - π ⎠⎟⎟⎟⎪
                                       ⎜sin⎜────────────⎟⎟⎟⎪
                                       ⎝   ⎝     2      ⎠⎠⎠⎭

@gschintgen
Copy link
Contributor

Also solveset returns very complicated answers with tan and irrational numbers:

That's because equations of purely trigonometric nature end up in solve_trig which currently doesn't call _invert. See also: #17334

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants