def test_erf2():
    assert erf2(0, 0) == 0
    assert erf2(x, x) == 0
    assert erf2(nan, 0) == nan

    assert erf2(-oo, y) == erf(y) + 1
    assert erf2(oo, y) == erf(y) - 1
    assert erf2(x, oo) == 1 - erf(x)
    assert erf2(x, -oo) == -1 - erf(x)
    assert erf2(x, erf2inv(x, y)) == y

    assert erf2(-x, -y) == -erf2(x, y)
    assert erf2(-x, y) == erf(y) + erf(x)
    assert erf2(x, -y) == -erf(y) - erf(x)
    assert erf2(x, y).rewrite(
        'fresnels') == erf(y).rewrite(fresnels) - erf(x).rewrite(fresnels)
    assert erf2(x, y).rewrite(
        'fresnelc') == erf(y).rewrite(fresnelc) - erf(x).rewrite(fresnelc)
    assert erf2(
        x, y).rewrite('hyper') == erf(y).rewrite(hyper) - erf(x).rewrite(hyper)
    assert erf2(x, y).rewrite(
        'meijerg') == erf(y).rewrite(meijerg) - erf(x).rewrite(meijerg)
    assert erf2(
        x,
        y).rewrite('uppergamma'
                   ) == erf(y).rewrite(uppergamma) - erf(x).rewrite(uppergamma)
    assert erf2(
        x,
        y).rewrite('expint') == erf(y).rewrite(expint) - erf(x).rewrite(expint)

    assert erf2(I, w).is_extended_real is False
    assert erf2(2 * w, w).is_extended_real is True
    assert erf2(z, w).is_extended_real is None
    assert erf2(w, z).is_extended_real is None

    assert conjugate(erf2(x, y)) == erf2(conjugate(x), conjugate(y))

    assert erf2(x, y).rewrite('erf') == erf(y) - erf(x)
    assert erf2(x, y).rewrite('erfc') == erfc(x) - erfc(y)
    assert erf2(x, y).rewrite('erfi') == I * (erfi(I * x) - erfi(I * y))

    pytest.raises(ArgumentIndexError, lambda: erfi(x).fdiff(3))
    pytest.raises(ArgumentIndexError, lambda: erf2(x, y).fdiff(3))

    assert erf2(x, y).diff(x) == -2 * exp(-x**2) / sqrt(pi)
    assert erf2(x, y).diff(y) == +2 * exp(-y**2) / sqrt(pi)
def test_erf2():
    assert erf2(0, 0) == 0
    assert erf2(x, x) == 0
    assert erf2(nan, 0) == nan

    assert erf2(-oo,  y) == erf(y) + 1
    assert erf2( oo,  y) == erf(y) - 1
    assert erf2(  x, oo) == 1 - erf(x)
    assert erf2(  x, -oo) == -1 - erf(x)
    assert erf2(x, erf2inv(x, y)) == y

    assert erf2(-x, -y) == -erf2(x, y)
    assert erf2(-x,  y) == erf(y) + erf(x)
    assert erf2( x, -y) == -erf(y) - erf(x)
    assert erf2(x, y).rewrite('fresnels') == erf(y).rewrite(fresnels)-erf(x).rewrite(fresnels)
    assert erf2(x, y).rewrite('fresnelc') == erf(y).rewrite(fresnelc)-erf(x).rewrite(fresnelc)
    assert erf2(x, y).rewrite('hyper') == erf(y).rewrite(hyper)-erf(x).rewrite(hyper)
    assert erf2(x, y).rewrite('meijerg') == erf(y).rewrite(meijerg)-erf(x).rewrite(meijerg)
    assert erf2(x, y).rewrite('uppergamma') == erf(y).rewrite(uppergamma) - erf(x).rewrite(uppergamma)
    assert erf2(x, y).rewrite('expint') == erf(y).rewrite(expint)-erf(x).rewrite(expint)

    assert erf2(I, w).is_extended_real is False
    assert erf2(2*w, w).is_extended_real is True
    assert erf2(z, w).is_extended_real is None
    assert erf2(w, z).is_extended_real is None

    assert conjugate(erf2(x, y)) == erf2(conjugate(x), conjugate(y))

    assert erf2(x, y).rewrite('erf') == erf(y) - erf(x)
    assert erf2(x, y).rewrite('erfc') == erfc(x) - erfc(y)
    assert erf2(x, y).rewrite('erfi') == I*(erfi(I*x) - erfi(I*y))

    pytest.raises(ArgumentIndexError, lambda: erfi(x).fdiff(3))
    pytest.raises(ArgumentIndexError, lambda: erf2(x, y).fdiff(3))

    assert erf2(x, y).diff(x) == -2*exp(-x**2)/sqrt(pi)
    assert erf2(x, y).diff(y) == +2*exp(-y**2)/sqrt(pi)