Jump to content

Just wondering how I would be able to do this. I've looked into how they calculate pi. One method is this(mostly just infinite series): 

 

pi^4/90 = 1/1^4 + 1/2^4 + 1/3^4 + ... + 1/n^4 

 

and just re arrange the formula for pi once you've gone to the nth term that you want to go to. 

 

I'm just confused how I would store it, surely most data types wouldn't be able to store more than something like 100 decimal places, I want to be able to calculate at least 500 places or so. Or perhaps suggest a better way of calculating it. 

CPU: Intel 3570 GPUs: Nvidia GTX 660Ti Case: Fractal design Define R4  Storage: 1TB WD Caviar Black & 240GB Hyper X 3k SSD Sound: Custom One Pros Keyboard: Ducky Shine 4 Mouse: Logitech G500

 

Link to comment
https://linustechtips.com/topic/407366-calculating-pi-with-a-c-program/
Share on other sites

Link to post
Share on other sites

Using tan-1 is pretty cool, it's not infinite:

NumberedEquation1.gif

So, in C++ (pretty sure it's the same in C#):

 π  = 16 * atan2(1.0, 5.0) - 4 * atan2(1.0, 239.0)

 

Or with the the zeta function( Inline29.gif ) if you like zeta <3:

NumberedEquation2.gif

 

Your formula is Leibniz's. 

9e804b8a1a11e442be93fed1d52205a9.png

4b325f4142cab62b1786d8be1ac3be60.png

 

 

There's also this series :

π=4-4/3+4/5-4/7+4/9-4/11+.....

i5 4670k @ 4.2GHz (Coolermaster Hyper 212 Evo); ASrock Z87 EXTREME4; 8GB Kingston HyperX Beast DDR3 RAM @ 2133MHz; Asus DirectCU GTX 560; Super Flower Golden King 550 Platinum PSU;1TB Seagate Barracuda;Corsair 200r case. 

Link to post
Share on other sites

roll your own datatype

store it as a string

use arbitrary lenght data type

why would you want to calculate AT LEAST FIVE FRIGGIN HUNDRED PLACES???

CPU: Intel i7 5820K @ 4.20 GHz | MotherboardMSI X99S SLI PLUS | RAM: Corsair LPX 16GB DDR4 @ 2666MHz | GPU: Sapphire R9 Fury (x2 CrossFire)
Storage: Samsung 950Pro 512GB // OCZ Vector150 240GB // Seagate 1TB | PSU: Seasonic 1050 Snow Silent | Case: NZXT H440 | Cooling: Nepton 240M
FireStrike // Extreme // Ultra // 8K // 16K

 

Link to post
Share on other sites

roll your own datatype

store it as a string

use arbitrary lenght data type

why would you want to calculate AT LEAST FIVE FRIGGIN HUNDRED PLACES???

Dunno well if super computers can calculate like 5 trillion or something insane, 500 didn't seem too hard. Just curious that's all, maths is just interesting and I need to get back into programming again as my course coming up in sept will use matlab so probably worth doing that. 

CPU: Intel 3570 GPUs: Nvidia GTX 660Ti Case: Fractal design Define R4  Storage: 1TB WD Caviar Black & 240GB Hyper X 3k SSD Sound: Custom One Pros Keyboard: Ducky Shine 4 Mouse: Logitech G500

 

Link to post
Share on other sites

Dunno well if super computers can calculate like 5 trillion or something insane, 500 didn't seem too hard. Just curious that's all, maths is just interesting and I need to get back into programming again as my course coming up in sept will use matlab so probably worth doing that. 

oh the meth lab is great, i did it recently, personally my favourite mission in GTA V

 

also the mathlab is quite a bit different from c# afaik

CPU: Intel i7 5820K @ 4.20 GHz | MotherboardMSI X99S SLI PLUS | RAM: Corsair LPX 16GB DDR4 @ 2666MHz | GPU: Sapphire R9 Fury (x2 CrossFire)
Storage: Samsung 950Pro 512GB // OCZ Vector150 240GB // Seagate 1TB | PSU: Seasonic 1050 Snow Silent | Case: NZXT H440 | Cooling: Nepton 240M
FireStrike // Extreme // Ultra // 8K // 16K

 

Link to post
Share on other sites

Using tan-1 is pretty cool, it's not infinite:

NumberedEquation1.gif

 

 

 

Or with the the zeta function( Inline29.gif ) if you like zeta <3:

NumberedEquation2.gif

 

Your formula is Leibniz's. 

9e804b8a1a11e442be93fed1d52205a9.png

4b325f4142cab62b1786d8be1ac3be60.png

 

 

There's also this series :

π=4-4/3+4/5-4/7+4/9-4/11+.....

 

Next time I have math homework, I'm coming to you OK?

blackshades on

 

 

Link to post
Share on other sites

Next time I have math homework, I'm coming to you OK?

As long as it's not something I haven't studied yet, ok.

i5 4670k @ 4.2GHz (Coolermaster Hyper 212 Evo); ASrock Z87 EXTREME4; 8GB Kingston HyperX Beast DDR3 RAM @ 2133MHz; Asus DirectCU GTX 560; Super Flower Golden King 550 Platinum PSU;1TB Seagate Barracuda;Corsair 200r case. 

Link to post
Share on other sites

C#/.NET in general is not a good choice, it's far too slow. This sort of thing should be done natively, at the lowest level possible. I'd be inclined to play with C++ AMP/CUDA for this.

The single biggest problem in communication is the illusion that it has taken place.

Link to post
Share on other sites

C#/.NET in general is not a good choice, it's far too slow. This sort of thing should be done natively, at the lowest level possible. I'd be inclined to play with C++ AMP/CUDA for this.

I've not had any experience with those and I would feel so stupid trying to do it... Can I do CUDA stuff with a 660ti? I would assume so. Is C++ that much different from c#? Also what software/ide would  I need just like notepad ++ or does visual studio work  ?

CPU: Intel 3570 GPUs: Nvidia GTX 660Ti Case: Fractal design Define R4  Storage: 1TB WD Caviar Black & 240GB Hyper X 3k SSD Sound: Custom One Pros Keyboard: Ducky Shine 4 Mouse: Logitech G500

 

Link to post
Share on other sites

I've not had any experience with those and I would feel so stupid trying to do it... Can I do CUDA stuff with a 660ti? I would assume so. Is C++ that much different from c#? Also what software/ide would  I need just like notepad ++ or does visual studio work  ?

 

Hell yes you can. Yes C++ is a different animal to C#; evolved for a different problem domain. That said their evolution is becoming somewhat convergent in places given the recent decade with C++ 11 and the upcoming 14.

 

Quintessentially in this context it's speed: .NET utilizes JIT, C++ doesn't and applying GPU parallelism yields lot's of cores to crunch the problem with...

The single biggest problem in communication is the illusion that it has taken place.

Link to post
Share on other sites

Hell yes you can. Yes C++ is a different animal to C#; evolved for a different problem domain. That said their evolution is becoming somewhat convergent in places given the recent decade with C++ 11 and the upcoming 14.

 

Quintessentially in this context it's speed: .NET utilizes JIT, C++ doesn't and applying GPU parallelism yields lot's of cores to crunch the problem with...

Thanks for the info, I will try and do it, probably get nowhere tho.... 

CPU: Intel 3570 GPUs: Nvidia GTX 660Ti Case: Fractal design Define R4  Storage: 1TB WD Caviar Black & 240GB Hyper X 3k SSD Sound: Custom One Pros Keyboard: Ducky Shine 4 Mouse: Logitech G500

 

Link to post
Share on other sites

Thanks for the info, I will try and do it, probably get nowhere tho.... 

 

At the very least a little exploration of C/C++ would be very useful.

The single biggest problem in communication is the illusion that it has taken place.

Link to post
Share on other sites

At the very least a little exploration of C/C++ would be very useful.

Well afaik unreal engine uses it too which I want to mess with a bit, programming can be really enjoyable but sometimes I hate it with a passion, don't know perhaps it's not for me. 

CPU: Intel 3570 GPUs: Nvidia GTX 660Ti Case: Fractal design Define R4  Storage: 1TB WD Caviar Black & 240GB Hyper X 3k SSD Sound: Custom One Pros Keyboard: Ducky Shine 4 Mouse: Logitech G500

 

Link to post
Share on other sites

Well afaik unreal engine uses it too which I want to mess with a bit, programming can be really enjoyable but sometimes I hate it with a passion, don't know perhaps it's not for me. 

 

I would say that it's perfectly normal to feel that way about it. I too both hate it and love it at times and so does just about everyone I know/have known in the industry.

 

Perhaps take it as a positive sign that you're able to feel such strong polar feelings about it.

The single biggest problem in communication is the illusion that it has taken place.

Link to post
Share on other sites

If you don't roll your own data type, you'll need some kind of big number library, e.g. https://gmplib.org/.

 

Coding your own big number library would be a pretty fun and educational project, though. The basic strategy is that you will store the values of the number in a contiguous byte array, but provide an interface to that array in the form of operations (functions) that implement the arithmetic. Your operations would need to iterate over the array, making sure to carry properly and avoid values that exceed the size of the native data types.

 

I recommend doing this in C, but an object oriented C++ approach could work. Worry about getting fancy with CUDA, etc. once you have a working solution.

Link to post
Share on other sites

you want your pc lose its mind? because that how you loose your mind.

 

just use math.pi or something

"You know it'll clock down as soon as it hits 40°C, right?" - "Yeah ... but it doesnt hit 40°C ... ever  😄"

 

GPU: MSI GTX1080 Ti Aero @ 2 GHz (watercooled) CPU: Ryzen 5600X (watercooled) RAM: 32GB 3600Mhz Corsair LPX MB: Gigabyte B550i PSU: Corsair SF750 Case: Hyte Revolt 3

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×