"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "mpmath/tests/test_quad.py" between
mpmath-1.0.0.tar.gz and mpmath-1.1.0.tar.gz

About: mpmath is a Python library for arbitrary-precision floating-point arithmetic.

test_quad.py  (mpmath-1.0.0):test_quad.py  (mpmath-1.1.0)
import pytest
from mpmath import * from mpmath import *
def ae(a, b): def ae(a, b):
return abs(a-b) < 10**(-mp.dps+5) return abs(a-b) < 10**(-mp.dps+5)
def test_basic_integrals(): def test_basic_integrals():
for prec in [15, 30, 100]: for prec in [15, 30, 100]:
mp.dps = prec mp.dps = prec
assert ae(quadts(lambda x: x**3 - 3*x**2, [-2, 4]), -12) assert ae(quadts(lambda x: x**3 - 3*x**2, [-2, 4]), -12)
assert ae(quadgl(lambda x: x**3 - 3*x**2, [-2, 4]), -12) assert ae(quadgl(lambda x: x**3 - 3*x**2, [-2, 4]), -12)
skipping to change at line 63 skipping to change at line 64
def test_double_4(): def test_double_4():
assert ae(quadts(lambda x, y: 1/(1-x*x * y*y), [0, 1], [0, 1]), pi**2 / 8) assert ae(quadts(lambda x, y: 1/(1-x*x * y*y), [0, 1], [0, 1]), pi**2 / 8)
def test_double_5(): def test_double_5():
assert ae(quadts(lambda x, y: 1/(1-x*y), [0, 1], [0, 1]), pi**2 / 6) assert ae(quadts(lambda x, y: 1/(1-x*y), [0, 1], [0, 1]), pi**2 / 6)
def test_double_6(): def test_double_6():
assert ae(quadts(lambda x, y: exp(-(x+y)), [0, inf], [0, inf]), 1) assert ae(quadts(lambda x, y: exp(-(x+y)), [0, inf], [0, inf]), 1)
# fails def test_double_7():
def xtest_double_7():
assert ae(quadts(lambda x, y: exp(-x*x-y*y), [-inf, inf], [-inf, inf]), pi) assert ae(quadts(lambda x, y: exp(-x*x-y*y), [-inf, inf], [-inf, inf]), pi)
# Test integrals from "Experimentation in Mathematics" by Borwein, # Test integrals from "Experimentation in Mathematics" by Borwein,
# Bailey & Girgensohn # Bailey & Girgensohn
def test_expmath_integrals(): def test_expmath_integrals():
for prec in [15, 30, 50]: for prec in [15, 30, 50]:
mp.dps = prec mp.dps = prec
assert ae(quadts(lambda x: x/sinh(x), [0, inf]), pi** 2 / 4) assert ae(quadts(lambda x: x/sinh(x), [0, inf]), pi** 2 / 4)
assert ae(quadts(lambda x: log(x)**2 / (1+x**2), [0, inf]), pi** 3 / 8) assert ae(quadts(lambda x: log(x)**2 / (1+x**2), [0, inf]), pi** 3 / 8)
assert ae(quadts(lambda x: (1+x**2)/(1+x**4), [0, inf]), pi/s qrt(2)) assert ae(quadts(lambda x: (1+x**2)/(1+x**4), [0, inf]), pi/s qrt(2))
assert ae(quadts(lambda x: log(x)/cosh(x)**2, [0, inf]), log( pi)-2*log(2)-euler) assert ae(quadts(lambda x: log(x)/cosh(x)**2, [0, inf]), log( pi)-2*log(2)-euler)
assert ae(quadts(lambda x: log(1+x**3)/(1-x+x**2), [0, inf]), 2*pi *log(3)/sqrt(3)) assert ae(quadts(lambda x: log(1+x**3)/(1-x+x**2), [0, inf]), 2*pi *log(3)/sqrt(3))
assert ae(quadts(lambda x: log(x)**2 / (x**2+x+1), [0, 1]), 8*pi **3 / (81*sqrt(3))) assert ae(quadts(lambda x: log(x)**2 / (x**2+x+1), [0, 1]), 8*pi **3 / (81*sqrt(3)))
assert ae(quadts(lambda x: log(cos(x))**2, [0, pi/2]), pi/2 * (log(2)**2+pi**2/12)) assert ae(quadts(lambda x: log(cos(x))**2, [0, pi/2]), pi/2 * (log(2)**2+pi**2/12))
assert ae(quadts(lambda x: x**2 / sin(x)**2, [0, pi/2]), pi*l og(2)) assert ae(quadts(lambda x: x**2 / sin(x)**2, [0, pi/2]), pi*l og(2))
assert ae(quadts(lambda x: x**2/sqrt(exp(x)-1), [0, inf]), 4*pi *(log(2)**2 + pi**2/12)) assert ae(quadts(lambda x: x**2/sqrt(exp(x)-1), [0, inf]), 4*pi *(log(2)**2 + pi**2/12))
assert ae(quadts(lambda x: x*exp(-x)*sqrt(1-exp(-2*x)), [0, inf]), pi*( 1+2*log(2))/8) assert ae(quadts(lambda x: x*exp(-x)*sqrt(1-exp(-2*x)), [0, inf]), pi*( 1+2*log(2))/8)
mp.dps = 15 mp.dps = 15
# Do not reach full accuracy # Do not reach full accuracy
def xtest_expmath_fail(): @pytest.mark.xfail
def test_expmath_fail():
assert ae(quadts(lambda x: sqrt(tan(x)), [0, pi/2]), pi*sqrt(2)/2) assert ae(quadts(lambda x: sqrt(tan(x)), [0, pi/2]), pi*sqrt(2)/2)
assert ae(quadts(lambda x: atan(x)/(x*sqrt(1-x**2)), [0, 1]), pi*log(1+sqrt( 2))/2) assert ae(quadts(lambda x: atan(x)/(x*sqrt(1-x**2)), [0, 1]), pi*log(1+sqrt( 2))/2)
assert ae(quadts(lambda x: log(1+x**2)/x**2, [0, 1]), pi/2-log(2)) assert ae(quadts(lambda x: log(1+x**2)/x**2, [0, 1]), pi/2-log(2))
assert ae(quadts(lambda x: x**2/((1+x**4)*sqrt(1-x**4)), [0, 1]), pi/8) assert ae(quadts(lambda x: x**2/((1+x**4)*sqrt(1-x**4)), [0, 1]), pi/8)
 End of changes. 3 change blocks. 
3 lines changed or deleted 4 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)