[B4X] Today - Pi Day

Star-Dust

Expert
Licensed User
Longtime User
Some B4X methods to calculate it

1) Formulas di Leibniz
B4X:
Dim N As Int = 1000 ' The greater the value, the greater the precision
Dim PiGreek As Double = 1
 
For i=1 To N
    PiGreek=PiGreek+Power(-1,i)/(2*i+1)
Next
 
Log(4*PiGreek)

2) Formulas di Machin
B4X:
Dim PiGreek As Double = 4*ATan(1/5)-ATan(1/239)

Log(4*PiGreek)

3) Formulas di Wallis
B4X:
Dim N As Int = 1000
Dim PiGreek As Double = 1

For i=1 To N
    PiGreek=PiGreek*((i*2)/((i-1)*2+1))*((i*2)/((i-1)*2+3))
Next

Log(2*PiGreek)
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
Sub AppStart (Args() As String)
   Dim CountIn As Int
   Dim Total As Int = 100000000
   For i = 0 To Total - 1
       Dim r1 As Int = Rnd(0, 0x7fffffff)
       Dim r2 As Int = Rnd(0, 0x7fffffff)
       Dim x As Double = r1 / 0x7fffffff
       Dim y As Double = r2 / 0x7fffffff
       Dim distance2 As Double = Power(x - 0.5, 2) + Power(y - 0.5, 2)
       If distance2 <= 0.25 Then CountIn = CountIn + 1
   Next
   Log(CountIn / Total / 0.25)
End Sub
 

Star-Dust

Expert
Licensed User
Longtime User
Formulas di Basel
B4X:
Dim N As Int = 1000
Dim PiGreek As Double = 0
   
For i=1 To N
        PiGreek=PiGreek+1/Power(i,2)
Next
   
Log(Sqrt(PiGreek*6))
 

MarkusR

Well-Known Member
Licensed User
Longtime User
simplified ~ 22/7
 

MarkusR

Well-Known Member
Licensed User
Longtime User
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
I'll talk about it with Euler
 

Star-Dust

Expert
Licensed User
Longtime User
Today March 14 2026 is the day of the Greek Pi

There is a mathematical relationship that links pi to other mathematical constants and which design the universe and creation



Euler's identity is a formula that deals with powers and complex numbers by putting together some of the most important and famous mathematical constants. And it is precisely thanks to its ability to inextricably link the following numbers that many scholars consider it one of the most beautiful formulas in mathematics
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…