Jump to content

[VB] Calculating Infinite Pi


!Corgi

Recommended Posts

So, I've come up with a project for myself, And it seems to be a bit out of my noob VB hands...

I am trying to calculate Pi to an extremely large integer, Then being able to take that integer and calculate it with the typical radius of circles and other things.

Like a super calculator with only 1 button....

What I've come up with so far is having a few loops run inside eachother stacking the Pi integer...

But I seem to hit a error every time.

Pi = D

X = 1

Y = 1

Z = 1

A = 3

B = 0

C = D

D = 0

For i = 1 to X

A / 7 = B

B + C = D

A = A + 2

A / 7 = B

B - C = D

A = A + 2

X = X + 1

If X = >1000000000 then

Goto StopPi

Next i

StopPi

If you can understand from my code, What I'm trying to do is basically have the number (Starting from 3/7) go to 3/7 + 5/7 - 7/7 + 9/7 - 11/7 + 13/7 - 15/7 + 17/7 - 19/7 + 21/7 - 23/7 + 25/7....ect...

(If you catch on to what I'm doing here) 1 Billion times. What the math professor told me is that the more times I do this routine, The more accurate Pi is.

Halp?

Link to comment
Share on other sites

I'm not familiar with VB or it's syntax (I'm assuming that stands for Visual Basic, yes?), but why on earth does it appear that you're trying to assign a value to an expression with statements like A / 7 = B ? Shouldn't that be switched around? ( B = A / 7) Only variables can be assigned values, unless a single = tests for equivalency in VB (which I'm doubting from looking at the rest of your code).

Link to comment
Share on other sites

I'm not familiar with VB so I can't say for the syntax if it is correct,DZ will probably pop in since I think he has a working knowledge on it...but one problem I see with calculating pi is the issue of integer or float values only being able to store so many values. Even with a long integer I imagine a pi calculator would fill that space up very quickly. I'm not sure if its possible, but it would be interesting if one could create their own integer types to hold larger sets of values....but then I don't know if it will be limited by the size of registers or not...

Update:Fara is right. VB variables precede declaration and assignment, ex: variable = 965336 or variable = a + b

Of course one way around that I suppose is to write to a dynamic array. It would be fun to watch the memory get eaten up by the process if it isn't limited by the programming environment

Also, maybe I'm being stupid...but how does taking the sum of those fractions make it closer to pi? I mean 25/7 is way over the value of pi by itself

Found something that could be wrong. At the beginning where you declare and assign values, you assign value 'D' to 'C' before 'D' is declared. So either the language is loosely typed and value C is now literally 'D' of type char, or there is a syntax error trying to assign variables that don't exist yet

Link to comment
Share on other sites

If I remember well, there's still a computer processing a function that calculates pi, and it keeps giving numbers and numbers. I remember 4 years ago, I downloaded a .txt that was about 5mb big, full with PI, and I think that was only 1 million digits . Like someone already said, you won't be able to put the value in one single data type, you will need to use an array or find a way to keep getting decimals and store them in a .txt file or database, this would help in case you need to stop your program and resume it later.

On the other hand....

http://stuff.mit.edu.../pi-billion.txt

Current record is 10 trillion digits , and that was on october of the last year.

You might find more info here http://www.numberworld.org/misc_runs/pi-5t/details.html it might also help you find a better way to calculate pi.

Link to comment
Share on other sites

Current record is 10 trillion digits , and that was on october of the last year.

As I was told

3.14 ----> Normal people.

3.1415 ----> People who are good at math.

>3.1415... ----> A**-holes.

Link to comment
Share on other sites

As I was told

3.14 ----> Normal people.

3.1415 ----> People who are good at math.

>3.1415... ----> A**-holes.

Well xD, so far, only the first 40 digits are important, as we focus more in the micro level of things, I don't doubt we will find a use for 80...120...etc; digits, however, most of this crazy pi calculation madness is to break records, we won't see applications for the 1,000th+ digit anytime soon, not in our lifetimes anyways, or that's what I think.

Link to comment
Share on other sites

tumblr_lbxrvcK4pk1qbylvso1_400.png

WHY DOES THIS MAKE SENSE?!?

Update: retract that statement. I'm being real derpy today :/

Link to comment
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
×
×
  • Create New...