So, you might have already seen @StudentFires 's attempt at a fast and accurate π approximation in C++...
So, here are two actually fast and accurate π approximations in C:
The repl linked to this post is the most accurate and is found at https://repl.it/@AmazingMech2418/p-in-C and the other is https://repl.it/@AmazingMech2418/p-in-C-2.
The first one uses trapezoidal sums while the other uses the Nilakantha Series.
Update: The second one was updated to make it faster. It gets to 16 places very quickly.
Also i can do this real fast. Imma challenge you.
@Jakman What is the challenge?
@AmazingMech2418 the fastest pi approx in a middle, esoteric or low-level language. So no python or js or lua, etc.
@Jakman I already did Forth... And APL... And LOLCODE...
@Jakman And C... And C#...
@AmazingMech2418 C is low-level. C# is middle-level.
@Jakman Yeah, but you said both... Also, try beating my C# and Forth approximations!
@AmazingMech2418 you can do it again. I bet Ill do it faster.
@Jakman My Forth one is instant...
@AmazingMech2418 no man. I mean just one language. Ill beat your Forth program any day. C# can be done.
@AmazingMech2418 it can still be done faster. Imma use some async processing.
@Jakman You won't be able to tell if it is faster though... The Forth one is too fast.
@AmazingMech2418 ill put on a stopwatch thread.
@Jakman Forth has no time module...
@AmazingMech2418 i am doing it in C# dude. The challenge was any language.
@Jakman Yes, but my Forth program can't be timed.
@AmazingMech2418 hmm. That could be an issue. How about any lang with a time module.
@Jakman Then, let's do my C# one. Though, Forth is much faster...
@AmazingMech2418 cool.
@Jakman It has to be accurate to the same number of places though...
@AmazingMech2418 I will. Now i will start.
@Jakman My submission for the challenge: https://repl.it/@AmazingMech2418/Pi-Speed-Test
@Jakman
@Jakman Native trigonometry is like using the normal pi variable... I'm honestly just waiting for you to finish now...
@AmazingMech2418 you win...
@Jakman You didn't even finish yours...
@AmazingMech2418 i did it in visual studio
@Jakman Oh. Can you upload to Repl.it so I can try it out? Also, I have the hacker plan, so I get double the speed.
@AmazingMech2418 nah man. deleted the source code after i found i lost. Sorry about that.I used the x * sin(180/x) method of pi.
@Jakman You still did pretty well. Maybe, next time, try C. :)
@AmazingMech2418 next time then. Good Game.
@Jakman Good game!
π Approximations in C
So, you might have already seen @StudentFires 's attempt at a fast and accurate π approximation in C++...
So, here are two actually fast and accurate π approximations in C:
The repl linked to this post is the most accurate and is found at https://repl.it/@AmazingMech2418/p-in-C and the other is https://repl.it/@AmazingMech2418/p-in-C-2.
The first one uses trapezoidal sums while the other uses the Nilakantha Series.
Update: The second one was updated to make it faster. It gets to 16 places very quickly.
Also i can do this real fast. Imma challenge you.
@Jakman What is the challenge?
@AmazingMech2418 the fastest pi approx in a middle, esoteric or low-level language. So no python or js or lua, etc.
@Jakman I already did Forth... And APL... And LOLCODE...
@Jakman And C... And C#...
@AmazingMech2418 C is low-level. C# is middle-level.
@Jakman Yeah, but you said both... Also, try beating my C# and Forth approximations!
@AmazingMech2418 you can do it again. I bet Ill do it faster.
@Jakman My Forth one is instant...
@AmazingMech2418 no man. I mean just one language. Ill beat your Forth program any day. C# can be done.
@AmazingMech2418 it can still be done faster. Imma use some async processing.
@Jakman You won't be able to tell if it is faster though... The Forth one is too fast.
@AmazingMech2418 ill put on a stopwatch thread.
@Jakman Forth has no time module...
@AmazingMech2418 i am doing it in C# dude. The challenge was any language.
@Jakman Yes, but my Forth program can't be timed.
@AmazingMech2418 hmm. That could be an issue. How about any lang with a time module.
@Jakman Then, let's do my C# one. Though, Forth is much faster...
@AmazingMech2418 cool.
@Jakman It has to be accurate to the same number of places though...
@AmazingMech2418 I will. Now i will start.
@Jakman My submission for the challenge: https://repl.it/@AmazingMech2418/Pi-Speed-Test
@Jakman

@Jakman Native trigonometry is like using the normal pi variable... I'm honestly just waiting for you to finish now...
@Jakman

@AmazingMech2418 you win...
@Jakman You didn't even finish yours...
@AmazingMech2418 i did it in visual studio
@Jakman Oh. Can you upload to Repl.it so I can try it out? Also, I have the hacker plan, so I get double the speed.
@AmazingMech2418 nah man. deleted the source code after i found i lost. Sorry about that.
I used the x * sin(180/x) method of pi.
@Jakman You still did pretty well. Maybe, next time, try C. :)
@AmazingMech2418 next time then. Good Game.
@Jakman Good game!