Skip to content

Add up two arctangents, and name the angles arctan knows - #692

Merged
Happypig375 merged 1 commit into
ASC-Community:masterfrom
Rafael-SOWNet:feat/arctan-identities
Aug 4, 2026
Merged

Happypig375 merged 1 commit into
ASC-Community:masterfrom
Rafael-SOWNet:feat/arctan-identities

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member
"arctan(1/2) + arctan(1/3)".Simplify()   // master: arctan(1/2) + arctan(1/3)
"arctan(1)".Simplify()                   // master: arctan(1)

It is pi/4, and neither half of that was reachable.

The addition formula

The tangent one read backwards: arctan(a) + arctan(b) = arctan((a + b)/(1 − ab)).

It holds as written only while ab < 1. Past that the sum leaves the range arctan answers in and the identity is off by a whole pi — arctan(2) + arctan(3) is 3pi/4, not arctan(−1). Both arguments are required to be numbers, which makes ab < 1 a question with an answer; the pairs past the boundary are left alone rather than answered wrongly.

arctan(1/2) + arctan(1/3)  →  pi/4
arctan(1/5) + arctan(1/8)  →  arctan(1/3)
arctan(2)   + arctan(3)    →  unchanged

Why arctan(1) is not a simplification candidate

The two rational values are handled where arctan is simplified, beside the values at plus and minus infinity that were already there — not in the pattern pool.

A candidate offered to the simplifier has to win on node count, and pi / 4 does not beat arctan(1). So a sum that came all the way to arctan(1) stopped one step short of the answer. The two irrational ones, arctan(sqrt(3)) and arctan(1/sqrt(3)), do win their contest and stay with the other trigonometric patterns.

Verification

Checked over 289 pairs either side of the boundary, negatives included: whatever a sum of two arctangents simplifies to is the same number it was. That check is in the tests.

17 tests, 8 of which fail without the change. 4026 unit tests and 127 F# tests on both target frameworks, none failing. 117-problem self-verifying corpus at 102/117 — simp:inverse-trig goes from 50% to 100% — with nothing wrong, in error or timing out. 1320 property checks over 151 expressions, none failing.

arctan(1/2) + arctan(1/3) is pi/4, and neither half of that was reachable: the
two could not be added, and arctan(1) stayed as it was.

The addition formula is the tangent one read backwards,
arctan(a) + arctan(b) = arctan((a + b)/(1 - ab)). It holds as written only while
ab < 1: past that the sum leaves the range arctan answers in and the identity is
off by a whole pi, so arctan(2) + arctan(3) is 3pi/4 rather than arctan(-1).
Both arguments are required to be numbers, which makes ab < 1 a question with an
answer, and the ones past the boundary are left alone.

arctan(1) and arctan(-1) are handled where arctan is simplified rather than
offered to the simplifier as candidates. A candidate has to win on node count,
and pi/4 does not beat arctan(1), so a sum that came to it stopped one step
short. They sit beside the values at plus and minus infinity, which were already
there. The two irrational ones, arctan(sqrt(3)) and arctan(1/sqrt(3)), do win
their contest and stay where the other trigonometric patterns are.

Checked over 289 pairs either side of the boundary: whatever a sum of two
arctangents simplifies to is the same number it was.

17 tests, 8 of which fail without the change. 4026 in all, 127 F#, corpus 102/117
with simp:inverse-trig at 100% from 50%, and 1320 property checks.
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.47%. Comparing base (90c00a8) to head (0738f2a).
⚠️ Report is 58 commits behind head on master.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #692      +/-   ##
==========================================
- Coverage   80.99%   80.47%   -0.53%     
==========================================
  Files         155      156       +1     
  Lines       13687    12938     -749     
  Branches     1957     2123     +166     
==========================================
- Hits        11086    10412     -674     
+ Misses       1990     1919      -71     
+ Partials      611      607       -4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Happypig375
Happypig375 merged commit c424029 into ASC-Community:master Aug 4, 2026
24 checks passed
@Rafael-SOWNet
Rafael-SOWNet deleted the feat/arctan-identities branch August 4, 2026 20:48
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.

3 participants