"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "mpmath/tests/test_gammazeta.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_gammazeta.py  (mpmath-1.0.0):test_gammazeta.py  (mpmath-1.1.0)
skipping to change at line 217 skipping to change at line 217
ep = 1e-4 ep = 1e-4
G = gamma G = gamma
assert gammaprod([-1],[-3,-4]) == 0 assert gammaprod([-1],[-3,-4]) == 0
assert gammaprod([-1,0],[-5]) == inf assert gammaprod([-1,0],[-5]) == inf
assert abs(gammaprod([-1],[-2]) - G(-1+h)/G(-2+h)) < 1e-4 assert abs(gammaprod([-1],[-2]) - G(-1+h)/G(-2+h)) < 1e-4
assert abs(gammaprod([-4,-3],[-2,0]) - G(-4+h)*G(-3+h)/G(-2+h)/G(0+h)) < 1e- 4 assert abs(gammaprod([-4,-3],[-2,0]) - G(-4+h)*G(-3+h)/G(-2+h)/G(0+h)) < 1e- 4
assert rf(3,0) == 1 assert rf(3,0) == 1
assert rf(2.5,1) == 2.5 assert rf(2.5,1) == 2.5
assert rf(-5,2) == 20 assert rf(-5,2) == 20
assert rf(j,j).ae(gamma(2*j)/gamma(j)) assert rf(j,j).ae(gamma(2*j)/gamma(j))
assert rf('-255.5815971722918','-0.5119253100282322').ae('-0.195272027880572 9485') # issue 421
assert ff(-2,0) == 1 assert ff(-2,0) == 1
assert ff(-2,1) == -2 assert ff(-2,1) == -2
assert ff(4,3) == 24 assert ff(4,3) == 24
assert ff(3,4) == 0 assert ff(3,4) == 0
assert binomial(0,0) == 1 assert binomial(0,0) == 1
assert binomial(1,0) == 1 assert binomial(1,0) == 1
assert binomial(0,-1) == 0 assert binomial(0,-1) == 0
assert binomial(3,2) == 3 assert binomial(3,2) == 3
assert binomial(5,2) == 10 assert binomial(5,2) == 10
assert binomial(5,3) == 10 assert binomial(5,3) == 10
skipping to change at line 250 skipping to change at line 251
assert beta(inf,inf) == 0 assert beta(inf,inf) == 0
assert isnan(beta(-inf,inf)) assert isnan(beta(-inf,inf))
assert isnan(beta(-3,inf)) assert isnan(beta(-3,inf))
assert isnan(beta(0,inf)) assert isnan(beta(0,inf))
assert beta(inf,0.5) == beta(0.5,inf) == 0 assert beta(inf,0.5) == beta(0.5,inf) == 0
assert beta(inf,-1.5) == inf assert beta(inf,-1.5) == inf
assert beta(inf,-0.5) == -inf assert beta(inf,-0.5) == -inf
assert beta(1+2j,-1-j/2).ae(1.16396542451069943086+0.08511695947832914640j) assert beta(1+2j,-1-j/2).ae(1.16396542451069943086+0.08511695947832914640j)
assert beta(-0.5,0.5) == 0 assert beta(-0.5,0.5) == 0
assert beta(-3,3).ae(-1/3.) assert beta(-3,3).ae(-1/3.)
assert beta('-255.5815971722918','-0.5119253100282322').ae('18.1573305627037 10339') # issue 421
def test_zeta(): def test_zeta():
mp.dps = 15 mp.dps = 15
assert zeta(2).ae(pi**2 / 6) assert zeta(2).ae(pi**2 / 6)
assert zeta(2.0).ae(pi**2 / 6) assert zeta(2.0).ae(pi**2 / 6)
assert zeta(mpc(2)).ae(pi**2 / 6) assert zeta(mpc(2)).ae(pi**2 / 6)
assert zeta(100).ae(1) assert zeta(100).ae(1)
assert zeta(0).ae(-0.5) assert zeta(0).ae(-0.5)
assert zeta(0.5).ae(-1.46035450880958681) assert zeta(0.5).ae(-1.46035450880958681)
assert zeta(-1).ae(-mpf(1)/12) assert zeta(-1).ae(-mpf(1)/12)
skipping to change at line 283 skipping to change at line 285
mp.dps = 50 mp.dps = 50
im = '236.5242296658162058024755079556629786895294952121891237' im = '236.5242296658162058024755079556629786895294952121891237'
assert zeta(mpc(0.5, im)).ae(0, 1e-46) assert zeta(mpc(0.5, im)).ae(0, 1e-46)
mp.dps = 15 mp.dps = 15
# Complex reflection formula # Complex reflection formula
assert (zeta(-60+3j) / 10**34).ae(8.6270183987866146+15.337398548226238j) assert (zeta(-60+3j) / 10**34).ae(8.6270183987866146+15.337398548226238j)
# issue #358 # issue #358
assert zeta(0,0.5) == 0 assert zeta(0,0.5) == 0
assert zeta(0,0) == 0.5 assert zeta(0,0) == 0.5
assert zeta(0,0.5,1).ae(-0.34657359027997265) assert zeta(0,0.5,1).ae(-0.34657359027997265)
# see issue #390
assert zeta(-1.5,0.5j).ae(-0.13671400162512768475 + 0.11411333638426559139j)
def test_altzeta(): def test_altzeta():
mp.dps = 15 mp.dps = 15
assert altzeta(-2) == 0 assert altzeta(-2) == 0
assert altzeta(-4) == 0 assert altzeta(-4) == 0
assert altzeta(-100) == 0 assert altzeta(-100) == 0
assert altzeta(0) == 0.5 assert altzeta(0) == 0.5
assert altzeta(-1) == 0.25 assert altzeta(-1) == 0.25
assert altzeta(-3) == -0.125 assert altzeta(-3) == -0.125
assert altzeta(-5) == 0.25 assert altzeta(-5) == 0.25
skipping to change at line 351 skipping to change at line 355
psi1 = lambda z: psi(1,z) psi1 = lambda z: psi(1,z)
assert psi0(3) == psi(0,3) == digamma(3) assert psi0(3) == psi(0,3) == digamma(3)
#assert psi2(3) == psi(2,3) == tetragamma(3) #assert psi2(3) == psi(2,3) == tetragamma(3)
#assert psi3(3) == psi(3,3) == pentagamma(3) #assert psi3(3) == psi(3,3) == pentagamma(3)
assert psi0(pi).ae(0.97721330794200673) assert psi0(pi).ae(0.97721330794200673)
assert psi0(-pi).ae(7.8859523853854902) assert psi0(-pi).ae(7.8859523853854902)
assert psi0(-pi+1).ae(7.5676424992016996) assert psi0(-pi+1).ae(7.5676424992016996)
assert psi0(pi+j).ae(1.04224048313859376 + 0.35853686544063749j) assert psi0(pi+j).ae(1.04224048313859376 + 0.35853686544063749j)
assert psi0(-pi-j).ae(1.3404026194821986 - 2.8824392476809402j) assert psi0(-pi-j).ae(1.3404026194821986 - 2.8824392476809402j)
assert findroot(psi0, 1).ae(1.4616321449683622) assert findroot(psi0, 1).ae(1.4616321449683622)
assert psi0(1e-10).ae(-10000000000.57722)
assert psi0(1e-40).ae(-1.000000000000000e+40)
assert psi0(1e-10+1e-10j).ae(-5000000000.577215 + 5000000000.000000j)
assert psi0(1e-40+1e-40j).ae(-5.000000000000000e+39 + 5.000000000000000e+39j
)
assert psi0(inf) == inf assert psi0(inf) == inf
assert psi1(inf) == 0 assert psi1(inf) == 0
assert psi(2,inf) == 0 assert psi(2,inf) == 0
assert psi1(pi).ae(0.37424376965420049) assert psi1(pi).ae(0.37424376965420049)
assert psi1(-pi).ae(53.030438740085385) assert psi1(-pi).ae(53.030438740085385)
assert psi1(pi+j).ae(0.32935710377142464 - 0.12222163911221135j) assert psi1(pi+j).ae(0.32935710377142464 - 0.12222163911221135j)
assert psi1(-pi-j).ae(-0.30065008356019703 + 0.01149892486928227j) assert psi1(-pi-j).ae(-0.30065008356019703 + 0.01149892486928227j)
assert (10**6*psi(4,1+10*pi*j)).ae(-6.1491803479004446 - 0.3921316371664063j ) assert (10**6*psi(4,1+10*pi*j)).ae(-6.1491803479004446 - 0.3921316371664063j )
assert psi0(1+10*pi*j).ae(3.4473994217222650 + 1.5548808324857071j) assert psi0(1+10*pi*j).ae(3.4473994217222650 + 1.5548808324857071j)
assert isnan(psi0(nan)) assert isnan(psi0(nan))
skipping to change at line 505 skipping to change at line 513
mp.dps = 50 mp.dps = 50
y = gamma(x) y = gamma(x)
assert str(y.real) == (\ assert str(y.real) == (\
"-3.2775389963494132168950056995974690946983219123935e-22739605897364022 458096393" "-3.2775389963494132168950056995974690946983219123935e-22739605897364022 458096393"
"7571892628368354580620654233316839") "7571892628368354580620654233316839")
assert str(y.imag) == (\ assert str(y.imag) == (\
"-7.1519888950415979749736749222530209713136588885897e-22739605897364022 458096393" "-7.1519888950415979749736749222530209713136588885897e-22739605897364022 458096393"
"7571892628368354580620654233316841") "7571892628368354580620654233316841")
mp.dps = 15 mp.dps = 15
def test_gamma_huge_6():
return
mp.dps = 500
x = -10**10 + mpf(10)**(-175)*j
mp.dps = 15
assert str(gamma(x)) == \
"(1.86729378905343e-95657055178 - 4.29960285282433e-95657055002j)"
mp.dps = 50
assert str(gamma(x)) == (\
"(1.8672937890534298925763143275474177736153484820662e-9565705517"
"8 - 4.2996028528243336966001185406200082244961757496106e-9565705"
"5002j)")
mp.dps = 15
def test_gamma_huge_7(): def test_gamma_huge_7():
mp.dps = 100 mp.dps = 100
a = 3 + j/mpf(10)**1000 a = 3 + j/mpf(10)**1000
mp.dps = 15 mp.dps = 15
y = gamma(a) y = gamma(a)
assert str(y.real) == "2.0" assert str(y.real) == "2.0"
# wrong # wrong
#assert str(y.imag) == "2.16735365342606e-1000" #assert str(y.imag) == "2.16735365342606e-1000"
assert str(y.imag) == "1.84556867019693e-1000" assert str(y.imag) == "1.84556867019693e-1000"
mp.dps = 50 mp.dps = 50
skipping to change at line 593 skipping to change at line 587
assert polylog(2, -1.1).ae(-0.89083809026228260587) assert polylog(2, -1.1).ae(-0.89083809026228260587)
assert polylog(2, 1.1*sqrt(j)).ae(0.58841571107611387722+1.09962542118827026 011j) assert polylog(2, 1.1*sqrt(j)).ae(0.58841571107611387722+1.09962542118827026 011j)
assert polylog(-2, 0.9).ae(1710) assert polylog(-2, 0.9).ae(1710)
assert polylog(-2, -0.9).ae(-90/6859.) assert polylog(-2, -0.9).ae(-90/6859.)
assert polylog(3, 0.9).ae(1.0496589501864398696) assert polylog(3, 0.9).ae(1.0496589501864398696)
assert polylog(-3, 0.9).ae(48690) assert polylog(-3, 0.9).ae(48690)
assert polylog(-3, -4).ae(-0.0064) assert polylog(-3, -4).ae(-0.0064)
assert polylog(0.5+j/3, 0.5+j/2).ae(0.31739144796565650535 + 0.9925539041655 6261437j) assert polylog(0.5+j/3, 0.5+j/2).ae(0.31739144796565650535 + 0.9925539041655 6261437j)
assert polylog(3+4j,1).ae(zeta(3+4j)) assert polylog(3+4j,1).ae(zeta(3+4j))
assert polylog(3+4j,-1).ae(-altzeta(3+4j)) assert polylog(3+4j,-1).ae(-altzeta(3+4j))
# issue 390
assert polylog(1.5, -48.910886523731889).ae(-6.272992229311817)
assert polylog(1.5, 200).ae(-8.349608319033686529 - 8.159694826434266042j)
def test_bell_polyexp(): def test_bell_polyexp():
mp.dps = 15 mp.dps = 15
# TODO: more tests for polyexp # TODO: more tests for polyexp
assert (polyexp(0,1e-10)*10**10).ae(1.00000000005) assert (polyexp(0,1e-10)*10**10).ae(1.00000000005)
assert (polyexp(1,1e-10)*10**10).ae(1.0000000001) assert (polyexp(1,1e-10)*10**10).ae(1.0000000001)
assert polyexp(5,3j).ae(-607.7044517476176454+519.962786482001476087j) assert polyexp(5,3j).ae(-607.7044517476176454+519.962786482001476087j)
assert polyexp(-1,3.5).ae(12.09537536175543444) assert polyexp(-1,3.5).ae(12.09537536175543444)
# bell(0,x) = 1 # bell(0,x) = 1
assert bell(0,0) == 1 assert bell(0,0) == 1
 End of changes. 6 change blocks. 
14 lines changed or deleted 12 lines changed or added

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