Jump to content

How high can you compute pi?

Nallown

Main reason for it slowing down over time is because the file size of output.pi increases over time it means that it takes longer to read the file holding the previous computed pi and add the next digit to it. Imagine this, reading a sentence is quicker to do so then reading a paragraph and since it needs to read over again to add the next character it would slow down over time.

Yup. Figured as much. Guessing the physical limit will be reached from lack of storage space (final output file was 100KB on my /home partition, total of 86GB or so). However many digits that works out to, assuming the computer doesn't crash before then. 

Interested in Linux, SteamOS and Open-source applications? Go here

Gaming Rig - CPU: i5 3570k @ Stock | GPU: EVGA Geforce 560Ti 448 Core Classified Ultra | RAM: Mushkin Enhanced Blackline 8GB DDR3 1600 | SSD: Crucial M4 128GB | HDD: 3TB Seagate Barracuda, 1TB WD Caviar Black, 1TB Seagate Barracuda | Case: Antec Lanboy Air | KB: Corsair Vengeance K70 Cherry MX Blue | Mouse: Corsair Vengeance M95 | Headset: Steelseries Siberia V2

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

I am total programming noob. How do I use? :P

what program do i use to run it?

 

 

i'll run it overnight tonight if you reply with how to, until around 6PM tomorrow.

I am a programmer and never did java just so I also don't know how to open it :P

use eclipse to open this program!

20,000 decimals and counting ... 

38,000+ in 4 minutes

51,000+ in 8-9 minutes

 

This will probably take a while. Running on my laptop with Arch Linux (i5 3320M, 12GB of RAM, 120GB SSD). CPU usage at 34%. 

thanks lol i leave it running for a while

btw its like 270MB of my ram which really isnt lightweit xD

but now it keeps going smaller and smaller.... wtf

You can bundle jar files as windows executables, the minecraft launcher uses this feature.

 

Additionally.. running it under linux, lets see how it performs on my rig.

 

Updated it and should be a little quicker now https://mega.co.nz/#!h58DxS5A!9xm1WKe_v0XSdAJUm1zhE0jfKrUrtiYBKU8hDsoXEj0 or check the source I updated that aswell, still not computing at a solid speed though since it still needs to add the next digit on top of the previous full computed pi so lets say it computes 1000 digits then to output it into the file it would need to read all the 999 digits from the file and add the 1000th digit on top

Link to comment
Share on other sites

Link to post
Share on other sites

I already forgot I had it running. Already to 120,000 decimals :P

updated version should compute 1.25 x quicker

Link to comment
Share on other sites

Link to post
Share on other sites

do you know any python? and btw what method did u use to calculate pi? is it Chudnovsky's?

I don't like touching python because it's a bit messy and it uses the spigot algorithm

Link to comment
Share on other sites

Link to post
Share on other sites

updated version should compute 1.25 x quicker

Will it continue from where v1.0 left of?

Link to comment
Share on other sites

Link to post
Share on other sites

Perhaps you should have written this in an interpreted language so people don't need to compile but could run a script that they could view the contents of.

Comb it with a brick

Link to comment
Share on other sites

Link to post
Share on other sites

Perhaps you should have written this in an interpreted language so people don't need to compile but could run a script that they could view the contents of.

he did. look in the thread or even the bottom of the main post

Link to comment
Share on other sites

Link to post
Share on other sites

Updated it and should be a little quicker now https://mega.co.nz/#!h58DxS5A!9xm1WKe_v0XSdAJUm1zhE0jfKrUrtiYBKU8hDsoXEj0 or check the source I updated that aswell, still not computing at a solid speed though since it still needs to add the next digit on top of the previous full computed pi so lets say it computes 1000 digits then to output it into the file it would need to read all the 999 digits from the file and add the 1000th digit on top

 

Remove the console print and rely on the user reading the file, make the file only write to every ~100 places, then get it to print the final value (and write out to file) when the user decides to stop. This will reduce a lot of the time waiting for the write sequences to return.

 

Main reason for it slowing down over time is because the file size of output.pi increases over time it means that it takes longer to read the file holding the previous computed pi and add the next digit to it. Imagine this, reading a sentence is quicker to do so then reading a paragraph and since it needs to read over again to add the next character it would slow down over time.

Actually from analysing the code, this isn't the case, the system you are using to write to the file is appending its output into the file, it doesn't ever read in the entire file and write it out, the program would slow down very quickly doing that. The reason it slows down is because the number is growing in size very rapidly. The bigint type you are using actually more closely resembles an int array (int[]), the slow down is parsing this array every time the program loops.

