Repository navigation
Know the Pythagorean identity in more than one arrangement (#725) - #726
Merged
Merged
Conversation
sin(x)^2 + cos(x)^2 was one syntactic pattern -- an adjacent sum of the two
squares, in either order -- so the same fact written any other way was not
recognised. The library's answer depended on which of several equivalent
spellings an expression happened to arrive in:
1 - sin(t)^2 unchanged, where it is cos(t)^2
1 - sin(t)^2 - cos(t)^2 unchanged, where it is 0
1 + tan(t)^2 unchanged, where it is sec(t)^2
1 + cotan(t)^2 unchanged, where it is csc(t)^2
sec(t)^2 - tan(t)^2 unchanged, where it is 1
csc(t)^2 - cotan(t)^2 unchanged, where it is 1
Two of those are the identity solved for one square rather than for 1; four
are the identity divided through by sin^2 and by cos^2. Eight rules, no
machinery.
The direction matters and is one-way on purpose. 1 - sin(:)^2 becomes
cos(:)^2 and not the reverse: the two sides are interchangeable, so stating
it both ways would undo each rewrite as fast as it fired.
MultipleAngleTest.PythagoreanPairAcrossASubtractionIsStillMissed pinned this
gap from the other side -- cos(2x) - (2cos(x)^2 - 1) stopped at
1 - cos(x)^2 - sin(x)^2 because the pair sat either side of a subtraction.
It reduces to 0 now, so the case moves into IdentitiesReduceToZero with the
old note kept. What that note said about the angle expansion not being able
to reach it was right, and nothing about the expansion changed.
What this does not reach is recorded rather than claimed, as a skipped
theory with the diagnosis: every rule here matches a pattern, so the two
parts have to be adjacent in the tree. In a sum of three terms the sorting
separates the pair first, which is why 1 + cotan(t)^2 - 1/sin(t)^2 does not
reduce although 1 + cotan(t)^2 is csc(t)^2 and csc(t)^2 - 1/sin(t)^2 is 0.
Written in sines and cosines the same statements do reduce, so nothing there
is a wrong answer, only an unreduced one. Reaching them wants the identity
stated over the gathered terms of a sum, which is a larger change; it is
also the last thing between the second expression in #557 and 0. The first
expression in #557 is answered and is pinned here.
19 regression cases, one skipped. Tests 4825 passing with none failing, F#
130 of 130, corpus 112/117 with 0 wrong, 0 error and 0 timeout.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This was referenced Aug 5, 2026
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.
Closes #725. Takes the first of the two expressions in #557 from unsimplified to 0; #557 itself stays open for the second, see below.
What was wrong
sin(x)^2 + cos(x)^2 = 1was one syntactic pattern — an adjacent sum of the two squares, in either order — so the same fact written any other way was not recognised. The library's answer depended on which of several equivalent spellings an expression happened to arrive in:1 - sin(t)^2cos(t)^21 - cos(t)^2sin(t)^21 - sin(t)^2 - cos(t)^201 + tan(t)^2sec(t)^21 + cotan(t)^2csc(t)^2sec(t)^2 - tan(t)^21 provided not cos(t) = 0csc(t)^2 - cotan(t)^21 provided not sin(t) = 0(sin(2t)*csc(t))^2/4 - cos(2t) - sin(t)^20 provided not sin(t) = 0Two of those are the identity solved for one square rather than for 1; four are it divided through by
sin^2and bycos^2. Eight rules, no machinery.The direction is one-way on purpose:
1 - sin(:)^2becomescos(:)^2and not the reverse. The two sides are interchangeable, so stating it both ways would undo each rewrite as fast as it fired.The conditions on the last three are the functions' own — a tangent and a secant are undefined where the cosine vanishes — and carrying them is right rather than a loss: a bare
1would claim a value at a point the expression does not reach.One existing test moved
MultipleAngleTest.PythagoreanPairAcrossASubtractionIsStillMissedpinned this gap from the other side:cos(2x) - (2cos(x)^2 - 1)stopped at1 - cos(x)^2 - sin(x)^2because the pair sat either side of a subtraction. It reduces to 0 now, so the case moves intoIdentitiesReduceToZerowith its note kept. What that note said — that this was not something opening the angle could reach — was right, and nothing about the angle expansion changed.What this does not reach, recorded rather than claimed
Every rule here matches a pattern, so the two parts of the identity have to be adjacent in the tree. In a sum of three terms the sorting separates the pair before the rules are tried:
Written in sines and cosines the same statements do reduce (
1 + cos(t)^2/sin(t)^2 - 1/sin(t)^2is 0), so nothing there is a wrong answer — only an unreduced one. Reaching them wants the identity stated over the gathered terms of a sum rather than over an adjacent pair, which is a larger change than this one.That same gap is the last thing standing between #557's second expression and 0: it reduces as far as
1/sin(t)^2 - (1 + cotan(t)^2), a difference of two equal things left in two notations. Everything else that expression needs is already in the library — the multiple-angle expansion openssin(2t), and the rational cancellation over sin/cos works.Both are pinned as a skipped theory with the diagnosis in its summary, next to a passing theory showing the sin/cos spellings that do reduce.
Measured
19 regression cases in a new
PythagoreanIdentityTest, one of them the skipped record above. Unit tests 4825 passing with none failing; F# 130 of 130; the 117-problem solver corpus stays at 112 solved with 0 wrong, 0 error and 0 timeout.🤖 Generated with Claude Code