Re: A way to calculate Pi
22/7=3,1428571428571428571428571428571
Pi=3,1415926535897932384626433832795
:D:)
Re: A way to calculate Pi
Why do you show like 40 digits if only the first two are correct lol.
Re: A way to calculate Pi
To see that they are not correct
Re: A way to calculate Pi
Why wouldn't you just use Math.PI?
Re: A way to calculate Pi
... because - just showing a way to calculate it
Kris
Re: A way to calculate Pi
Well that doesn't provide an accurate result at all.
After the first 2 digits, it's already entirely incorrect.
Re: A way to calculate Pi
Quote:
Originally Posted by
Mathiaslylo
Well that doesn't provide an accurate result at all.
After the first 2 digits, it's already entirely incorrect.
I know this is inaccurate ... just a demo of how to do it using the Gregory-Leibniz method.
Check this wikipedia link for more details
Re: A way to calculate Pi
Quote:
Originally Posted by
i00
I know this is inaccurate ... just a demo of how to do it using the Gregory-Leibniz method.
Check
this wikipedia link for more details
Reminds me of Professor Frink's sarcasm detector. Comic Book Guy: Now that's really useful ... (machine explodes)
Just kidding Kris, it's a nice code example. BB
Re: A way to calculate Pi
@i00 Seems like you and I are stuck in the same boat.
vbnet Code:
Public ReadOnly Property Pi(ByVal Optional limit As Int32 = 25) As Double
'Pi = (6(1/1^2 + 1/2^2 + 1/3^2 + 1/4^2 + ...))^(1/2)
Get
Dim result As Double
Dim tmp As Double = 0.0
For i As Int32 = 1 To limit
tmp = tmp + (1/i)^2
Next
result = (6*tmp)^(1/2)
Return result
End Get
End Property
This is only as accurate as the number of times you process it.. and of course the higher you go the longer it takes. I've pushed it to 100,000,000x before I realized this is not practical for my applications use. 100,000,000x gave me 3.14159264498239. My guess is 1,000,000,000x will produce 3.14159265... so on and so forth.. just as you proposed in your method.