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

Some trivial identities and simplifications missed by Sage (pynac ?) #24211

Open
EmmanuelCharpentier mannequin opened this issue Nov 13, 2017 · 11 comments · May be fixed by #36069
Open

Some trivial identities and simplifications missed by Sage (pynac ?) #24211

EmmanuelCharpentier mannequin opened this issue Nov 13, 2017 · 11 comments · May be fixed by #36069

Comments

@EmmanuelCharpentier
Copy link
Mannequin

EmmanuelCharpentier mannequin commented Nov 13, 2017

On 8.1.rc0. Consider :

sage: import sympy
sage: [arcsin(t) for t in [0, 1/2, sqrt(2)/2, sqrt(3)/2, 1]]
[0, 1/6*pi, arcsin(1/2*sqrt(2)), arcsin(1/2*sqrt(3)), 1/2*pi]
sage: [maxima.asin(t).sage() for t in [0, 1/2, sqrt(2)/2, sqrt(3)/2, 1]]
[0, 1/6*pi, 1/4*pi, 1/3*pi, 1/2*pi]
sage: [sympy.asin(t)._sage_() for t in [0, 1/2, sqrt(2)/2, sqrt(3)/2, 1]]
[0, 1/6*pi, 1/4*pi, 1/3*pi, 1/2*pi]
sage: [arctan(t) for t in [0, 1/sqrt(3), 1, sqrt(3)]]
[0, arctan(1/3*sqrt(3)), 1/4*pi, arctan(sqrt(3))]
sage: [maxima.atan(t).sage() for t in [0, 1/sqrt(3), 1, sqrt(3)]]
[0, 1/6*pi, 1/4*pi, 1/3*pi]
sage: [sympy.atan(t)._sage_() for t in [0, 1/sqrt(3), 1, sqrt(3)]]
[0, 1/6*pi, 1/4*pi, 1/3*pi]

[ Edit on 2017-11-23 ] In the same vein :

sage: [arccos(t) for t in [0, 1/2, sqrt(2)/2, sqrt(3)/2, 1]]
[1/2*pi, 1/3*pi, arccos(1/2*sqrt(2)), arccos(1/2*sqrt(3)), 0]
sage: [maxima.arccos(t).sage() for t in [0, 1/2, sqrt(2)/2, sqrt(3)/2, 1]]
[1/2*pi, 1/3*pi, arccos(1/2*sqrt(2)), arccos(1/2*sqrt(3)), 0]
sage: [sympy.acos(t)._sage_() for t in [0, 1/2, sqrt(2)/2, sqrt(3)/2, 1]]
[1/2*pi, 1/3*pi, 1/4*pi, 1/6*pi, 0]
sage: [arctan(t) for t in [0, 1/sqrt(3), 1, sqrt(3)]]
[0, arctan(1/3*sqrt(3)), 1/4*pi, arctan(sqrt(3))]
sage: [maxima.arctan(t).sage() for t in [0, 1/sqrt(3), 1, sqrt(3)]]
[0, arctan(1/3*sqrt(3)), 1/4*pi, arctan(sqrt(3))]
sage: [sympy.atan(t)._sage_() for t in [0, 1/sqrt(3), 1, sqrt(3)]]
[0, 1/6*pi, 1/4*pi, 1/3*pi]

This is not a bug stricto sensu (the answers are not false), but is certainly a lack of functionality.

The absence of this problem when using sympy or maxima fingerpoints to pynac.

Furthermore, arctan suffers from some lack of simplification:

sage: assume(-pi/2<x, x<pi/2)  
sage: arctan(tan(x)).simplify()  # OK
x
sage: arctan(sin(x)/cos(x)).simplify()   # should return x as above
arctan(sin(x)/cos(x))
sage: arctan(sin(x)/cos(x)).simplify_full()
arctan(sin(x)/cos(x))

arctan2 has the same issue:

sage: arctan2(sin(x), cos(x)).simplify_full()
arctan2(sin(x), cos(x))

In those cases, the problem is not solved by recourse to pynac...

Depends on #24262