Arch Linux on Samsung 840 EVO 120GB: Startup finished in 1.334s (kernel) + 224ms (userspace) = 1.559s | U mad windoze..?

Link to comment
Share on other sites

Link to post
Share on other sites

@Nallown I NEED HALP!

I closed it down, and now I can't re-open. I shift-right click, and this is what I get:

BFvr9lC.png

 

 

 

Wait... I fixed it :D

Link to comment
Share on other sites

Link to post
Share on other sites

he did. look in the thread or even the bottom of the main post

No it's a compiled program, written in java hence the ".jar".

Comb it with a brick

Link to comment
Share on other sites

Link to post
Share on other sites

No it's a compiled program, written in java hence the ".jar".

actually its a script writtin in java. wouldnt call it a program considering there is no UI except when u run it in cmd

Link to comment
Share on other sites

Link to post
Share on other sites

actually its a script writtin in java. wouldnt call it a program considering there is no UI except when u run it in cmd

Java is not a scripting language. 

 

I so is a C program that moves a file from 1 location to another without any output and is invoked in the terminal a program or a script?

Its a program, you can't see its source code from the binary.

 

A javascript script that does the same thing can be called a script and a program.

 

There are also scripting languages that can built UI elements. 

Arch Linux on Samsung 840 EVO 120GB: Startup finished in 1.334s (kernel) + 224ms (userspace) = 1.559s | U mad windoze..?

Link to comment
Share on other sites

Link to post
Share on other sites

Hey guys I just created this Java code which computes pi up to unlimited digits and I thought, lets put this to the test and find it's limit.

So basically the idea is to see how high your computer can compute pi, I tried keeping the source as light weight as possible and since I created it on a old crappy laptop while I was on the train this should mean that anyone can run it with no issues.

 

So here's the source and have fun with it :)

import java.io.File;import java.io.FileWriter;import java.io.IOException;import java.io.PrintWriter;import java.math.BigInteger; public class ComputePi {	final static BigInteger two = BigInteger.valueOf(2);	final static BigInteger three = BigInteger.valueOf(3);	final static BigInteger four = BigInteger.valueOf(4);	final static BigInteger seven = BigInteger.valueOf(7); 	static BigInteger q = BigInteger.ONE;	static BigInteger r = BigInteger.ZERO;	static BigInteger t = BigInteger.ONE;	static BigInteger k = BigInteger.ONE;	static BigInteger n = BigInteger.valueOf(3);	static BigInteger l = BigInteger.valueOf(3);	static PrintWriter out; 	public static void main(String[] args) {		BigInteger nn, nr;		boolean first = true;		int decimals = 0;				try {			out = new PrintWriter(System.getProperty("user.home")+"/out.pi");						while(true){				if(four.multiply(q).add(r).subtract(t).compareTo(n.multiply(t)) == -1){					out.print(n);					if(first){out.print("."); first = false;}					nr = BigInteger.TEN.multiply(r.subtract(n.multiply(t)));					n = BigInteger.TEN.multiply(three.multiply(q).add(r)).divide(t).subtract(BigInteger.TEN.multiply(n));					q = q.multiply(BigInteger.TEN);					r = nr;					out.flush();					decimals++;					System.out.println((decimals-1)+", Decimals Computed");				}else{					nr = two.multiply(q).add(r).multiply(l);					nn = q.multiply((seven.multiply(k))).add(two).add(r.multiply(l)).divide(t.multiply(l));					q = q.multiply(k);					t = t.multiply(l);					l = l.add(two);					k = k.add(BigInteger.ONE);					n = nn;					r = nr;				}			}		}catch (IOException e) {			e.printStackTrace();		}finally{			out.close();		}	}	} 

The final results of pi computed is outputted in your user folder (c:\users\your user), people running linux would know where their final outputted file would be found.

Keep in mind that the console mentions how many decimal places it has found but the final outputted file has all digits from 3.1 to the final computed digit.

 

file is called output.pi and also the results found inside of it are computed in realtime. So in theory you can use watch in linux to watch it change in realtime and also if your computer crashes then the final results should show your pc's limits since before continuing on to the next digit it would output it into the file.

 

Don't forget to post your final results and how long you've been running it for ;)

 

 

Edit: Added instructions and java file for people who don't know how to program 

 
 

!Important read if you don't know how to program or got no programming experience!

 

To run follow these steps otherwise it'll be running invisibly in the background which is no issue because it only uses 8mb ram but still

  1. Download this file
  2. Shift right click the folder (or desktop) where you saved the file
  3. Choose " Open command window here "
  4. type in " java -jar computePi.jar "
  5. And go!!!!

