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

Trivial simplifications for arccos #36069

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

rhinopotamus
Copy link

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 in src/sage/symbolic/ginac/inifcns_trig.cpp, 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.

Partially fixes #24211.

I'm not sure exactly how to create tests covering this change but would be happy to do so with a little guidance!

📝 Checklist

  • The title is concise, informative, and self-explanatory.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation accordingly.

⌛ Dependencies

None!

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
@github-actions
Copy link

github-actions bot commented Aug 14, 2023

Documentation preview for this PR (built with commit caf0721; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@tscrim
Copy link
Collaborator

tscrim commented Sep 13, 2023

You should be able to add doctests showing the simplifications are occurring in the output. I imagine

sage: arcsin(sqrt(2)/2)
1/4*pi
sage: arccos(sqrt(2)/2)  # is simplified to 1/4*pi with your change
arccos(1/2*sqrt(2))

@fchapoton
Copy link
Contributor

fchapoton commented Oct 28, 2024

one test has to be fixed:

File "src/doc/de/thematische_anleitungen/sage_gymnasium.rst", line 790, in doc.de.thematische_anleitungen.sage_gymnasium
Failed example:
    acos(sqrt(3)/2)
Expected:
    arccos(1/2*sqrt(3))
Got:
    1/6*pi

and the same in src/sage/tests/books/computational-mathematics-with-sagemath/premierspas_doctest.py

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

Successfully merging this pull request may close these issues.

Some trivial identities and simplifications missed by Sage (pynac ?)
4 participants