コード例 #1
0
ファイル: test_transforms.py プロジェクト: skirpichev/diofant
def test_sine_transform():
    f = Function("f")

    # Test unevaluated form
    assert sine_transform(f(t), t, w) == SineTransform(f(t), t, w)
    assert inverse_sine_transform(
        f(w), w, t) == InverseSineTransform(f(w), w, t)

    assert sine_transform(1/sqrt(t), t, w) == 1/sqrt(w)
    assert inverse_sine_transform(1/sqrt(w), w, t) == 1/sqrt(t)

    assert sine_transform(
        (1/sqrt(t))**3, t, w) == sqrt(w)*gamma(Rational(1, 4))/(2*gamma(Rational(5, 4)))

    assert sine_transform(t**(-a), t, w) == 2**(
        -a + Rational(1, 2))*w**(a - 1)*gamma(-a/2 + 1)/gamma((a + 1)/2)
    assert inverse_sine_transform(2**(-a +
                                      Rational(1, 2))*w**(a - 1)*gamma(-a/2 + 1)/gamma(a/2 + Rational(1, 2)), w, t) == t**(-a)

    assert sine_transform(
        exp(-a*t), t, w) == sqrt(2)*w/(sqrt(pi)*(a**2 + w**2))
    assert inverse_sine_transform(
        sqrt(2)*w/(sqrt(pi)*(a**2 + w**2)), w, t) == exp(-a*t)

    assert sine_transform(
        log(t)/t, t, w) == -sqrt(2)*sqrt(pi)*(log(w**2) + 2*EulerGamma)/4

    assert sine_transform(
        t*exp(-a*t**2), t, w) == sqrt(2)*w*exp(-w**2/(4*a))/(4*a**Rational(3, 2))
    assert inverse_sine_transform(
        sqrt(2)*w*exp(-w**2/(4*a))/(4*a**Rational(3, 2)), w, t) == t*exp(-a*t**2)
コード例 #2
0
def test_sine_transform():
    from diofant import EulerGamma

    t = symbols("t")
    w = symbols("w")
    a = symbols("a")
    f = Function("f")

    # Test unevaluated form
    assert sine_transform(f(t), t, w) == SineTransform(f(t), t, w)
    assert inverse_sine_transform(f(w), w,
                                  t) == InverseSineTransform(f(w), w, t)

    assert sine_transform(1 / sqrt(t), t, w) == 1 / sqrt(w)
    assert inverse_sine_transform(1 / sqrt(w), w, t) == 1 / sqrt(t)

    assert sine_transform(
        (1 / sqrt(t))**3, t,
        w) == sqrt(w) * gamma(Rational(1, 4)) / (2 * gamma(Rational(5, 4)))

    assert sine_transform(
        t**(-a), t,
        w) == 2**(-a + Rational(1, 2)) * w**(a - 1) * gamma(-a / 2 +
                                                            1) / gamma(
                                                                (a + 1) / 2)
    assert inverse_sine_transform(
        2**(-a + Rational(1, 2)) * w**(a - 1) * gamma(-a / 2 + 1) /
        gamma(a / 2 + Rational(1, 2)), w, t) == t**(-a)

    assert sine_transform(exp(-a * t), t,
                          w) == sqrt(2) * w / (sqrt(pi) * (a**2 + w**2))
    assert inverse_sine_transform(
        sqrt(2) * w / (sqrt(pi) * (a**2 + w**2)), w, t) == exp(-a * t)

    assert sine_transform(
        log(t) / t, t,
        w) == -sqrt(2) * sqrt(pi) * (log(w**2) + 2 * EulerGamma) / 4

    assert sine_transform(
        t * exp(-a * t**2), t,
        w) == sqrt(2) * w * exp(-w**2 / (4 * a)) / (4 * a**Rational(3, 2))
    assert inverse_sine_transform(
        sqrt(2) * w * exp(-w**2 / (4 * a)) / (4 * a**Rational(3, 2)), w,
        t) == t * exp(-a * t**2)