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

Improve the accuracy of real acos #19

Merged
merged 1 commit into from
Jul 30, 2024
Merged

Improve the accuracy of real acos #19

merged 1 commit into from
Jul 30, 2024

Conversation

pearu
Copy link
Owner

@pearu pearu commented Jul 30, 2024

As in the title:

-| acos | float32 | 548396 | 444291 | 7072 | 242 | - | - |
-| acos | float64 | 985930 | 12727 | 1338 | 6 | - | - |
+| acos | float32 | 961608 | 38291 | 99 | 3 | - | - |
+| acos | float64 | 992582 | 7416 | 3 | - | - | - |

The trick is to use identity arccos(x) = arctan2(sqrt(1 - x*x), x). Btw, this is the formula to which Hull et al algorithm also reduces when restricting to the real line.

@pearu pearu merged commit 5504909 into main Jul 30, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant