Beispiel #1
0
def test_undefined_function():
    from sympy import Function, MellinTransform
    f = Function('f')
    assert mellin_transform(f(x), x, s) == MellinTransform(f(x), x, s)
    assert mellin_transform(f(x) + exp(-x), x, s) == \
        (MellinTransform(f(x), x, s) + gamma(s), (0, oo), True)

    assert laplace_transform(2*f(x), x, s) == 2*LaplaceTransform(f(x), x, s)
Beispiel #2
0
def test_undefined_function():
    from sympy import Function, MellinTransform
    f = Function('f')
    assert mellin_transform(f(x), x, s) == MellinTransform(f(x), x, s)
    assert mellin_transform(f(x) + exp(-x), x, s) == \
        (MellinTransform(f(x), x, s) + gamma(s), (0, oo), True)

    assert laplace_transform(2*f(x), x, s) == 2*LaplaceTransform(f(x), x, s)
Beispiel #3
0
def test_as_integral():
    from sympy import Function, Integral

    f = Function("f")
    assert mellin_transform(f(x), x, s).rewrite("Integral") == Integral(
        x ** (s - 1) * f(x), (x, 0, oo)
    )
    assert fourier_transform(f(x), x, s).rewrite("Integral") == Integral(
        f(x) * exp(-2 * I * pi * s * x), (x, -oo, oo)
    )
    assert laplace_transform(f(x), x, s).rewrite("Integral") == Integral(
        f(x) * exp(-s * x), (x, 0, oo)
    )
    assert (
        str(
            2
            * pi
            * I
            * inverse_mellin_transform(f(s), s, x, (a, b)).rewrite("Integral")
        )
        == "Integral(x**(-s)*f(s), (s, _c - oo*I, _c + oo*I))"
    )
    assert (
        str(2 * pi * I * inverse_laplace_transform(f(s), s, x).rewrite("Integral"))
        == "Integral(f(s)*exp(s*x), (s, _c - oo*I, _c + oo*I))"
    )
    assert inverse_fourier_transform(f(s), s, x).rewrite("Integral") == Integral(
        f(s) * exp(2 * I * pi * s * x), (s, -oo, oo)
    )
Beispiel #4
0
def test_expint():
    from sympy.functions.elementary.miscellaneous import Max
    from sympy.functions.special.error_functions import (Ci, E1, Ei, Si)
    from sympy.functions.special.zeta_functions import lerchphi
    from sympy.simplify.simplify import simplify
    aneg = Symbol('a', negative=True)
    u = Symbol('u', polar=True)

    assert mellin_transform(E1(x), x, s) == (gamma(s)/s, (0, oo), True)
    assert inverse_mellin_transform(gamma(s)/s, s, x,
              (0, oo)).rewrite(expint).expand() == E1(x)
    assert mellin_transform(expint(a, x), x, s) == \
        (gamma(s)/(a + s - 1), (Max(1 - re(a), 0), oo), True)
    # XXX IMT has hickups with complicated strips ...
    assert simplify(unpolarify(
                    inverse_mellin_transform(gamma(s)/(aneg + s - 1), s, x,
                  (1 - aneg, oo)).rewrite(expint).expand(func=True))) == \
        expint(aneg, x)

    assert mellin_transform(Si(x), x, s) == \
        (-2**s*sqrt(pi)*gamma(s/2 + S.Half)/(
        2*s*gamma(-s/2 + 1)), (-1, 0), True)
    assert inverse_mellin_transform(-2**s*sqrt(pi)*gamma((s + 1)/2)
                                    /(2*s*gamma(-s/2 + 1)), s, x, (-1, 0)) \
        == Si(x)

    assert mellin_transform(Ci(sqrt(x)), x, s) == \
        (-2**(2*s - 1)*sqrt(pi)*gamma(s)/(s*gamma(-s + S.Half)), (0, 1), True)
    assert inverse_mellin_transform(
        -4**s*sqrt(pi)*gamma(s)/(2*s*gamma(-s + S.Half)),
        s, u, (0, 1)).expand() == Ci(sqrt(u))

    # TODO LT of Si, Shi, Chi is a mess ...
    assert laplace_transform(Ci(x), x, s) == (-log(1 + s**2)/2/s, 0, True)
    assert laplace_transform(expint(a, x), x, s) == \
        (lerchphi(s*exp_polar(I*pi), 1, a), 0, re(a) > S.Zero)
    assert laplace_transform(expint(1, x), x, s) == (log(s + 1)/s, 0, True)
    assert laplace_transform(expint(2, x), x, s) == \
        ((s - log(s + 1))/s**2, 0, True)

    assert inverse_laplace_transform(-log(1 + s**2)/2/s, s, u).expand() == \
        Heaviside(u)*Ci(u)
    assert inverse_laplace_transform(log(s + 1)/s, s, x).rewrite(expint) == \
        Heaviside(x)*E1(x)
    assert inverse_laplace_transform((s - log(s + 1))/s**2, s,
                x).rewrite(expint).expand() == \
        (expint(2, x)*Heaviside(x)).rewrite(Ei).rewrite(expint).expand()
Beispiel #5
0
def test_expint():
    from sympy import E1, expint, Max, re, lerchphi, Symbol, simplify, Si, Ci, Ei

    aneg = Symbol("a", negative=True)
    u = Symbol("u", polar=True)

    assert mellin_transform(E1(x), x, s) == (gamma(s) / s, (0, oo), True)
    assert inverse_mellin_transform(gamma(s) / s, s, x, (0, oo)).rewrite(expint).expand() == E1(x)
    assert mellin_transform(expint(a, x), x, s) == (gamma(s) / (a + s - 1), (Max(1 - re(a), 0), oo), True)
    # XXX IMT has hickups with complicated strips ...
    assert simplify(
        unpolarify(
            inverse_mellin_transform(gamma(s) / (aneg + s - 1), s, x, (1 - aneg, oo)).rewrite(expint).expand(func=True)
        )
    ) == expint(aneg, x)

    assert mellin_transform(Si(x), x, s) == (
        -2 ** s * sqrt(pi) * gamma(s / 2 + S(1) / 2) / (2 * s * gamma(-s / 2 + 1)),
        (-1, 0),
        True,
    )
    assert inverse_mellin_transform(
        -2 ** s * sqrt(pi) * gamma((s + 1) / 2) / (2 * s * gamma(-s / 2 + 1)), s, x, (-1, 0)
    ) == Si(x)

    assert mellin_transform(Ci(sqrt(x)), x, s) == (
        -2 ** (2 * s - 1) * sqrt(pi) * gamma(s) / (s * gamma(-s + S(1) / 2)),
        (0, 1),
        True,
    )
    assert inverse_mellin_transform(
        -4 ** s * sqrt(pi) * gamma(s) / (2 * s * gamma(-s + S(1) / 2)), s, u, (0, 1)
    ).expand() == Ci(sqrt(u))

    # TODO LT of Si, Shi, Chi is a mess ...
    assert laplace_transform(Ci(x), x, s) == (-log(1 + s ** 2) / 2 / s, 0, True)
    assert laplace_transform(expint(a, x), x, s) == (lerchphi(s * polar_lift(-1), 1, a), 0, S(0) < re(a))
    assert laplace_transform(expint(1, x), x, s) == (log(s + 1) / s, 0, True)
    assert laplace_transform(expint(2, x), x, s) == ((s - log(s + 1)) / s ** 2, 0, True)

    assert inverse_laplace_transform(-log(1 + s ** 2) / 2 / s, s, u).expand() == Heaviside(u) * Ci(u)
    assert inverse_laplace_transform(log(s + 1) / s, s, x).rewrite(expint) == Heaviside(x) * E1(x)
    assert (
        inverse_laplace_transform((s - log(s + 1)) / s ** 2, s, x).rewrite(expint).expand()
        == (expint(2, x) * Heaviside(x)).rewrite(Ei).rewrite(expint).expand()
    )
Beispiel #6
0
def test_expint():
    from sympy import E1, expint, Max, re, lerchphi, Symbol, simplify, Si, Ci, Ei
    aneg = Symbol('a', negative=True)
    u = Symbol('u', polar=True)

    assert mellin_transform(E1(x), x, s) == (gamma(s) / s, (0, oo), True)
    assert inverse_mellin_transform(gamma(s) / s, s, x,
                                    (0, oo)).rewrite(expint).expand() == E1(x)
    assert mellin_transform(expint(a, x), x, s) == \
        (gamma(s)/(a + s - 1), (Max(1 - re(a), 0), oo), True)
    # XXX IMT has hickups with complicated strips ...
    assert simplify(unpolarify(
                    inverse_mellin_transform(gamma(s)/(aneg + s - 1), s, x,
                  (1 - aneg, oo)).rewrite(expint).expand(func=True))) == \
        expint(aneg, x)

    assert mellin_transform(Si(x), x, s) == \
        (-2**s*sqrt(pi)*gamma(s/2 + S(1)/2)/(
        2*s*gamma(-s/2 + 1)), (-1, 0), True)
    assert inverse_mellin_transform(-2**s*sqrt(pi)*gamma((s + 1)/2)
                                    /(2*s*gamma(-s/2 + 1)), s, x, (-1, 0)) \
        == Si(x)

    assert mellin_transform(Ci(sqrt(x)), x, s) == \
        (-2**(2*s - 1)*sqrt(pi)*gamma(s)/(s*gamma(-s + S(1)/2)), (0, 1), True)
    assert inverse_mellin_transform(
        -4**s * sqrt(pi) * gamma(s) / (2 * s * gamma(-s + S(1) / 2)), s, u,
        (0, 1)).expand() == Ci(sqrt(u))

    # TODO LT of Si, Shi, Chi is a mess ...
    assert laplace_transform(Ci(x), x, s) == (-log(1 + s**2) / 2 / s, 0, True)
    assert laplace_transform(expint(a, x), x, s) == \
        (lerchphi(s*polar_lift(-1), 1, a), 0, S(0) < re(a))
    assert laplace_transform(expint(1, x), x, s) == (log(s + 1) / s, 0, True)
    assert laplace_transform(expint(2, x), x, s) == \
        ((s - log(s + 1))/s**2, 0, True)

    assert inverse_laplace_transform(-log(1 + s**2)/2/s, s, u).expand() == \
        Heaviside(u)*Ci(u)
    assert inverse_laplace_transform(log(s + 1)/s, s, x).rewrite(expint) == \
        Heaviside(x)*E1(x)
    assert inverse_laplace_transform((s - log(s + 1))/s**2, s,
                x).rewrite(expint).expand() == \
        (expint(2, x)*Heaviside(x)).rewrite(Ei).rewrite(expint).expand()
Beispiel #7
0
def test_as_integral():
    from sympy import Function, Integral
    f = Function('f')
    assert mellin_transform(f(x), x, s).rewrite('Integral') == \
        Integral(x**(s - 1)*f(x), (x, 0, oo))
    assert fourier_transform(f(x), x, s).rewrite('Integral') == \
        Integral(f(x)*exp(-2*I*pi*s*x), (x, -oo, oo))
    assert laplace_transform(f(x), x, s).rewrite('Integral') == \
        Integral(f(x)*exp(-s*x), (x, 0, oo))
    assert str(inverse_mellin_transform(f(s), s, x, (a, b)).rewrite('Integral')) \
        == "Integral(x**(-s)*f(s), (s, _c - oo*I, _c + oo*I))"
    assert str(inverse_laplace_transform(f(s), s, x).rewrite('Integral')) == \
        "Integral(f(s)*exp(s*x), (s, _c - oo*I, _c + oo*I))"
    assert inverse_fourier_transform(f(s), s, x).rewrite('Integral') == \
        Integral(f(s)*exp(2*I*pi*s*x), (s, -oo, oo))
Beispiel #8
0
def test_as_integral():
    from sympy import Integral
    f = Function('f')
    assert mellin_transform(f(x), x, s).rewrite('Integral') == \
        Integral(x**(s - 1)*f(x), (x, 0, oo))
    assert fourier_transform(f(x), x, s).rewrite('Integral') == \
        Integral(f(x)*exp(-2*I*pi*s*x), (x, -oo, oo))
    assert laplace_transform(f(x), x, s).rewrite('Integral') == \
        Integral(f(x)*exp(-s*x), (x, 0, oo))
    assert str(2*pi*I*inverse_mellin_transform(f(s), s, x, (a, b)).rewrite('Integral')) \
        == "Integral(f(s)/x**s, (s, _c - oo*I, _c + oo*I))"
    assert str(2*pi*I*inverse_laplace_transform(f(s), s, x).rewrite('Integral')) == \
        "Integral(f(s)*exp(s*x), (s, _c - oo*I, _c + oo*I))"
    assert inverse_fourier_transform(f(s), s, x).rewrite('Integral') == \
        Integral(f(s)*exp(2*I*pi*s*x), (s, -oo, oo))
Beispiel #9
0
def test_issue_7181():
    assert mellin_transform(1 / (1 - x), x, s) != None
Beispiel #10
0
def test_free_symbols():
    from sympy import Function
    f = Function('f')
    assert mellin_transform(f(x), x, s).free_symbols == {s}
    assert mellin_transform(f(x) * a, x, s).free_symbols == {s, a}
Beispiel #11
0
def test_free_symbols():
    from sympy import Function
    f = Function('f')
    assert mellin_transform(f(x), x, s).free_symbols == set([s])
    assert mellin_transform(f(x)*a, x, s).free_symbols == set([s, a])
Beispiel #12
0
def test_as_integral():
    from sympy import Function, Integral
    f = Function('f')
    assert mellin_transform(f(x), x, s).rewrite('Integral') == \
           Integral(x**(s - 1)*f(x), (x, 0, oo))
Beispiel #13
0
def test_issue_7181():
    assert mellin_transform(1 / (1 - x), x, s) != None
Beispiel #14
0
def test_as_integral():
    from sympy import Function, Integral
    f = Function('f')
    assert mellin_transform(f(x), x, s).rewrite('Integral') == \
           Integral(x**(s - 1)*f(x), (x, 0, oo))
Beispiel #15
0
def test_undefined_function():
    from sympy.integrals.transforms import MellinTransform
    f = Function('f')
    assert mellin_transform(f(x), x, s) == MellinTransform(f(x), x, s)
    assert mellin_transform(f(x) + exp(-x), x, s) == \
        (MellinTransform(f(x), x, s) + gamma(s + 1)/s, (0, oo), True)