def test_TRmorrie(): assert TRmorrie(7*Mul(*[cos(i) for i in range(10)])) == \ 7*sin(12)*sin(16)*cos(5)*cos(7)*cos(9)/(64*sin(1)*sin(3)) assert TRmorrie(x) == x assert TRmorrie(2*x) == 2*x e = cos(pi/7)*cos(2*pi/7)*cos(4*pi/7) assert TR8(TRmorrie(e)) == -S(1)/8 e = Mul(*[cos(2**i*pi/17) for i in range(1, 17)]) assert TR8(TR3(TRmorrie(e))) == S(1)/65536
def test_TRmorrie(): assert TRmorrie(7*Mul(*[cos(i) for i in range(10)])) == \ 7*sin(12)*sin(16)*cos(5)*cos(7)*cos(9)/(64*sin(1)*sin(3)) assert TRmorrie(x) == x assert TRmorrie(2 * x) == 2 * x e = cos(pi / 7) * cos(pi * Rational(2, 7)) * cos(pi * Rational(4, 7)) assert TR8(TRmorrie(e)) == Rational(-1, 8) e = Mul(*[cos(2**i * pi / 17) for i in range(1, 17)]) assert TR8(TR3(TRmorrie(e))) == Rational(1, 65536) # issue 17063 eq = cos(x) / cos(x / 2) assert TRmorrie(eq) == eq
def test_TR8(): assert TR8(cos(2) * cos(3)) == cos(5) / 2 + cos(1) / 2 assert TR8(cos(2) * sin(3)) == sin(5) / 2 + sin(1) / 2 assert TR8(sin(2) * sin(3)) == -cos(5) / 2 + cos(1) / 2 assert TR8(sin(1) * sin(2) * sin(3)) == sin(4) / 4 - sin(6) / 4 + sin(2) / 4 assert TR8(cos(2) * cos(3) * cos(4) * cos(5)) == cos(4) / 4 + cos(10) / 8 + cos( 2 ) / 8 + cos(8) / 8 + cos(14) / 8 + cos(6) / 8 + Rational(1, 8) assert ( TR8(cos(2) * cos(3) * cos(4) * cos(5) * cos(6)) == cos(10) / 8 + cos(4) / 8 + 3 * cos(2) / 16 + cos(16) / 16 + cos(8) / 8 + cos(14) / 16 + cos(20) / 16 + cos(12) / 16 + Rational(1, 16) + cos(6) / 8 ) assert TR8( sin(pi * Rational(3, 7)) ** 2 * cos(pi * Rational(3, 7)) ** 2 / (16 * sin(pi / 7) ** 2) ) == Rational(1, 64)
def test_TR8(): assert TR8(cos(2)*cos(3)) == cos(5)/2 + cos(1)/2 assert TR8(cos(2)*sin(3)) == sin(5)/2 + sin(1)/2 assert TR8(sin(2)*sin(3)) == -cos(5)/2 + cos(1)/2 assert TR8(sin(1)*sin(2)*sin(3)) == sin(4)/4 - sin(6)/4 + sin(2)/4 assert TR8(cos(2)*cos(3)*cos(4)*cos(5)) == \ cos(4)/4 + cos(10)/8 + cos(2)/8 + cos(8)/8 + cos(14)/8 + \ cos(6)/8 + S(1)/8 assert TR8(cos(2)*cos(3)*cos(4)*cos(5)*cos(6)) == \ cos(10)/8 + cos(4)/8 + 3*cos(2)/16 + cos(16)/16 + cos(8)/8 + \ cos(14)/16 + cos(20)/16 + cos(12)/16 + S(1)/16 + cos(6)/8 assert TR8(sin(3*pi/7)**2*cos(3*pi/7)**2/(16*sin(pi/7)**2)) == S(1)/64
def _trig_optimizer(expr): return TR10(TR8(expr))