Component: symbolics

Issue created by migration from https://trac.sagemath.org/ticket/24211

@EmmanuelCharpentier EmmanuelCharpentier mannequin added this to the sage-8.1 milestone Nov 13, 2017
@rwst
Copy link

rwst commented Nov 13, 2017

comment:1

Is sin(x)/cos(x) simplifiable for all x to tan(x)?

@egourgoulhon
Copy link
Member

comment:2

Replying to @rwst:

Is sin(x)/cos(x) simplifiable for all x to tan(x)?

I would say yes, see e.g.

@egourgoulhon
Copy link
Member

comment:3

Replying to @egourgoulhon:

Replying to @rwst:

Is sin(x)/cos(x) simplifiable for all x to tan(x)?

I would say yes, see e.g.

Moreover, Sage assumes it is the case, without any assumption on x:

sage: bool(tan(x) == sin(x)/cos(x))
True

@egourgoulhon egourgoulhon changed the title Sime trivial identities and simplifications missed by Sage (pynac ?) Some trivial identities and simplifications missed by Sage (pynac ?) Nov 13, 2017
@rwst
Copy link

rwst commented Nov 14, 2017

comment:5

Replying to @egourgoulhon:

Moreover, Sage assumes it is the case, without any assumption on x:

sage: bool(tan(x) == sin(x)/cos(x))
True

That comes from Maxima which simplifies tan(x) to sin(x)/cos(x)---but not vice versa, as the atan cases show. It may be difficult to find sin(x)/cos(x) in all expressions but I haven't looked further into it, and the simple cases should be implemented regardless.

@rwst
Copy link

rwst commented Nov 21, 2017

Dependencies: pynac-0.7.13

@rwst
Copy link

rwst commented Nov 21, 2017

comment:6

These doctest now work with Pynac master:

sage: [arcsin(t) for t in [0, 1/2, sqrt(2)/2, sqrt(3)/2, 1]]
[0, 1/6*pi, 1/4*pi, 1/3*pi, 1/2*pi]
sage: [arcsin(-t) for t in [0, 1/2, sqrt(2)/2, sqrt(3)/2, 1]]
[0, -1/6*pi, -1/4*pi, -1/3*pi, -1/2*pi]
sage: [arctan(t) for t in [0, 1/sqrt(3), 1, sqrt(3)]]
[0, 1/6*pi, 1/4*pi, 1/3*pi]
sage: [arctan(-t) for t in [0, 1/sqrt(3), 1, sqrt(3)]]
[0, -1/6*pi, -1/4*pi, -1/3*pi]

@rwst rwst modified the milestones: sage-8.1, sage-8.2 Nov 21, 2017
@rwst
Copy link

rwst commented Nov 21, 2017

Changed dependencies from pynac-0.7.13 to #24262

@EmmanuelCharpentier
Copy link
Mannequin Author

EmmanuelCharpentier mannequin commented Nov 22, 2017

comment:8

#24262 partially fixes some of these deficiencies. See its initial review.

@EmmanuelCharpentier

This comment has been minimized.

@EmmanuelCharpentier
Copy link
Mannequin Author

EmmanuelCharpentier mannequin commented Nov 23, 2017

comment:9

Edit : added similar examples with arccos/arctan.

@mkoeppe mkoeppe removed this from the sage-8.2 milestone Dec 29, 2022
This was referenced Dec 12, 2017
rhinopotamus added a commit to rhinopotamus/sage that referenced this issue Aug 10, 2023
This fixes a couple of places where arccos doesn't automatically simplify for ratios arising from the unit circle (but arcsin does). Turns out that asin_eval has some logic handling unit circle cases directly that was not replicated in acos_eval. I copy-pasted the logic from asin_eval and modified appropriately.

sagemath#24211
@rhinopotamus rhinopotamus linked a pull request Aug 10, 2023 that will close this issue
5 tasks
@rhinopotamus
Copy link

This pull request may not close the issue entirely. There is probably still more to do with arctangent.

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

Successfully merging a pull request may close this issue.

4 participants