def test_standard_radian(self): l0, l1, sq3, pi6, pi4, pi2, pi1 = tree('0,1,sqrt(3),1/6*pi,1/4*pi,1/2*pi,pi') self.assertEqual(standard_radian(sin(pi6), (OP_SIN, 1)), l1 / 2) self.assertEqual(standard_radian(sin(pi2), (OP_SIN, 4)), 1) self.assertEqual(standard_radian(cos(l0), (OP_COS, 0)), 1) self.assertEqual(standard_radian(tan(pi4), (OP_TAN, 3)), sq3) self.assertEqual(standard_radian(sin(pi1), (OP_SIN, 5)), 0) self.assertEqual(standard_radian(cos(pi1), (OP_COS, 5)), -1) self.assertEqual(standard_radian(-cos(pi1), (OP_COS, 5)), --l1)
def test_sin(self): self.assertEqual(sin(tree('x')), tree('sin(x)'))
def test_negated_sinus_parameter(self): s = tree('sin -t') t = s[0] self.assertEqual(negated_sinus_parameter(s, (t,)), -sin(+t))
def test_function(self): x = tree('x') self.assertEqual(tree('sin x'), sin(x)) self.assertEqual(tree('sin 2 x'), sin(2) * x) self.assertEqual(tree('sin x ^ 2'), sin(x ** 2)) self.assertEqual(tree('sin^2 x'), sin(x) ** 2) self.assertEqual(tree('sin(x ^ 2)'), sin(x ** 2)) self.assertEqual(tree('sin(x) ^ 2'), sin(x) ** 2) self.assertEqual(tree('sin cos x'), sin(cos(x))) self.assertEqual(tree('sin cos x ^ 2'), sin(cos(x ** 2))) self.assertEqual(tree('sin cos(x) ^ 2'), sin(cos(x) ** 2)) self.assertEqual(tree('sin (cos x) ^ 2'), sin(cos(x)) ** 2) self.assertEqual(tree('sin (cos x) ^ 2'), sin(cos(x)) ** 2) self.assertEqual(tree('sin((cos x) ^ 2)'), sin(cos(x) ** 2))
def test_tangens(self): root, x = tree('d/dx tan(x), x') self.assertEqual(tangens(root, ()), der(sin(x) / cos(x), x)) root = tree('tan(x)\'') self.assertEqual(tangens(root, ()), der(sin(x) / cos(x)))
def test_cosinus(self): root, x = tree('d/dx cos(x), x') self.assertEqual(cosinus(root, ()), -sin(x))