community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
SOLVED

Calculating Pi to an infinate number of sig figs for no good reason

Bolide

Has anyone built anything to calc pi - infinite series style.

 

I wrote this for Excel:

===========================================================================================

Sub Button1_Click()
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
Range("xfd:xfd").Clear
Range("G6").Clear
Range("H6").Clear
Range("F6").Clear
Range("G10").Select
Part1 = 0

a = 1
b = 0
x = 2
y = 3
Z = 4

Do Until a > 1048576

Range("xfd" & a) = 4 / (x * y * Z)

a = a + 1
b = b + 1
x = x + 2
y = y + 2
Z = Z + 2

Range("xfd" & a) = -4 / (x * y * Z)

a = a + 1
x = x + 2
y = y + 2
Z = Z + 2

Part1 = Application.WorksheetFunction.Sum(ws.Range("xfd:xfd"))
Range("G6") = a - 1
Range("H6") = 3 + Part1
Range("H6").NumberFormat = "0.0000000000000000000"
Range("F6") = (b * 18) + 13

Loop

Range("F6") = (b * 18) + 17

MsgBox 3 + Part1, , "Aproximating Pi"

End Sub

=======================================================================================

I was thinking of trying to put the square peg into a round workflow.

 

Someone is telling me to use Chudnovsky algorithm.

 

If anyone has something built, I'd like to see it - for next Pi Day.

 

Fun challenge:

 

Sub Button1_Click()
    Dim ws As Worksheet
    Set ws = Worksheets("Sheet1")

    Range("A:A").Clear
    Range("H6").Clear
    b = 0
    Do Until b > 100
        Range("A" & (2 * b + 1)) = 4 / ((4 * b + 2) * (4 * b + 3) * (4 * b + 4))
        Range("A" & (2 * b + 2)) = -4 / ((4 * b + 4) * (4 * b + 5) * (4 * b + 6))
        b = b + 1

        Part1 = Application.WorksheetFunction.Sum(ws.Range("A:A"))
        Range("H6") = 3 + Part1
        Range("H6").NumberFormat = "0.0000000000000000000"
    Loop
    MsgBox 3 + Part1, , "Aproximating Pi"
End Sub

 

That's the same algorithm, but closer to something we can build in Alteryx.

 

So here's my one evening approach:

 

2019-03-19_21-13-18.jpg

 

Basically avoid leaving integer space until as late as possible

Unfortunately Alteryx only has double computation in formula tool so limitation on accuracy.

 

Assuming am allow to add some custom tools can probably add support higher accuracy but need to think approach.

 

Anyway first go attached...

 

 

 

Labels