Repository navigation
Open up multiple angles, and integrate the squares of sine and cosine - #671
Merged
Happypig375 merged 1 commit intoAug 3, 2026
Merged
Conversation
sin(2x) and cos(2x) never opened into single-angle form, so identities in them did not close: cos(2x) - (1 - 2sin(x)^2) stayed as it was written rather than reducing to 0. The expansions were already here. TrigonometricAngleExpansion.ExpandSineArgument- Multiplied and its cosine twin have been in the tree all along, reached only for numeric angles that are multiples of pi. This wires them to a symbolic sin(n x) for whole n up to 8, past which the expansion is longer than anything it buys. The expanded form is offered to the simplifier as a candidate rather than taken, the way the polynomial factorer's is, so the complexity metric decides. sin(2x) on its own therefore still prints as sin(2x), while cos(2x) + sin(x)^2 now comes back as cos(x)^2. Separately, power reduction goes into the integral table: sin(u)^2 = (1 - cos(2u))/2 gives the integral directly, where before sin(x)^2 fell through to integration by parts and cycled there until it ran out of stack. Not fixed, and worth being clear about: #557 itself gets further than it did but still does not reach 0, and cos(2x) - (2cos(x)^2 - 1) stops at 1 - cos(x)^2 - sin(x)^2. Both need a pair of trigonometric terms to be spotted across a subtraction, which is the pairwise-versus-flattened gap of #531 rather than anything about angles. Tests pin where each of them actually stops. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #671 +/- ##
==========================================
- Coverage 80.99% 79.49% -1.50%
==========================================
Files 155 155
Lines 13687 12331 -1356
Branches 1957 1990 +33
==========================================
- Hits 11086 9803 -1283
+ Misses 1990 1940 -50
+ Partials 611 588 -23 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two things the library could not do, both reached by wiring up machinery that was
already here.
Multiple angles never opened
sin(2x)andcos(2x)stayed as written, so identities in them did not close:The expansions were not missing.
TrigonometricAngleExpansion.ExpandSineArgumentMultipliedand its cosine twin have been in the tree all along, and were only ever reached for
numeric angles that are multiples of pi. This wires them to a symbolic
sin(n x)forwhole
nup to 8, past which the expansion is longer than anything it buys.The expanded form is offered to the simplifier as a candidate, the way the
polynomial factorer's is, so the complexity metric decides.
sin(2x)on its owntherefore still prints as
sin(2x)— opening it there would only make it longer.The squares of sine and cosine could not be integrated
∫ sin(x)^2 dxfell through to integration by parts and cycled there until it ran outof stack. Power reduction,
sin(u)^2 = (1 - cos(2u))/2, gives the integral outright, soit goes in the integral table:
Each is checked by differentiating back at several points, not by comparing strings.
What this does not fix
Worth being explicit, because #557 is the issue this looked like it would close and it
does not:
(sin(2t)csc(t))^2/4 - cos(2t) - sin(t)^2, gets further than before butstill does not reach 0.
cos(2x) - (2cos(x)^2 - 1)stops at1 - cos(x)^2 - sin(x)^2.Both need a pair of trigonometric terms to be recognised across a subtraction.
sin^2 + cos^2 = 1is matched as a pair of adjacent terms, and in these two the pairsits either side of a
-. That is the same pairwise-versus-flattened gap as #531, intrigonometry rather than in a polynomial sum, and opening the angle cannot reach it.
There are tests pinning exactly where each of them stops, so the remaining distance is
recorded rather than implied.
Testing
UnitTests3676 passed / 0 failed,FSharpWrapperUnitTests127 passed / 0 failed, andboth
netstandard2.0andnet7.0build.18 new tests: the identities that close, the two that do not, the compact forms that
must be left alone, value preservation under expansion at several points, and the four
integrals.
Independent of #663 through #670.
🤖 Generated with Claude Code