"Fossies" - the Fresh Open Source Software Archive  

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

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

test_functions2.py  (mpmath-0.19):test_functions2.py  (mpmath-1.0.0)
skipping to change at line 74 skipping to change at line 74
assert besselk(2,0) == inf assert besselk(2,0) == inf
assert besselk(-1,0) == inf assert besselk(-1,0) == inf
assert besselk(-2,0) == inf assert besselk(-2,0) == inf
assert besselk(0,0.5).ae(0.92441907122766586178) assert besselk(0,0.5).ae(0.92441907122766586178)
assert besselk(1,0.5).ae(1.6564411200033008937) assert besselk(1,0.5).ae(1.6564411200033008937)
assert besselk(-1,0.5).ae(1.6564411200033008937) assert besselk(-1,0.5).ae(1.6564411200033008937)
assert besselk(3.5,0.5).ae(207.48418747548460607) assert besselk(3.5,0.5).ae(207.48418747548460607)
assert besselk(0,3+4j).ae(-0.007239051213570155013+0.026510418350267677215j) assert besselk(0,3+4j).ae(-0.007239051213570155013+0.026510418350267677215j)
assert besselk(0,j).ae(-0.13863371520405399968-1.20196971531720649914j) assert besselk(0,j).ae(-0.13863371520405399968-1.20196971531720649914j)
assert (besselk(3, 10**10) * mpf(10)**4342944824).ae(1.1628981033356187851) assert (besselk(3, 10**10) * mpf(10)**4342944824).ae(1.1628981033356187851)
# test for issue 331, bug reported by Michael Hartmann
for n in range(10,100,10):
mp.dps = n
assert besseli(91.5,24.7708).ae("4.0083063213867396361965614065353708043
84623429283770206957386355592187973485480926368967963241902713161379828101448742
64e-41")
def test_bessel_zeros(): def test_bessel_zeros():
mp.dps = 15 mp.dps = 15
assert besseljzero(0,1).ae(2.40482555769577276869) assert besseljzero(0,1).ae(2.40482555769577276869)
assert besseljzero(2,1).ae(5.1356223018406825563) assert besseljzero(2,1).ae(5.1356223018406825563)
assert besseljzero(1,50).ae(157.86265540193029781) assert besseljzero(1,50).ae(157.86265540193029781)
assert besseljzero(10,1).ae(14.475500686554541220) assert besseljzero(10,1).ae(14.475500686554541220)
assert besseljzero(0.5,3).ae(9.4247779607693797153) assert besseljzero(0.5,3).ae(9.4247779607693797153)
assert besseljzero(2,1,1).ae(3.0542369282271403228) assert besseljzero(2,1,1).ae(3.0542369282271403228)
assert besselyzero(0,1).ae(0.89357696627916752158) assert besselyzero(0,1).ae(0.89357696627916752158)
skipping to change at line 518 skipping to change at line 522
assert hyper([0.2,(3,10)],[0.4+0j],1.5).ae(v) assert hyper([0.2,(3,10)],[0.4+0j],1.5).ae(v)
assert hyper([0.2,(3,10)],[0.4+0j],1.5+0j).ae(v) assert hyper([0.2,(3,10)],[0.4+0j],1.5+0j).ae(v)
v = 0.76922501362865848528 + 0.32640579593235886194j v = 0.76922501362865848528 + 0.32640579593235886194j
assert hyper([(2,10),(3,10)],[(4,10)],4+2j).ae(v) assert hyper([(2,10),(3,10)],[(4,10)],4+2j).ae(v)
assert hyper([0.2,(3,10)],[0.4+0j],4+2j).ae(v) assert hyper([0.2,(3,10)],[0.4+0j],4+2j).ae(v)
assert hyper([0.2,(3,10)],[(4,10)],4+2j).ae(v) assert hyper([0.2,(3,10)],[(4,10)],4+2j).ae(v)
def test_hyper_2f1_hard(): def test_hyper_2f1_hard():
mp.dps = 15 mp.dps = 15
# Singular cases # Singular cases
assert hyp2f1(2,-1,-1,3).ae(0.25) assert hyp2f1(2,-1,-1,3).ae(7)
assert hyp2f1(2,-2,-2,3).ae(0.25) assert hyp2f1(2,-1,-1,3,eliminate_all=True).ae(0.25)
assert hyp2f1(2,-1,-1,3,eliminate=False) == 7 assert hyp2f1(2,-2,-2,3).ae(34)
assert hyp2f1(2,-2,-2,3,eliminate=False) == 34 assert hyp2f1(2,-2,-2,3,eliminate_all=True).ae(0.25)
assert hyp2f1(2,-2,-3,3) == 14 assert hyp2f1(2,-2,-3,3) == 14
assert hyp2f1(2,-3,-2,3) == inf assert hyp2f1(2,-3,-2,3) == inf
assert hyp2f1(2,-1.5,-1.5,3) == 0.25 assert hyp2f1(2,-1.5,-1.5,3) == 0.25
assert hyp2f1(1,2,3,0) == 1 assert hyp2f1(1,2,3,0) == 1
assert hyp2f1(0,1,0,0) == 1 assert hyp2f1(0,1,0,0) == 1
assert hyp2f1(0,0,0,0) == 1 assert hyp2f1(0,0,0,0) == 1
assert isnan(hyp2f1(1,1,0,0)) assert isnan(hyp2f1(1,1,0,0))
assert hyp2f1(2,-1,-5, 0.25+0.25j).ae(1.1+0.1j) assert hyp2f1(2,-1,-5, 0.25+0.25j).ae(1.1+0.1j)
assert hyp2f1(2,-5,-5, 0.25+0.25j, eliminate=False).ae(163./128 + 125./128*j ) assert hyp2f1(2,-5,-5, 0.25+0.25j, eliminate=False).ae(163./128 + 125./128*j )
assert hyp2f1(0.7235, -1, -5, 0.3).ae(1.04341) assert hyp2f1(0.7235, -1, -5, 0.3).ae(1.04341)
skipping to change at line 873 skipping to change at line 877
assert gammainc(3.5,0,inf).ae(gamma(3.5)) assert gammainc(3.5,0,inf).ae(gamma(3.5))
assert gammainc(-150.5,500).ae('6.9825435345798951153e-627') assert gammainc(-150.5,500).ae('6.9825435345798951153e-627')
assert gammainc(-150.5,800).ae('4.6885137549474089431e-788') assert gammainc(-150.5,800).ae('4.6885137549474089431e-788')
assert gammainc(-3.5, -20.5).ae(0.27008820585226911 - 1310.31447140574997636 j) assert gammainc(-3.5, -20.5).ae(0.27008820585226911 - 1310.31447140574997636 j)
assert gammainc(-3.5, -200.5).ae(0.27008820585226911 - 5.3264597096208368435 e76j) # XXX real part assert gammainc(-3.5, -200.5).ae(0.27008820585226911 - 5.3264597096208368435 e76j) # XXX real part
assert gammainc(0,0,2) == inf assert gammainc(0,0,2) == inf
assert gammainc(1,b=1).ae(0.6321205588285576784) assert gammainc(1,b=1).ae(0.6321205588285576784)
assert gammainc(3,2,2) == 0 assert gammainc(3,2,2) == 0
assert gammainc(2,3+j,3-j).ae(-0.28135485191849314194j) assert gammainc(2,3+j,3-j).ae(-0.28135485191849314194j)
assert gammainc(4+0j,1).ae(5.8860710587430771455) assert gammainc(4+0j,1).ae(5.8860710587430771455)
# GH issue #301
assert gammainc(-1,-1).ae(-0.8231640121031084799 + 3.1415926535897932385j)
assert gammainc(-2,-1).ae(1.7707229202810768576 - 1.5707963267948966192j)
assert gammainc(-3,-1).ae(-1.4963349162467073643 + 0.5235987755982988731j)
assert gammainc(-4,-1).ae(1.05365418617643814992 - 0.13089969389957471827j)
# Regularized upper gamma # Regularized upper gamma
assert isnan(gammainc(0, 0, regularized=True)) assert isnan(gammainc(0, 0, regularized=True))
assert gammainc(-1, 0, regularized=True) == inf assert gammainc(-1, 0, regularized=True) == inf
assert gammainc(1, 0, regularized=True) == 1 assert gammainc(1, 0, regularized=True) == 1
assert gammainc(0, 5, regularized=True) == 0 assert gammainc(0, 5, regularized=True) == 0
assert gammainc(0, 2+3j, regularized=True) == 0 assert gammainc(0, 2+3j, regularized=True) == 0
assert gammainc(0, 5000, regularized=True) == 0 assert gammainc(0, 5000, regularized=True) == 0
assert gammainc(0, 10**30, regularized=True) == 0 assert gammainc(0, 10**30, regularized=True) == 0
assert gammainc(-1, 5, regularized=True) == 0 assert gammainc(-1, 5, regularized=True) == 0
assert gammainc(-1, 5000, regularized=True) == 0 assert gammainc(-1, 5000, regularized=True) == 0
skipping to change at line 912 skipping to change at line 921
assert gammainc(0, 2, 3).ae(0.035852129613864082155) assert gammainc(0, 2, 3).ae(0.035852129613864082155)
assert gammainc(0, 2, 3, regularized=True) == 0 assert gammainc(0, 2, 3, regularized=True) == 0
assert gammainc(-1, 2, 3).ae(0.015219822548487616132) assert gammainc(-1, 2, 3).ae(0.015219822548487616132)
assert gammainc(-1, 2, 3, regularized=True) == 0 assert gammainc(-1, 2, 3, regularized=True) == 0
assert gammainc(0, 2, 3).ae(0.035852129613864082155) assert gammainc(0, 2, 3).ae(0.035852129613864082155)
assert gammainc(0, 2, 3, regularized=True) == 0 assert gammainc(0, 2, 3, regularized=True) == 0
# Should use upper gammas # Should use upper gammas
assert gammainc(5, 10000, 12000).ae('1.1359381951461801687e-4327', abs_eps=0 , rel_eps=8*eps) assert gammainc(5, 10000, 12000).ae('1.1359381951461801687e-4327', abs_eps=0 , rel_eps=8*eps)
# Should use lower gammas # Should use lower gammas
assert gammainc(10000, 2, 3).ae('8.1244514125995785934e4765') assert gammainc(10000, 2, 3).ae('8.1244514125995785934e4765')
# GH issue 306
assert gammainc(3,-1-1j) == 0
assert gammainc(3,-1+1j) == 0
assert gammainc(2,-1) == 0
assert gammainc(2,-1+0j) == 0
assert gammainc(2+0j,-1) == 0
def test_gammainc_expint_n(): def test_gammainc_expint_n():
# These tests are intended to check all cases of the low-level code # These tests are intended to check all cases of the low-level code
# for upper gamma and expint with small integer index. # for upper gamma and expint with small integer index.
# Need to cover positive/negative arguments; small/large/huge arguments # Need to cover positive/negative arguments; small/large/huge arguments
# for both positive and negative indices, as well as indices 0 and 1 # for both positive and negative indices, as well as indices 0 and 1
# which may be special-cased # which may be special-cased
mp.dps = 15 mp.dps = 15
assert expint(-3,3.5).ae(0.021456366563296693987) assert expint(-3,3.5).ae(0.021456366563296693987)
assert expint(-2,3.5).ae(0.014966633183073309405) assert expint(-2,3.5).ae(0.014966633183073309405)
skipping to change at line 983 skipping to change at line 998
assert u.ae('-3.7805306852415755699e+152003068666138139677871') assert u.ae('-3.7805306852415755699e+152003068666138139677871')
# Small case; no branch cut # Small case; no branch cut
assert gammainc(-3,3.5).ae(0.00010020262545203707109) assert gammainc(-3,3.5).ae(0.00010020262545203707109)
assert gammainc(-2,3.5).ae(0.00040370427343557393517) assert gammainc(-2,3.5).ae(0.00040370427343557393517)
assert gammainc(-1,3.5).ae(0.0016576839773997501492) assert gammainc(-1,3.5).ae(0.0016576839773997501492)
assert gammainc(0,3.5).ae(0.0069701398575483929193) assert gammainc(0,3.5).ae(0.0069701398575483929193)
assert gammainc(1,3.5).ae(0.03019738342231850074) assert gammainc(1,3.5).ae(0.03019738342231850074)
assert gammainc(2,3.5).ae(0.13588822540043325333) assert gammainc(2,3.5).ae(0.13588822540043325333)
assert gammainc(3,3.5).ae(0.64169439772426814072) assert gammainc(3,3.5).ae(0.64169439772426814072)
# Small case; with branch cut # Small case; with branch cut
assert gammainc(-3,-3.5).ae(0.03595832954467563286 - 0.52359877559829887308j ) assert gammainc(-3,-3.5).ae(0.03595832954467563286 + 0.52359877559829887308j )
assert gammainc(-2,-3.5).ae(-0.88024704597962022221 - 1.5707963267948966192j ) assert gammainc(-2,-3.5).ae(-0.88024704597962022221 - 1.5707963267948966192j )
assert gammainc(-1,-3.5).ae(4.4637962926688170771 - 3.1415926535897932385j) assert gammainc(-1,-3.5).ae(4.4637962926688170771 + 3.1415926535897932385j)
assert gammainc(0,-3.5).ae(-13.925353995152335292 - 3.1415926535897932385j) assert gammainc(0,-3.5).ae(-13.925353995152335292 - 3.1415926535897932385j)
assert gammainc(1,-3.5).ae(33.115451958692313751) assert gammainc(1,-3.5).ae(33.115451958692313751)
assert gammainc(2,-3.5).ae(-82.788629896730784377) assert gammainc(2,-3.5).ae(-82.788629896730784377)
assert gammainc(3,-3.5).ae(240.08702670051927469) assert gammainc(3,-3.5).ae(240.08702670051927469)
# Asymptotic case; no branch cut # Asymptotic case; no branch cut
assert gammainc(-3,350).ae(6.5424095113340358813e-163, abs_eps=0, rel_eps=8* eps) assert gammainc(-3,350).ae(6.5424095113340358813e-163, abs_eps=0, rel_eps=8* eps)
assert gammainc(-2,350).ae(2.296312222489899769e-160, abs_eps=0, rel_eps=8*e ps) assert gammainc(-2,350).ae(2.296312222489899769e-160, abs_eps=0, rel_eps=8*e ps)
assert gammainc(-1,350).ae(8.059861834133858573e-158, abs_eps=0, rel_eps=8*e ps) assert gammainc(-1,350).ae(8.059861834133858573e-158, abs_eps=0, rel_eps=8*e ps)
assert gammainc(0,350).ae(2.8289659656701459404e-155, abs_eps=0, rel_eps=8*e ps) assert gammainc(0,350).ae(2.8289659656701459404e-155, abs_eps=0, rel_eps=8*e ps)
assert gammainc(1,350).ae(9.9295903962649792963e-153, abs_eps=0, rel_eps=8*e ps) assert gammainc(1,350).ae(9.9295903962649792963e-153, abs_eps=0, rel_eps=8*e ps)
assert gammainc(2,350).ae(3.485286229089007733e-150, abs_eps=0, rel_eps=8*ep s) assert gammainc(2,350).ae(3.485286229089007733e-150, abs_eps=0, rel_eps=8*ep s)
assert gammainc(3,350).ae(1.2233453960006379793e-147, abs_eps=0, rel_eps=8*e ps) assert gammainc(3,350).ae(1.2233453960006379793e-147, abs_eps=0, rel_eps=8*e ps)
# Asymptotic case; branch cut # Asymptotic case; branch cut
u = gammainc(-3,-350) u = gammainc(-3,-350)
assert u.ae(6.7889565783842895085e+141) assert u.ae(6.7889565783842895085e+141)
assert u.imag.ae(-0.52359877559829887308) assert u.imag.ae(0.52359877559829887308)
u = gammainc(-2,-350) u = gammainc(-2,-350)
assert u.ae(-2.3692668977889832121e+144) assert u.ae(-2.3692668977889832121e+144)
assert u.imag.ae(-1.5707963267948966192) assert u.imag.ae(-1.5707963267948966192)
u = gammainc(-1,-350) u = gammainc(-1,-350)
assert u.ae(8.2685354361441858669e+146) assert u.ae(8.2685354361441858669e+146)
assert u.imag.ae(-3.1415926535897932385) assert u.imag.ae(3.1415926535897932385)
u = gammainc(0,-350) u = gammainc(0,-350)
assert u.ae(-2.8856710698020863568e+149) assert u.ae(-2.8856710698020863568e+149)
assert u.imag.ae(-3.1415926535897932385) assert u.imag.ae(-3.1415926535897932385)
u = gammainc(1,-350) u = gammainc(1,-350)
assert u.ae(1.0070908870280797598e+152) assert u.ae(1.0070908870280797598e+152)
assert u.imag == 0 assert u.imag == 0
u = gammainc(2,-350) u = gammainc(2,-350)
assert u.ae(-3.5147471957279983618e+154) assert u.ae(-3.5147471957279983618e+154)
assert u.imag == 0 assert u.imag == 0
u = gammainc(3,-350) u = gammainc(3,-350)
skipping to change at line 1030 skipping to change at line 1045
# Extreme asymptotic case # Extreme asymptotic case
assert gammainc(-3,350000000000000000000000).ae('5.0362468738874738859e-1520 03068666138139677990', abs_eps=0, rel_eps=8*eps) assert gammainc(-3,350000000000000000000000).ae('5.0362468738874738859e-1520 03068666138139677990', abs_eps=0, rel_eps=8*eps)
assert gammainc(-2,350000000000000000000000).ae('1.7626864058606158601e-1520 03068666138139677966', abs_eps=0, rel_eps=8*eps) assert gammainc(-2,350000000000000000000000).ae('1.7626864058606158601e-1520 03068666138139677966', abs_eps=0, rel_eps=8*eps)
assert gammainc(-1,350000000000000000000000).ae('6.1694024205121555102e-1520 03068666138139677943', abs_eps=0, rel_eps=8*eps) assert gammainc(-1,350000000000000000000000).ae('6.1694024205121555102e-1520 03068666138139677943', abs_eps=0, rel_eps=8*eps)
assert gammainc(0,350000000000000000000000).ae('2.1592908471792544286e-15200 3068666138139677919', abs_eps=0, rel_eps=8*eps) assert gammainc(0,350000000000000000000000).ae('2.1592908471792544286e-15200 3068666138139677919', abs_eps=0, rel_eps=8*eps)
assert gammainc(1,350000000000000000000000).ae('7.5575179651273905e-15200306 8666138139677896', abs_eps=0, rel_eps=8*eps) assert gammainc(1,350000000000000000000000).ae('7.5575179651273905e-15200306 8666138139677896', abs_eps=0, rel_eps=8*eps)
assert gammainc(2,350000000000000000000000).ae('2.645131287794586675e-152003 068666138139677872', abs_eps=0, rel_eps=8*eps) assert gammainc(2,350000000000000000000000).ae('2.645131287794586675e-152003 068666138139677872', abs_eps=0, rel_eps=8*eps)
assert gammainc(3,350000000000000000000000).ae('9.2579595072810533625e-15200 3068666138139677849', abs_eps=0, rel_eps=8*eps) assert gammainc(3,350000000000000000000000).ae('9.2579595072810533625e-15200 3068666138139677849', abs_eps=0, rel_eps=8*eps)
u = gammainc(-3,-350000000000000000000000) u = gammainc(-3,-350000000000000000000000)
assert u.ae('8.8175642804468234866e+152003068666138139677800') assert u.ae('8.8175642804468234866e+152003068666138139677800')
assert u.imag.ae(-0.52359877559829887308) assert u.imag.ae(0.52359877559829887308)
u = gammainc(-2,-350000000000000000000000) u = gammainc(-2,-350000000000000000000000)
assert u.ae('-3.0861474981563882203e+152003068666138139677824') assert u.ae('-3.0861474981563882203e+152003068666138139677824')
assert u.imag.ae(-1.5707963267948966192) assert u.imag.ae(-1.5707963267948966192)
u = gammainc(-1,-350000000000000000000000) u = gammainc(-1,-350000000000000000000000)
assert u.ae('1.0801516243547358771e+152003068666138139677848') assert u.ae('1.0801516243547358771e+152003068666138139677848')
assert u.imag.ae(-3.1415926535897932385) assert u.imag.ae(3.1415926535897932385)
u = gammainc(0,-350000000000000000000000) u = gammainc(0,-350000000000000000000000)
assert u.ae('-3.7805306852415755699e+152003068666138139677871') assert u.ae('-3.7805306852415755699e+152003068666138139677871')
assert u.imag.ae(-3.1415926535897932385) assert u.imag.ae(-3.1415926535897932385)
assert gammainc(1,-350000000000000000000000).ae('1.3231857398345514495e+1520 03068666138139677895') assert gammainc(1,-350000000000000000000000).ae('1.3231857398345514495e+1520 03068666138139677895')
assert gammainc(2,-350000000000000000000000).ae('-4.6311500894209300731e+152 003068666138139677918') assert gammainc(2,-350000000000000000000000).ae('-4.6311500894209300731e+152 003068666138139677918')
assert gammainc(3,-350000000000000000000000).ae('1.6209025312973255256e+1520 03068666138139677942') assert gammainc(3,-350000000000000000000000).ae('1.6209025312973255256e+1520 03068666138139677942')
def test_incomplete_beta(): def test_incomplete_beta():
mp.dps = 15 mp.dps = 15
assert betainc(-2,-3,0.5,0.75).ae(63.4305673311255413583969) assert betainc(-2,-3,0.5,0.75).ae(63.4305673311255413583969)
 End of changes. 10 change blocks. 
10 lines changed or deleted 27 lines changed or added

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