I wanted to know how I can generate pi up to the nth digit. I have a couple of basic ideas.
- Use
Math.PI and increase accuracy (if possible) - Use the Euler formula to generate pi, but even here I will need to increase the accuracy (I think)

- There is also the Srinivasa Ramanujan formula for generating PI, which is known for its fast convergence. This formula seems complicated. I suppose I would also need to increase the optimal accuracy.

So, in any case, I need to increase the accuracy of BigDecimal depending on what the nth digit is. How can I increase the accuracy of BigDecimal to the nth digit? Also, if it will be better and faster, can you point me in the right direction.
EDIT: I just want to create a PI. I do not want to use for calculations. and this is a question about how I can use BigDecimal to implement my ideas for generating PI.
java precision pi bigdecimal
Jeel shah
source share