def test_hyper_re():
    d = f(x) + Derivative(f(x), x, x)
    assert hyper_re(d, r, k) == r(k) + (k + 1) * (k + 2) * r(k + 2)

    d = -x * f(x) + Derivative(f(x), x, x)
    assert hyper_re(d, r, k) == (k + 2) * (k + 3) * r(k + 3) - r(k)

    d = 2 * f(x) - 2 * Derivative(f(x), x) + Derivative(f(x), x, x)
    assert hyper_re(d, r, k) == \
        (-2*k - 2)*r(k + 1) + (k + 1)*(k + 2)*r(k + 2) + 2*r(k)

    d = 2 * n * f(x) + (x**2 - 1) * Derivative(f(x), x)
    assert hyper_re(d, r, k) == \
        k*r(k) + 2*n*r(k + 1) + (-k - 2)*r(k + 2)

    d = (x**10 + 4) * Derivative(f(x), x) + x * (x**10 - 1) * Derivative(
        f(x), x, x)
    assert hyper_re(d, r, k) == \
        (k*(k - 1) + k)*r(k) + (4*k - (k + 9)*(k + 10) + 40)*r(k + 10)

    d = ((x**2 - 1) * Derivative(f(x), x, 3) + 3 * x * Derivative(f(x), x, x) +
         Derivative(f(x), x))
    assert hyper_re(d, r, k) == \
        ((k*(k - 2)*(k - 1) + 3*k*(k - 1) + k)*r(k) +
         (-k*(k + 1)*(k + 2))*r(k + 2))
Beispiel #2
0
def test_hyper_re():
    d = f(x) + Derivative(f(x), x, x)
    assert hyper_re(d, r, k) == r(k) + (k + 1) * (k + 2) * r(k + 2)

    d = -x * f(x) + Derivative(f(x), x, x)
    assert hyper_re(d, r, k) == (k + 2) * (k + 3) * r(k + 3) - r(k)

    d = 2 * f(x) - 2 * Derivative(f(x), x) + Derivative(f(x), x, x)
    assert hyper_re(d, r, k) == (-2 * k - 2) * r(k + 1) + (k + 1) * (k + 2) * r(k + 2) + 2 * r(k)

    d = 2 * n * f(x) + (x ** 2 - 1) * Derivative(f(x), x)
    assert hyper_re(d, r, k) == k * r(k) + 2 * n * r(k + 1) + (-k - 2) * r(k + 2)

    d = (x ** 10 + 4) * Derivative(f(x), x) + x * (x ** 10 - 1) * Derivative(f(x), x, x)
    assert hyper_re(d, r, k) == (k * (k - 1) + k) * r(k) + (4 * k - (k + 9) * (k + 10) + 40) * r(k + 10)

    d = (x ** 2 - 1) * Derivative(f(x), x, 3) + 3 * x * Derivative(f(x), x, x) + Derivative(f(x), x)
    assert hyper_re(d, r, k) == (
        (k * (k - 2) * (k - 1) + 3 * k * (k - 1) + k) * r(k) + (-k * (k + 1) * (k + 2)) * r(k + 2)
    )