def test_deltaproduct_mul_add_x_kd_add_y_kd(): assert dp((x + KD(i, k))*(y + KD(i, j)), (j, 1, 3)) == \ KD(i, 1)*(KD(i, k) + x)*((KD(i, k) + x)*y)**2 + \ KD(i, 2)*(KD(i, k) + x)*y*(KD(i, k) + x)**2*y + \ KD(i, 3)*((KD(i, k) + x)*y)**2*(KD(i, k) + x) + \ ((KD(i, k) + x)*y)**3 assert dp((x + KD(i, k))*(y + KD(i, j)), (j, 1, 1)) == \ (x + KD(i, k))*(y + KD(i, 1)) assert dp((x + KD(i, k))*(y + KD(i, j)), (j, 2, 2)) == \ (x + KD(i, k))*(y + KD(i, 2)) assert dp((x + KD(i, k))*(y + KD(i, j)), (j, 3, 3)) == \ (x + KD(i, k))*(y + KD(i, 3)) assert dp((x + KD(i, k))*(y + KD(i, j)), (j, 1, k)) == \ ((x + KD(i, k))*y)**k + Piecewise( (((x + KD(i, k))*y)**(i - 1)*(x + KD(i, k))* ((x + KD(i, k))*y)**(-i + k), And(S(1) <= i, i <= k)), (0, True) ) assert dp((x + KD(i, k))*(y + KD(i, j)), (j, k, 3)) == \ ((x + KD(i, k))*y)**(4 - k) + Piecewise( (((x + KD(i, k))*y)**(i - k)*(x + KD(i, k))* ((x + KD(i, k))*y)**(-i + 3), And(k <= i, i <= 3)), (0, True) ) assert dp((x + KD(i, k))*(y + KD(i, j)), (j, k, l)) == \ ((x + KD(i, k))*y)**(-k + l + 1) + Piecewise( (((x + KD(i, k))*y)**(i - k)*(x + KD(i, k))* ((x + KD(i, k))*y)**(-i + l), And(k <= i, i <= l)), (0, True) )
def test_deltaproduct_mul_add_x_y_add_y_kd(): assert dp((x + y)*(y + KD(i, j)), (j, 1, 3)) == ((x + y)*y)**3 + \ (x + y)*((x + y)*y)**2*KD(i, 1) + \ (x + y)*y*(x + y)**2*y*KD(i, 2) + \ ((x + y)*y)**2*(x + y)*KD(i, 3) assert dp((x + y)*(y + KD(i, j)), (j, 1, 1)) == (x + y)*(y + KD(i, 1)) assert dp((x + y)*(y + KD(i, j)), (j, 2, 2)) == (x + y)*(y + KD(i, 2)) assert dp((x + y)*(y + KD(i, j)), (j, 3, 3)) == (x + y)*(y + KD(i, 3)) assert dp((x + y)*(y + KD(i, j)), (j, 1, k)) == \ ((x + y)*y)**k + Piecewise( (((x + y)*y)**(i - 1)*(x + y)*((x + y)*y)**(k - i), And(S(1) <= i, i <= k)), (0, True) ) assert dp((x + y)*(y + KD(i, j)), (j, k, 3)) == \ ((x + y)*y)**(-k + 4) + Piecewise( (((x + y)*y)**(i - k)*(x + y)*((x + y)*y)**(3 - i), And(k <= i, i <= 3)), (0, True) ) assert dp((x + y)*(y + KD(i, j)), (j, k, l)) == \ ((x + y)*y)**(-k + l + 1) + Piecewise( (((x + y)*y)**(i - k)*(x + y)*((x + y)*y)**(l - i), And(k <= i, i <= l)), (0, True) )
def test_deltaproduct_mul_add_x_y_add_y_kd(): assert dp((x + y)*(y + KD(i, j)), (j, 1, 3)) == ((x + y)*y)**3 + \ (x + y)*((x + y)*y)**2*KD(i, 1) + \ (x + y)*y*(x + y)**2*y*KD(i, 2) + \ ((x + y)*y)**2*(x + y)*KD(i, 3) assert dp((x + y) * (y + KD(i, j)), (j, 1, 1)) == (x + y) * (y + KD(i, 1)) assert dp((x + y) * (y + KD(i, j)), (j, 2, 2)) == (x + y) * (y + KD(i, 2)) assert dp((x + y) * (y + KD(i, j)), (j, 3, 3)) == (x + y) * (y + KD(i, 3)) assert dp((x + y)*(y + KD(i, j)), (j, 1, k)) == \ ((x + y)*y)**k + Piecewise( (((x + y)*y)**(i - 1)*(x + y)*((x + y)*y)**(k - i), And(S(1) <= i, i <= k)), (0, True) ) assert dp((x + y)*(y + KD(i, j)), (j, k, 3)) == \ ((x + y)*y)**(-k + 4) + Piecewise( (((x + y)*y)**(i - k)*(x + y)*((x + y)*y)**(3 - i), And(k <= i, i <= 3)), (0, True) ) assert dp((x + y)*(y + KD(i, j)), (j, k, l)) == \ ((x + y)*y)**(-k + l + 1) + Piecewise( (((x + y)*y)**(i - k)*(x + y)*((x + y)*y)**(l - i), And(k <= i, i <= l)), (0, True) )
def test_deltaproduct_mul_x_kd(): assert dp(x*KD(i, j), (j, 1, 3)) == 0 assert dp(x*KD(i, j), (j, 1, 1)) == x*KD(i, 1) assert dp(x*KD(i, j), (j, 2, 2)) == x*KD(i, 2) assert dp(x*KD(i, j), (j, 3, 3)) == x*KD(i, 3) assert dp(x*KD(i, j), (j, 1, k)) == x*KD(i, 1)*KD(k, 1) + KD(k, 0) assert dp(x*KD(i, j), (j, k, 3)) == x*KD(i, 3)*KD(k, 3) + KD(k, 4) assert dp(x*KD(i, j), (j, k, l)) == x*KD(i, l)*KD(k, l) + KD(k, l + 1)
def test_deltaproduct_basic(): assert dp(KD(i, j), (j, 1, 3)) == 0 assert dp(KD(i, j), (j, 1, 1)) == KD(i, 1) assert dp(KD(i, j), (j, 2, 2)) == KD(i, 2) assert dp(KD(i, j), (j, 3, 3)) == KD(i, 3) assert dp(KD(i, j), (j, 1, k)) == KD(i, 1)*KD(k, 1) + KD(k, 0) assert dp(KD(i, j), (j, k, 3)) == KD(i, 3)*KD(k, 3) + KD(k, 4) assert dp(KD(i, j), (j, k, l)) == KD(i, l)*KD(k, l) + KD(k, l + 1)
def test_deltaproduct_trivial(): assert dp(x, (j, 1, 0)) == 1 assert dp(x, (j, 1, 3)) == x**3 assert dp(x + y, (j, 1, 3)) == (x + y)**3 assert dp(x*y, (j, 1, 3)) == (x*y)**3 assert dp(KD(i, j), (k, 1, 3)) == KD(i, j) assert dp(x*KD(i, j), (k, 1, 3)) == x**3*KD(i, j) assert dp(x*y*KD(i, j), (k, 1, 3)) == (x*y)**3*KD(i, j)
def test_deltaproduct_basic(): assert dp(KD(i, j), (j, 1, 3)) == 0 assert dp(KD(i, j), (j, 1, 1)) == KD(i, 1) assert dp(KD(i, j), (j, 2, 2)) == KD(i, 2) assert dp(KD(i, j), (j, 3, 3)) == KD(i, 3) assert dp(KD(i, j), (j, 1, k)) == KD(i, 1) * KD(k, 1) + KD(k, 0) assert dp(KD(i, j), (j, k, 3)) == KD(i, 3) * KD(k, 3) + KD(k, 4) assert dp(KD(i, j), (j, k, l)) == KD(i, l) * KD(k, l) + KD(k, l + 1)
def test_deltaproduct_trivial(): assert dp(x, (j, 1, 0)) == 1 assert dp(x, (j, 1, 3)) == x**3 assert dp(x + y, (j, 1, 3)) == (x + y)**3 assert dp(x * y, (j, 1, 3)) == (x * y)**3 assert dp(KD(i, j), (k, 1, 3)) == KD(i, j) assert dp(x * KD(i, j), (k, 1, 3)) == x**3 * KD(i, j) assert dp(x * y * KD(i, j), (k, 1, 3)) == (x * y)**3 * KD(i, j)
def test_deltaproduct_add_kd_kd(): assert dp(KD(i, k) + KD(j, k), (k, 1, 3)) == 0 assert dp(KD(i, k) + KD(j, k), (k, 1, 1)) == KD(i, 1) + KD(j, 1) assert dp(KD(i, k) + KD(j, k), (k, 2, 2)) == KD(i, 2) + KD(j, 2) assert dp(KD(i, k) + KD(j, k), (k, 3, 3)) == KD(i, 3) + KD(j, 3) assert dp(KD(i, k) + KD(j, k), (k, 1, l)) == KD(l, 0) + \ KD(i, 1)*KD(l, 1) + KD(j, 1)*KD(l, 1) + \ KD(i, 1)*KD(j, 2)*KD(l, 2) + KD(j, 1)*KD(i, 2)*KD(l, 2) assert dp(KD(i, k) + KD(j, k), (k, l, 3)) == KD(l, 4) + \ KD(i, 3)*KD(l, 3) + KD(j, 3)*KD(l, 3) + \ KD(i, 2)*KD(j, 3)*KD(l, 2) + KD(i, 3)*KD(j, 2)*KD(l, 2) assert dp(KD(i, k) + KD(j, k), (k, l, m)) == KD(l, m + 1) + \ KD(i, m)*KD(l, m) + KD(j, m)*KD(l, m) + \ KD(i, m)*KD(j, m - 1)*KD(l, m - 1) + KD(i, m - 1)*KD(j, m)*KD(l, m - 1)
def test_deltaproduct_mul_x_add_kd_kd(): assert dp(x*(KD(i, k) + KD(j, k)), (k, 1, 3)) == 0 assert dp(x*(KD(i, k) + KD(j, k)), (k, 1, 1)) == x*(KD(i, 1) + KD(j, 1)) assert dp(x*(KD(i, k) + KD(j, k)), (k, 2, 2)) == x*(KD(i, 2) + KD(j, 2)) assert dp(x*(KD(i, k) + KD(j, k)), (k, 3, 3)) == x*(KD(i, 3) + KD(j, 3)) assert dp(x*(KD(i, k) + KD(j, k)), (k, 1, l)) == KD(l, 0) + \ x*KD(i, 1)*KD(l, 1) + x*KD(j, 1)*KD(l, 1) + \ x**2*KD(i, 1)*KD(j, 2)*KD(l, 2) + x**2*KD(j, 1)*KD(i, 2)*KD(l, 2) assert dp(x*(KD(i, k) + KD(j, k)), (k, l, 3)) == KD(l, 4) + \ x*KD(i, 3)*KD(l, 3) + x*KD(j, 3)*KD(l, 3) + \ x**2*KD(i, 2)*KD(j, 3)*KD(l, 2) + x**2*KD(i, 3)*KD(j, 2)*KD(l, 2) assert dp(x*(KD(i, k) + KD(j, k)), (k, l, m)) == KD(l, m + 1) + \ x*KD(i, m)*KD(l, m) + x*KD(j, m)*KD(l, m) + \ x**2*KD(i, m - 1)*KD(j, m)*KD(l, m - 1) + \ x**2*KD(i, m)*KD(j, m - 1)*KD(l, m - 1)
def test_deltaproduct_mul_x_add_y_kd(): assert dp(x * (y + KD(i, j)), (j, 1, 3)) == (x * y)**3 + x * (x * y)**2 * KD(i, 1) + ( x * y) * x * (x * y) * KD(i, 2) + (x * y)**2 * x * KD(i, 3) assert dp(x * (y + KD(i, j)), (j, 1, 1)) == x * (y + KD(i, 1)) assert dp(x * (y + KD(i, j)), (j, 2, 2)) == x * (y + KD(i, 2)) assert dp(x * (y + KD(i, j)), (j, 3, 3)) == x * (y + KD(i, 3)) assert dp(x * (y + KD(i, j)), (j, 1, k)) == (x * y)**k + Piecewise( ((x * y)**(i - 1) * x * (x * y)**(k - i), And(1 <= i, i <= k)), (0, True)) assert dp(x * (y + KD(i, j)), (j, k, 3)) == (x * y)**(-k + 4) + Piecewise( ((x * y)**(i - k) * x * (x * y)**(3 - i), And(k <= i, i <= 3)), (0, True)) assert dp(x * (y + KD(i, j)), (j, k, l)) == (x * y)**(-k + l + 1) + Piecewise( ((x * y)**(i - k) * x * (x * y)**(l - i), And(k <= i, i <= l)), (0, True))
def test_deltaproduct_mul_x_add_y_twokd(): assert dp(x*(y + 2*KD(i, j)), (j, 1, 3)) == (x*y)**3 + \ 2*x*(x*y)**2*KD(i, 1) + 2*x*y*x*x*y*KD(i, 2) + 2*(x*y)**2*x*KD(i, 3) assert dp(x*(y + 2*KD(i, j)), (j, 1, 1)) == x*(y + 2*KD(i, 1)) assert dp(x*(y + 2*KD(i, j)), (j, 2, 2)) == x*(y + 2*KD(i, 2)) assert dp(x*(y + 2*KD(i, j)), (j, 3, 3)) == x*(y + 2*KD(i, 3)) assert dp(x*(y + 2*KD(i, j)), (j, 1, k)) == \ (x*y)**k + Piecewise( (2*(x*y)**(i - 1)*x*(x*y)**(k - i), And(S(1) <= i, i <= k)), (0, True) ) assert dp(x*(y + 2*KD(i, j)), (j, k, 3)) == \ (x*y)**(-k + 4) + Piecewise( (2*(x*y)**(i - k)*x*(x*y)**(3 - i), And(k <= i, i <= 3)), (0, True) ) assert dp(x*(y + 2*KD(i, j)), (j, k, l)) == \ (x*y)**(-k + l + 1) + Piecewise( (2*(x*y)**(i - k)*x*(x*y)**(l - i), And(k <= i, i <= l)), (0, True) )