Skip to content

Reduce the double angle over the single one (#557) - #693

Merged
Rafael-SOWNet merged 2 commits into
ASC-Community:masterfrom
Rafael-SOWNet:feat/double-angle-over-sine
Aug 4, 2026
Merged

Rafael-SOWNet merged 2 commits into
ASC-Community:masterfrom
Rafael-SOWNet:feat/double-angle-over-sine

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

Closes the last part of #557.

"sin(2*x) * cosec(x)".Simplify()   // master: csc(x) * sin(2 * x)
"(sin(2*x)*cosec(x))^2/4 - cos(2*x) - sin(x)^2".Simplify()
// master: (sin(2 * x) * csc(x)) ^ 2 / 4 - cos(x) ^ 2

That second one is the expression from the issue, and it is zero.

Why it stopped one step short

sin(2u) csc(u) is 2 cos(u). Opening sin(2u) up — which the multiple-angle expansion from the earlier part of this issue does — leaves 2 sin(u) cos(u) csc(u), whose sine and cosecant are no longer adjacent in the product. The rules that cancel those match a pair of factors, so they never meet.

Hence a rule of its own, matching before the double angle is opened and the pieces are scattered.

The condition is carried

2cos(u) is a number where sin(u) is zero and sin(2u) csc(u) is not, so an unconditional answer would speak for a point the expression does not reach:

sin(2x) * cosec(x)  →  2 * cos(x) provided not sin(x) = 0
sin(x)  * cosec(x)  →  1          provided not sin(x) = 0     (already the case)

Same condition the neighbouring cancellation already comes back with.

Verification

17 tests, 7 of which fail without the change — including that the rewrite is the same number wherever both sides are defined, checked at six points. Nothing outside the identity is claimed: a different argument (sin(2x) csc(y)) and a multiplier it does not cover (sin(3x) csc(x)) are left alone and pinned as such.

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

sin(2u) csc(u) is 2 cos(u), and nothing reduced it. Opening sin(2u) up leaves
2 sin(u) cos(u) csc(u), whose sine and cosecant are no longer adjacent in the
product, and the rules that cancel those match a pair of factors. So
(sin(2t) csc(t))^2/4 - cos(2t) - sin(t)^2 came down to
(sin(2t) csc(t))^2/4 - cos(t)^2 and stopped, one step short of the zero
#557 asks for.

A rule of its own, matching before the double angle is opened up and the two
pieces are scattered.

The cosecant's condition is carried rather than dropped. 2cos(u) is a number
where sin(u) is zero and sin(2u) csc(u) is not, so an unconditional answer would
speak for a point the expression does not reach. It is the same condition the
cancellation of sin(u) csc(u) already comes back with.

17 tests, 7 of which fail without the change, including that the rewrite is the
same number wherever both sides are defined. 4026 in all, 127 F#, corpus 102/117
with simp:trig at 100% from 67%, and 1320 property checks.
@codecov-commenter

codecov-commenter commented Aug 4, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.60%. Comparing base (90c00a8) to head (06ed34e).
⚠️ Report is 74 commits behind head on master.

Files with missing lines Patch % Lines
...s/Simplification/Patterns/Patterns.Trigonometry.cs 86.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #693      +/-   ##
==========================================
+ Coverage   80.99%   81.60%   +0.60%     
==========================================
  Files         155      157       +2     
  Lines       13687    13362     -325     
  Branches     1957     2200     +243     
==========================================
- Hits        11086    10904     -182     
+ Misses       1990     1851     -139     
+ 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

Copy link
Copy Markdown
Member

conflicted

Both sides add independent trigonometric rules to the same table; kept both.
@Rafael-SOWNet
Rafael-SOWNet merged commit 020f6a0 into ASC-Community:master Aug 4, 2026
26 checks passed
@Rafael-SOWNet
Rafael-SOWNet deleted the feat/double-angle-over-sine 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