You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Simplify() does not handle complex trigonometrical statements well #557
I am using the latest release 1.3.0 for my .NET project.
Calling .Simplify() on Entitys which contain complex trigonometrical statements such as (sin(2*theta)*csc(theta))^2/4-cos(2*theta)-sin(theta)^2
or (cos(2*theta)*sin(theta)^6*(-1)+cos(theta)*sin(theta)^5*sin(2*theta)-sin(2*theta)^2*sin(theta)^4/4)/sin(theta)^8-1+(sin(2*theta)*csc(theta))^2/4-cos(2*theta)-sin(theta)^2
are not simplified to 0 (as i am expecting).
That is the right answer rather than a partial one: csc(t) is undefined where sin(t) = 0, so the identity holds everywhere the input is defined and the condition records exactly where it is not. An unconditional 0 would be claiming something false at t = 0.
Note the last term: sin(2t)^2*sin(t)^4 - (sin(2t)*sin(t))^2 is visibly zero, and it is left standing. So this is not really a trigonometric gap -- it is that a difference of two products which are the same product up to how they associate does not cancel, and here it sits over a denominator so nothing collects it. That is the multivariate polynomial cancellation in #55 rather than a missing trig identity.
Leaving open for the second case, with the cause recorded above so whoever picks it up starts from the right place.
The condition is right rather than a shortfall — a cosecant is undefined where the sine vanishes, and 0 alone would claim a value at a point the expression does not reach.
The second is not, and what is missing is now a single identified thing. It reduces as far as
1 / sin(theta) ^ 2 - (1 + cotan(theta) ^ 2)
which is a difference of two equal things left in two notations. Everything else the expression needs is already in the library: the multiple-angle expansion opens sin(2*theta), and the rational cancellation over sines and cosines works.
What is left is #725 — the Pythagorean identity is matched as a pattern, so the two parts have to be adjacent in the tree. Written on its own each half reduces (1 + cotan(t)^2 is csc(t)^2, and csc(t)^2 - 1/sin(t)^2 is 0), but in a sum of three terms the sorting separates the pair before the rules are tried. #726 fixes the arrangements that are adjacent; reaching the rest wants the identity stated over the gathered terms of a sum, which is a larger change and is recorded there as a skipped test carrying the diagnosis rather than claimed.
Both of the reporter's expressions are pinned in PythagoreanIdentityTest: the first as a passing assertion, the second as that skipped record. Leaving this issue open for the second.
The condition is correct rather than a hedge: your expressions contain csc(t) and a denominator of sin(t)^8, so they are undefined where sin(t) = 0 and 0 everywhere else.
Why the second took longer than the first. Three separate things were missing, and only the last was about your second expression specifically:
Nothing opened a symbolic double angle.sin(2t) and cos(2t) were only ever written out for numeric multiples of pi, so cos(2t) - (1 - 2sin(t)^2) did not reduce to zero either. Fixed first, and that settles your first expression.
The opened form was judged before it could pay off. Opening a multiple angle is offered to the simplifier as a candidate rather than taken, because written out sin(4x) is longer than it started and a complexity metric decides. That judgement is right; what was wrong is the form it was asked to judge. The opened form was handed to the trigonometric rules only -- enough for an expression that is already one term. Your second expression is a quotient, and it cancels only once its terms are over a common denominator; the passes that build one run earlier, while the angles are still shut. So the metric saw the opened form with none of its payoff collected and rightly rejected it as the longer of the two.
The last one is easy to see in isolation -- the same number, and only the shut form failed:
(sin(t)^6 - (2*sin(t)*cos(t))^2*sin(t)^4/4)/sin(t)^8 - 1 => 0 // already worked
(sin(t)^6 - sin(2*t)^2*sin(t)^4/4)/sin(t)^8 - 1 => ... // not reduced
The opened form is now simplified in full, and expanded, before being offered -- which is what Expand() and Factorize() already got. Multiple angles that do not cancel keep their compact form: sin(4x), cos(6x) and sin(3x) are unchanged and sin(2x)*cos(2x) still collapses to sin(4x)/2.
Tests in DoubleAngleOverSineTest.cs pinning both of your expressions and the pieces they are built from. Full suite green, 117-problem corpus unchanged.
Activity
Open up multiple angles, and integrate the squares of sine and cosine (…
Reduce the double angle over the single one (#557) (#693)
Rafael-SOWNet commentedon Aug 5, 2026
Re-measured on master. The first expression is answered; the second is not.
That is the right answer rather than a partial one:
csc(t)is undefined wheresin(t) = 0, so the identity holds everywhere the input is defined and the condition records exactly where it is not. An unconditional0would be claiming something false att = 0.The longer one does not reach 0:
Note the last term:
sin(2t)^2*sin(t)^4 - (sin(2t)*sin(t))^2is visibly zero, and it is left standing. So this is not really a trigonometric gap -- it is that a difference of two products which are the same product up to how they associate does not cancel, and here it sits over a denominator so nothing collects it. That is the multivariate polynomial cancellation in #55 rather than a missing trig identity.Leaving open for the second case, with the cause recorded above so whoever picks it up starts from the right place.
Rafael-SOWNet commentedon Aug 5, 2026
Measured against
masterat 5f1a003, and the two expressions in this report are now in different places.The first is answered:
The condition is right rather than a shortfall — a cosecant is undefined where the sine vanishes, and
0alone would claim a value at a point the expression does not reach.The second is not, and what is missing is now a single identified thing. It reduces as far as
which is a difference of two equal things left in two notations. Everything else the expression needs is already in the library: the multiple-angle expansion opens
sin(2*theta), and the rational cancellation over sines and cosines works.What is left is #725 — the Pythagorean identity is matched as a pattern, so the two parts have to be adjacent in the tree. Written on its own each half reduces (
1 + cotan(t)^2iscsc(t)^2, andcsc(t)^2 - 1/sin(t)^2is 0), but in a sum of three terms the sorting separates the pair before the rules are tried. #726 fixes the arrangements that are adjacent; reaching the rest wants the identity stated over the gathered terms of a sum, which is a larger change and is recorded there as a skipped test carrying the diagnosis rather than claimed.Both of the reporter's expressions are pinned in
PythagoreanIdentityTest: the first as a passing assertion, the second as that skipped record. Leaving this issue open for the second.Know the Pythagorean identity in more than one arrangement (#725) (#726)
Simplify an opened multiple angle before judging it (#557)
Simplify an opened multiple angle before judging it (#557) (#732)
Rafael-SOWNet commentedon Aug 5, 2026
Both of your expressions now simplify to 0. Fixed in #732 (with #726 and the double-angle work before it), merged to master.
The condition is correct rather than a hedge: your expressions contain
csc(t)and a denominator ofsin(t)^8, so they are undefined wheresin(t) = 0and 0 everywhere else.Why the second took longer than the first. Three separate things were missing, and only the last was about your second expression specifically:
sin(2t)andcos(2t)were only ever written out for numeric multiples of pi, socos(2t) - (1 - 2sin(t)^2)did not reduce to zero either. Fixed first, and that settles your first expression.1 - sin^2,1 + tan^2,sec^2 - tan^2and the rest of the same fact were each unrecognised. That is The other two Pythagorean identities are not known #725, fixed in Know the Pythagorean identity in more than one arrangement (#725) #726.sin(4x)is longer than it started and a complexity metric decides. That judgement is right; what was wrong is the form it was asked to judge. The opened form was handed to the trigonometric rules only -- enough for an expression that is already one term. Your second expression is a quotient, and it cancels only once its terms are over a common denominator; the passes that build one run earlier, while the angles are still shut. So the metric saw the opened form with none of its payoff collected and rightly rejected it as the longer of the two.The last one is easy to see in isolation -- the same number, and only the shut form failed:
The opened form is now simplified in full, and expanded, before being offered -- which is what
Expand()andFactorize()already got. Multiple angles that do not cancel keep their compact form:sin(4x),cos(6x)andsin(3x)are unchanged andsin(2x)*cos(2x)still collapses tosin(4x)/2.Tests in
DoubleAngleOverSineTest.cspinning both of your expressions and the pieces they are built from. Full suite green, 117-problem corpus unchanged.Point AGENTS.md at work that is still open, and at keeping the harness (