Example #1
0
def test_difference_delta__Add():
    e = n + n*(n + 1)
    assert dd(e, n) == 2*n + 3
    assert dd(e, n, 2) == 4*n + 8

    e = n + Sum(1/k, (k, 1, n))
    assert dd(e, n) == 1 + 1/(n + 1)
    assert dd(e, n, 5) == 5 + Add(*[1/(i + n + 1) for i in range(5)])
Example #2
0
def test_difference_delta():
    e = n*(n + 1)
    e2 = e * k

    assert dd(e) == 2*n + 2
    assert dd(e2, n, 2) == k*(4*n + 6)

    raises(ValueError, lambda: dd(e2))
    raises(ValueError, lambda: dd(e2, n, oo))
Example #3
0
def test_difference_delta():
    e = n * (n + 1)
    e2 = e * k

    assert dd(e) == 2 * n + 2
    assert dd(e2, n, 2) == k * (4 * n + 6)

    raises(ValueError, lambda: dd(e2))
    raises(ValueError, lambda: dd(e2, n, oo))
Example #4
0
def test_difference_delta__Sum():
    e = Sum(1/k, (k, 1, n))
    assert dd(e, n) == 1/(n + 1)
    assert dd(e, n, 5) == Add(*[1/(i + n + 1) for i in range(5)])

    e = Sum(1/k, (k, 1, 3*n))
    assert dd(e, n) == Add(*[1/(i + 3*n + 1) for i in range(3)])

    e = n * Sum(1/k, (k, 1, n))
    assert dd(e, n) == 1 + Sum(1/k, (k, 1, n))

    e = Sum(1/k, (k, 1, n), (m, 1, n))
    assert dd(e, n) == harmonic(n)
Example #5
0
def test_difference_delta__Sum():
    e = Sum(1 / k, (k, 1, n))
    assert dd(e, n) == 1 / (n + 1)
    assert dd(e, n, 5) == Add(*[1 / (i + n + 1) for i in range(5)])

    e = Sum(1 / k, (k, 1, 3 * n))
    assert dd(e, n) == Add(*[1 / (i + 3 * n + 1) for i in range(3)])

    e = n * Sum(1 / k, (k, 1, n))
    assert dd(e, n) == 1 + Sum(1 / k, (k, 1, n))

    e = Sum(1 / k, (k, 1, n), (m, 1, n))
    assert dd(e, n) == harmonic(n)
Example #6
0
def test_difference_delta__Pow():
    e = 4**n
    assert dd(e, n) == 3*4**n
    assert dd(e, n, 2) == 15*4**n

    e = 4**(2*n)
    assert dd(e, n) == 15*4**(2*n)
    assert dd(e, n, 2) == 255*4**(2*n)

    e = n**4
    assert dd(e, n) == (n + 1)**4 - n**4

    e = n**n
    assert dd(e, n) == (n + 1)**(n + 1) - n**n
Example #7
0
def test_difference_delta__Pow():
    e = 4**n
    assert dd(e, n) == 3 * 4**n
    assert dd(e, n, 2) == 15 * 4**n

    e = 4**(2 * n)
    assert dd(e, n) == 15 * 4**(2 * n)
    assert dd(e, n, 2) == 255 * 4**(2 * n)

    e = n**4
    assert dd(e, n) == (n + 1)**4 - n**4

    e = n**n
    assert dd(e, n) == (n + 1)**(n + 1) - n**n
Example #8
0
 def _eval_difference_delta(self, n, step):
     from sympy.series.limitseq import difference_delta as dd
     return self.func(*[dd(a, n, step) for a in self.args])
Example #9
0
 def _eval_difference_delta(self, n, step):
     from sympy.series.limitseq import difference_delta as dd
     return self.func(*[dd(a, n, step) for a in self.args])