def test_acceleration(): e = (1 + 1 / n)**n assert round(richardson(e, n, 10, 20).evalf(), 10) == round(E.evalf(), 10) A = Sum2(Integer(-1)**(k + 1) / k, (k, 1, n)) assert round(shanks(A, n, 25).evalf(), 4) == round(log(2).evalf(), 4) assert round(shanks(A, n, 25, 5).evalf(), 10) == round(log(2).evalf(), 10)
def test_Sum2(): assert str(Sum2(cos(3 * z), (z, x, y))) == "Sum2(cos(3*z), (z, x, y))"
def maxima_sum(a1, a2, a3, a4): return Sum2(a1, (a2, a3, a4))