If you accidentally double click it then just force close java through task manager when you want to close it or otherwise if you run it with my instructions then simply close the command window

not working for me. i keep getting this http://gyazo.com/0ccc4e421343d121a843860ba15763c5

PC Specs

Intel i5 4670k 4.2ghz @1.20v | Cooler Master 212 Plus | Asus z87-A | Fractal Design Define R4 |Hitachi 1TB 7200rpm HDD | 2x Samsung 840 EVO | Seasonic 520w m12II | Crucial Ballistix Sport 8gb DDR3 1600mhz | PowerColor 7870 GHz edition | Razer Blackwidow Ultimate 2013 | NZXT Hue RGB Controller
Link to comment
Share on other sites

Link to post
Share on other sites

not working for me. i keep getting this http://gyazo.com/0ccc4e421343d121a843860ba15763c5

You have to have Java installed (http://www.oracle.com/technetwork/java/javase/downloads/jre7-downloads-1880261.html) and either set its location in your PATH or use the full file location to java.exe usually C:\Program Files\Java\jre7\bin\java.exe

1474412270.2748842

Link to comment
Share on other sites

Link to post
Share on other sites

Remove the console print and rely on the user reading the file, make the file only write to every ~100 places, then get it to print the final value (and write out to file) when the user decides to stop. This will reduce a lot of the time waiting for the write sequences to return.

 

Actually from analysing the code, this isn't the case, the system you are using to write to the file is appending its output into the file, it doesn't ever read in the entire file and write it out, the program would slow down very quickly doing that. The reason it slows down is because the number is growing in size very rapidly. The bigint type you are using actually more closely resembles an int array (int[]), the slow down is parsing this array every time the program loops.

Would do so and if you really want that then feel free to do so yourself ;) The only reason I added the console update was because otherwise people would believe that it would of not worked

Link to comment
Share on other sites

Link to post
Share on other sites

Will it continue from where v1.0 left of?

No, it can't continue on since it doesn't know what sequence it has stopped at and I don't want to make it to complicated so I leave it like this

Link to comment
Share on other sites

Link to post
Share on other sites

@Nallown I NEED HALP!

I closed it down, and now I can't re-open. I shift-right click, and this is what I get:

BFvr9lC.png

 

 

 

Wait... I fixed it :D

how did you fix it? im getting the same thing 

PC Specs

Intel i5 4670k 4.2ghz @1.20v | Cooler Master 212 Plus | Asus z87-A | Fractal Design Define R4 |Hitachi 1TB 7200rpm HDD | 2x Samsung 840 EVO | Seasonic 520w m12II | Crucial Ballistix Sport 8gb DDR3 1600mhz | PowerColor 7870 GHz edition | Razer Blackwidow Ultimate 2013 | NZXT Hue RGB Controller
Link to comment
Share on other sites

Link to post
Share on other sites

nvm i got it working. 20 seconds and 20k decimals 

PC Specs

Intel i5 4670k 4.2ghz @1.20v | Cooler Master 212 Plus | Asus z87-A | Fractal Design Define R4 |Hitachi 1TB 7200rpm HDD | 2x Samsung 840 EVO | Seasonic 520w m12II | Crucial Ballistix Sport 8gb DDR3 1600mhz | PowerColor 7870 GHz edition | Razer Blackwidow Ultimate 2013 | NZXT Hue RGB Controller
Link to comment
Share on other sites

Link to post
Share on other sites

how did you fix it? im getting the same thing 

Don't right click the file but right click the folder instead and make sure you "Shift + right click"

Link to comment
Share on other sites

Link to post
Share on other sites

Would do so and if you really want that then feel free to do so yourself ;) The only reason I added the console update was because otherwise people would believe that it would of not worked

I don't have JDK installed, and im not willing to go through the hassle of learning how javac works.

Arch Linux on Samsung 840 EVO 120GB: Startup finished in 1.334s (kernel) + 224ms (userspace) = 1.559s | U mad windoze..?

Link to comment
Share on other sites

Link to post
Share on other sites

I'm about a minute and abit in, 15k decimal places.

 

Anyway you can edit it and add multi threaded support, it's only using 8% of my CPU.

 

3 minutes in, 26k places.

15" MBP TB

AMD 5800X | Gigabyte Aorus Master | EVGA 2060 KO Ultra | Define 7 || Blade Server: Intel 3570k | GD65 | Corsair C70 | 13TB

Link to comment
Share on other sites

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

×