QB / QB64 Discussion Forum      Other Subforums, Links and Downloads
 Return to Index  

Better

February 12 2012 at 4:11 PM
EW Dijkstra  (no login)


Response to Certainly

DEFDBL A-Z
' Approximates Gaussian integral
' e^(-x^2) from -infinity to +infinity = sqrt(pi)
' to calculate pi
' It is not difficult to prove this integral
' using complex analysis
CLS
zero = 2 - 2
a = zero
b = 22
n = 22222
f = zero
dx = (b - a) / n
FOR x = a TO b STEP dx
f = f + 2 * EXP(-x ^ 2) * dx
NEXT
f = (f - EXP(-a ^ 2) * dx - EXP(-b ^ 2) * dx) / 2
PRINT 2 * 2 * f * f

 
 Respond to this message   
Responses