In [6]:
from math import erf
def erfVersionOfBoysFunction(x):
return erf(sqrt(x))*sqrt(pi)/(2*sqrt(x))
In [24]:
s = 0.01; e=50; c = 20
nmax = 100;
xvec = linspace(s,e,c)
F0 = zeros(c)
print "Boys boysF0_small(0);"+ "\n" \
+"mat F0; rowvec xvec;" + "\n" \
+"xvec = linspace<rowvec>(" + str(s) + "," + str(e)+ "," + str(c) + ");" \
+ "\n" + "F0 = zeros(" + str(c)+ ",1);"
print "for(uint i = 0; i < " + str(c) + "; i++){" + "\n" \
+ " boysF0_small.evaluateBoysFunctions(xvec[i]);" + "\n" \
+ " F0.row(i) = boysF0_small.getBoysFunctions();" + "\n" \
+ "}" +"\n"
for i in range(0, c):
F0[i] = erfVersionOfBoysFunction(xvec[i])
print "CHECK_CLOSE(F0(" \
+str(i)+ ",0)"+ ", " + str("%.16e" %F0[i])\
+ ", 1e-10);"
In [10]:
def factorialBoysFunction(x,n):
return 1.0/(2**(n+1)) * sqrt(pi/x**(2*n+1))
In [25]:
s = 51; e=100; c = 20
nmax = 100;
xvec = linspace(s,e,c)
F0 = zeros(c)
print "Boys boysF0_large(0);"+ "\n" \
+"xvec = linspace<rowvec>(" + str(s) + "," + str(e)+ "," + str(c) + ");" \
+ "\n" + "F0 = zeros(" + str(c)+ ",1);"
print "for(uint i = 0; i < " + str(c) + "; i++){" + "\n" \
+ " boysF0_large.evaluateBoysFunctions(xvec[i]);" + "\n" \
+ " F0.row(i) = boysF0_large.getBoysFunctions();" + "\n" \
+ "}" +"\n"
for i in range(0, c):
F0[i] = erfVersionOfBoysFunction(xvec[i])
print "CHECK_CLOSE(F0(" \
+str(i)+ ",0)"+ ", " + str("%.16e" %F0[i])\
+ ", 1e-10);"
In [16]:
n_max = 20
F_exact = zeros(n_max+1)
for n in range(0,n_max+1,1):
F_exact[n] = 1.0/(2*n+1)
print "CHECK_CLOSE(Fn[" + str(n)+ "]"+ ", " + str("%.16e" % F_exact[n])\
+ ", 1e-10);"
In [28]:
s = 0.01; e=50; c = 20
xvec = linspace(s,e,c)
F0 = zeros(c)
n = 15
print "Boys boysF0_small("+str(n)+");"+ "\n" \
+"mat F0; rowvec xvec;" + "\n" \
+"xvec = linspace<rowvec>(" + str(s) + "," + str(e)+ "," + str(c) + ");" \
+ "\n" + "F0 = zeros(" + str(c)+ "," + str(n+1)+ ");"
print "for(uint i = 0; i < " + str(c) + "; i++){" + "\n" \
+ " boysF0_small.evaluateBoysFunctions(xvec[i]);" + "\n" \
+ " F0.row(i) = boysF0_small.getBoysFunctions();" + "\n" \
+ "}" +"\n"
for i in range(0, c):
F0[i] = erfVersionOfBoysFunction(xvec[i])
print "CHECK_CLOSE(F0(" \
+str(i)+ ",0)"+ ", " + str("%.16e" % F0[i])\
+ ", 1e-10);"
In [29]:
s = 51; e=100; c = 20
xvec = linspace(s,e,c)
F0 = zeros(c)
n = 15
print "Boys boysF0_large("+str(n)+");"+ "\n" \
+"xvec = linspace<rowvec>(" + str(s) + "," + str(e)+ "," + str(c) + ");" \
+ "\n" + "F0 = zeros(" + str(c)+ ","+str(n+1)+");"
print "for(uint i = 0; i < " + str(c) + "; i++){" + "\n" \
+ " boysF0_large.evaluateBoysFunctions(xvec[i]);" + "\n" \
+ " F0.row(i) = boysF0_large.getBoysFunctions();" + "\n" \
+ "}" +"\n"
for i in range(0, c):
F0[i] = erfVersionOfBoysFunction(xvec[i])
print "CHECK_CLOSE(F0(" \
+str(i)+ ",0)"+ ", " + str("%.16e" %F0[i])\
+ ", 1e-10);"
In [8]:
In [8]:
In [8]:
In [8]:
In [8]:
In [9]:
s = 0.01; e=0.09; c = 10
nmax = 100;
xvec = linspace(s,e,c)
Fpvec = zeros(c)
F_exact = zeros(c)
print "vec xvec, Fpvec;" + "\n" \
+"xvec = linspace(" + str(s) + "," + str(e)+ "," + str(c) + ");" \
+ "\n" + "Fpvec = zeros(" + str(c)+ ");"
print "for(uint i = 0; i < " + str(c) + "; i++){" + "\n" \
" for(uint n = " + str(nmax)+ "; n > 0; n--){" + "\n" \
+ " Fpvec[i] = boys.downwardRecursion(xvec[i],n);" + "\n" \
+ "}" +"\n" \
+ " }"
for i in range(0, c):
F_exact[i] = erfVersionOfBoysFunction(xvec[i])
Fpvec[i] = factorialBoysFunction(xvec[i], 0)
print "CHECK_CLOSE(Fpvec[" \
+str(i)+ "]"+ ", " + str(F_exact[i])\
+ ", 1e-10);"
In [10]:
s = 20; e=100; c = 10
nmax = 10;
xvec = linspace(s,e,c)
Fpvec = zeros(c)
F_exact = zeros(c)
print "vec xvec, Fpvec;" + "\n" \
+"xvec = linspace(" + str(s) + "," + str(e)+ "," + str(c) + ");" \
+ "\n" + "Fpvec = zeros(" + str(c)+ ");"
print "for(uint i = 0; i < " + str(c) + "; i++){" + "\n" \
" for(uint n = " + str(nmax)+ "; n > 0; n--){" + "\n" \
+ " Fpvec[i] = boys.downwardRecursion(xvec[i],n);" + "\n" \
+ "}" +"\n" \
+ " }"
for i in range(0, c):
F_exact[i] = erfVersionOfBoysFunction(xvec[i])
Fpvec[i] = factorialBoysFunction(xvec[i], 0)
print "CHECK_CLOSE(Fpvec[" \
+str(i)+ "]"+ ", " + str(F_exact[i])\
+ ", 1e-10);"
In [10]: