How do I calculate Pi?

Today it is Pi day. So I thought it would be fun to make an AppInventor app to calculate decimals of Pi. I asked ChatGpt to help me out.

It gave me a 10 page document on how to do it. Then I asked to make an .aia for it, in the hope it had improved since the last time I asked for an .aia a few months ago. No luck.

Maybe I will retry later. Anyone has a good idea about how to let ChatGpt (or some other) do the work for you?

I tried Aptly but it doesn’t work anymore.

This time it worked. It made this.

Here is the aia.

PiDay.aia (2.6 KB)

I got this warning.

image

Halo! It is certainly possible to code mathematical functions with ChatGPT or any other AI.

I made this function (Ramanujan's Pi estimation) using AI:

This is the result, it generates upto 5 decimal points.

1 Like

Here is another function that uses MachinPi (also created by AI):

func MachinPi(terms) = {
  local arctan1 = 0
  local arctan2 = 0

  for (k: 0 .. terms - 1) {
    local sign = if (k % 2 == 0) 1 else -1
    local exp = 2 * k + 1
    arctan1 = arctan1 + sign * (1 / (5 ^ exp)) / exp
    arctan2 = arctan2 + sign * (1 / (239 ^ exp)) / exp
  }

  16 * arctan1 - 4 * arctan2
}

println(MachinPi(10))

You can paste these codes in https://falcon.ekita.me/ to get the blocks.

…and all it needed was

1 Like

This is of course awesome. What I wanted however, was to calculate pi the old fashioned way as invented by Archimedes.

Too late for today now, I will look at the other replies later.

4 years ago we already had a Pi day challenge...

Taifun

2 Likes