-
-
Notifications
You must be signed in to change notification settings - Fork 517
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
base: develop
Are you sure you want to change the base?
Conversation
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
Documentation preview for this PR (built with commit 10823d4; changes) is ready! 🎉 |
You should be able to add doctests showing the simplifications are occurring in the output. I imagine
|
one test has to be fixed:
and the same in |
adding one doctest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just will wait for a green bot before a positive review.
Trivial failures in
|
the failures are not so trivial to fix, and keep their meaning |
From ad4c750bfb1ab05a2bcf06247e1baec44506fb58 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= <[email protected]>
Date: Tue, 4 Feb 2025 21:51:54 +0100
Subject: [PATCH] fixing the doctests
---
src/doc/de/thematische_anleitungen/sage_gymnasium.rst | 8 +-------
src/sage/geometry/hyperbolic_space/hyperbolic_geodesic.py | 4 ++--
.../premierspas_doctest.py | 2 +-
3 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/src/doc/de/thematische_anleitungen/sage_gymnasium.rst b/src/doc/de/thematische_anleitungen/sage_gymnasium.rst
index 9dc38d8bf0b..dfeb3e13c82 100644
--- a/src/doc/de/thematische_anleitungen/sage_gymnasium.rst
+++ b/src/doc/de/thematische_anleitungen/sage_gymnasium.rst
@@ -774,8 +774,7 @@ falls wir im Bogenmass rechnen möchten. Ansonsten müssen wir wie oben beschrie
Ihre Umkehrfunktionen sind auch mit den nicht sehr überraschenden Namen ``asin()``, ``acos()``, ``atan()`` und ``acot()`` versehen.
Sie geben uns aber wie oben erklärt nur Winkel im Bogenmass zurück. Möchten wir im Gradmass rechnen, müssen wir wieder
-konvertieren. Die exakte Berechnung der Werte funktioniert in die Gegenrichtung nur, falls im ursprünglichen Wert keine
-Wurzeln vorkommen::
+konvertieren. Exakte Berechnung der Werte funktioniert, wenn es möglich ist::
sage: atan(1)
1/4*pi
@@ -784,12 +783,7 @@ Wurzeln vorkommen::
sage: rad2deg(x) = x*(180/pi)
sage: rad2deg(acos(-1/2))
120
-
-Falls wir Wurzelterme verwenden, müssen wir mit der Funktion ``simplify_full()`` vereinfachen::
-
sage: acos(sqrt(3)/2)
- arccos(1/2*sqrt(3))
- sage: (acos(sqrt(3)/2)).simplify_full()
1/6*pi
Sage kann auch weitere Regeln für trigonometrische Funktionen anwenden, um Terme zu vereinfachen. Es kennt zum Beispiel auch die
diff --git a/src/sage/geometry/hyperbolic_space/hyperbolic_geodesic.py b/src/sage/geometry/hyperbolic_space/hyperbolic_geodesic.py
index b9488e77b16..52f889f30d1 100644
--- a/src/sage/geometry/hyperbolic_space/hyperbolic_geodesic.py
+++ b/src/sage/geometry/hyperbolic_space/hyperbolic_geodesic.py
@@ -1854,9 +1854,9 @@ class HyperbolicGeodesicUHP(HyperbolicGeodesic):
sage: g = HyperbolicPlane().UHP().get_geodesic(1, 1 + I)
sage: h = HyperbolicPlane().UHP().get_geodesic(-sqrt(2), sqrt(2))
sage: g.angle(h)
- arccos(1/2*sqrt(2))
+ 1/4*pi
sage: h.angle(g)
- arccos(1/2*sqrt(2))
+ 1/4*pi
Angle is unoriented, as opposed to oriented. ::
diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/premierspas_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/premierspas_doctest.py
index feb5391b4d6..027c31eecfe 100644
--- a/src/sage/tests/books/computational-mathematics-with-sagemath/premierspas_doctest.py
+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/premierspas_doctest.py
@@ -65,7 +65,7 @@ Sage example in ./premierspas.tex, line 952::
Sage example in ./premierspas.tex, line 967::
sage: arccos(sin(pi/3))
- arccos(1/2*sqrt(3))
+ 1/6*pi
sage: sqrt(2)
sqrt(2)
sage: exp(I*pi/7)
--
2.43.0
|
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 inacos_eval
. I copy-pasted the logic fromasin_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
⌛ Dependencies
None!