Exemplo n.º 1
0
    def test_right_shift5(self):
        a, b = sp.symbols("a, b", commutative = False)
        f1 = sp.Function('f1')(t)
        f2 = sp.Function('y2')(t)

        res1 = nct.right_shift(f1**-1, s, t)
        self.assertEqual(res1, 1/f1)

        res2 = nct.right_shift((f1 + f2)**-1, s, t)
        self.assertEqual(res2, 1/(f1 + f2))

        ff = (f1 + f2)**-1
        res3 = nct.right_shift(s*ff, s, t) - (ff.diff(t) + ff*s)
        res3 = res3.simplify()
        self.assertEqual(res3, 0)
Exemplo n.º 2
0
    def test_right_shift4(self):

        y1, y2 = yy = sp.Matrix( sp.symbols('y1, y2', commutative=False) )

        ydot1, ydot2 = st.time_deriv(yy, yy)
        res1 = nct.right_shift(s*y1, s, t, yy)

        self.assertEqual(res1, ydot1 + y1*s)
Exemplo n.º 3
0
    def test_right_shift2(self):
        a, b = sp.symbols("a, b", commutative=False)
        f1 = sp.Function('f1')(t)
        f1d = f1.diff(t)
        f2 = sp.Function('f2')(t)

        res1 = nct.right_shift(s*t, s, t)
        self.assertEqual(res1, 1 + t*s)

        res2 = nct.right_shift(s, s, t)
        self.assertEqual(res2, s)

        res3 = nct.right_shift(s**4, s, t)
        self.assertEqual(res3, s**4)

        res4 = nct.right_shift(s**4*a*b, s, t)
        self.assertEqual(res4, a*b*s**4)

        res5 = nct.right_shift(s**2*a*s*b*s, s, t)
        ex5 = a*b*s**4
        self.assertEqual(res5, ex5)

        res6 = nct.right_shift(s**2*(a*t**3), s, t)
        ex6 = a*(6*t + 6*t**2*s + t**3*s**2)
        self.assertEqual(res6, ex6)

        res7 = nct.right_shift(f1*s*a*s*b, s, t)
        self.assertEqual(res7, f1*a*b*s**2)
Exemplo n.º 4
0
    def test_right_shift3(self):
        a, b = sp.symbols("a, b", commutative = False)
        f1 = sp.Function('f1')(t)
        f2 = sp.Function('y2')(t)
        f1d = f1.diff(t)
        f1dd = f1.diff(t, 2)
        f2d = f2.diff(t)
        f2dd = f2.diff(t, 2)

        res1 = nct.right_shift(s*f1d*f2d, s, t)
        ex1 = f1dd*f2d + f1d*f2dd + f1d*f2d*s

        self.assertEqual(res1, ex1)

        test = s*f2*f2d
        res2 = nct.right_shift(test, s, t)
        ex2 = f2d**2 + f2*f2dd + f2*f2d*s

        self.assertEqual(res2, ex2)
Exemplo n.º 5
0
    def test_right_shift(self):
        a, b = sp.symbols("a, b")
        f1 = sp.Function('f1')(t)
        f1d = f1.diff(t)
        f2 = sp.Function('f2')(t)

        res1 = nct.right_shift(s*f1, s, t)
        ex1 = f1.diff(t) + f1*s

        self.assertEqual(res1, ex1)

        res2 = nct.right_shift(f2*s*f1, s, t)
        ex2= f2*f1.diff(t) + f2*f1*s

        self.assertEqual(res2, ex2)

        res3 = nct.right_shift(a*f2*s*f1d, s, t)
        ex3= a*f2*f1.diff(t, 2) + a*f2*f1d*s

        self.assertEqual(res3, ex3)

        res4 = nct.right_shift(s*f1*f2, s, t)
        ex4 = f1.diff(t)*f2 + f1*f2*s + f1*f2.diff(t)

        self.assertEqual(res4, ex4)

        self.assertRaises( ValueError, nct.right_shift, s*f1*(f2+1), s, t)

        res = nct.right_shift(s, s, t)
        self.assertEqual(res, s)

        res = nct.right_shift(s**2, s, t)
        self.assertEqual(res, s**2)

        res = nct.right_shift(a, s, t)
        self.assertEqual(res, a)

        self.assertRaises( ValueError, nct.right_shift, sp.sin(s), s, t)
        self.assertRaises( ValueError, nct.right_shift, s*sp.sin(s), s, t)