# Program to evaluate erf(x) using Gauss method:
from math import*
def f(x):
y=2/pi**0.5*exp(-x*x)
return y
f1=open("gauss.d","w")
a=0.0
h=0.001
for n in range(0,5001,50):
z=0
b=a+n*h
for i in range(1,n):
z=z+f(a+i*h)
r=(f(a)+f(b)+2*z)*(h/2)
print(b,r,file=f1)
f1.close()
from math import*
def f(x):
y=2/pi**0.5*exp(-x*x)
return y
f1=open("gauss.d","w")
a=0.0
h=0.001
for n in range(0,5001,50):
z=0
b=a+n*h
for i in range(1,n):
z=z+f(a+i*h)
r=(f(a)+f(b)+2*z)*(h/2)
print(b,r,file=f1)
f1.close()
Comments
Post a Comment