Author Topic: [JAVA] Calculate Pi!  (Read 19246 times)

0 Members and 1 Guest are viewing this topic.

Offline Joe

  • B&
  • Moderator
  • Hero Member
  • *****
  • Posts: 10319
  • In Soviet Russia, text read you!
    • View Profile
    • Github
[JAVA] Calculate Pi!
« on: November 08, 2005, 10:10:27 pm »
Yes! A very advanced mathematical..tool?

This is the brainchild of five straight hours of pondering the problem, resulting in 5 hours of detention to be served starting tomorrow, for insubordination when teachers told me to get to work.

public class CalculatePi {
  public static void main(String args[]) {
    System.out.println("Pi: " + 4 * Math.atan(1));
  }
}


I also managed to port it to Visual Basic after another three hours of work, mostly debugging.
Public Sub Main
    Call MsgBox(4 * Atan(1))
End Sub


You may use this in your programs for a royalty of 50cents per copy sold.
I'd personally do as Joe suggests

You might be right about that, Joe.


Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: [JAVA] Calculate Pi!
« Reply #1 on: November 08, 2005, 10:25:51 pm »
Wow, your teachers suck. -_-

Offline Newby

  • Moderator
  • Hero Member
  • *****
  • Posts: 10877
  • Thrash!
    • View Profile
Re: [JAVA] Calculate Pi!
« Reply #2 on: November 08, 2005, 10:26:12 pm »
How about pi?

Or (22 / 7) (isn't that supposed to be pi?)
- Newby
http://www.x86labs.org

Quote
[17:32:45] * xar sets mode: -oooooooooo algorithm ban chris cipher newby stdio TehUser tnarongi|away vursed warz
[17:32:54] * xar sets mode: +o newby
[17:32:58] <xar> new rule
[17:33:02] <xar> me and newby rule all

I'd bet that you're currently bloated like a water ballon on a hot summer's day.

That analogy doesn't even make sense.  Why would a water balloon be especially bloated on a hot summer's day? For your sake, I hope there wasn't too much logic testing on your LSAT. 

Offline Joe

  • B&
  • Moderator
  • Hero Member
  • *****
  • Posts: 10319
  • In Soviet Russia, text read you!
    • View Profile
    • Github
Re: [JAVA] Calculate Pi!
« Reply #3 on: November 08, 2005, 10:35:00 pm »
Wow, your teachers suck. -_-

We didn't learn that in school son.

Newby, I doubt it. Just a sec..

EDIT -
No, but its close. 22/7=3.1428571
I'd personally do as Joe suggests

You might be right about that, Joe.


Offline deadly7

  • 42
  • x86
  • Hero Member
  • *****
  • Posts: 6496
    • View Profile
Re: [JAVA] Calculate Pi!
« Reply #4 on: November 08, 2005, 10:35:51 pm »
How about pi?

Or (22 / 7) (isn't that supposed to be pi?)
I think it is.
Pi = the world's gayest number.
[17:42:21.609] <Ergot> Kutsuju you're girlfrieds pussy must be a 403 error for you
 [17:42:25.585] <Ergot> FORBIDDEN

on IRC playing T&T++
<iago> He is unarmed
<Hitmen> he has no arms?!

on AIM with a drunk mythix:
(00:50:05) Mythix: Deadly
(00:50:11) Mythix: I'm going to fuck that red dot out of your head.
(00:50:15) Mythix: with my nine

Offline Joe

  • B&
  • Moderator
  • Hero Member
  • *****
  • Posts: 10319
  • In Soviet Russia, text read you!
    • View Profile
    • Github
Re: [JAVA] Calculate Pi!
« Reply #5 on: November 08, 2005, 10:39:40 pm »
22/7 is 3.1428571. Pi is 3.141592 something.

EDIT -
deadly, actually, that would be infinity (the gayest number). At least you can add/subtract/multiply/divide something by pi and get something not pi.

Also, pi is not only a number, but the 16th letter in the greek alphabet.



STUPID -
Hm, are they going to start with hurricane gamma next year? I can just see it now "Hurricane Pi is coming!"
« Last Edit: November 08, 2005, 10:44:16 pm by Joe[e2] »
I'd personally do as Joe suggests

You might be right about that, Joe.


Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: [JAVA] Calculate Pi!
« Reply #6 on: November 08, 2005, 10:51:34 pm »
How about pi?

Or (22 / 7) (isn't that supposed to be pi?)
I think it is.
Pi = the world's gayest number.

No, it's not.  It's moderately close, but using a Pi constant on calculators is a lot more accurate than using 22/7.

Offline Joe

  • B&
  • Moderator
  • Hero Member
  • *****
  • Posts: 10319
  • In Soviet Russia, text read you!
    • View Profile
    • Github
Re: [JAVA] Calculate Pi!
« Reply #7 on: November 08, 2005, 11:12:32 pm »
How about pi?

Or (22 / 7) (isn't that supposed to be pi?)
I think it is.
Pi = the world's gayest number.

No, it's not. It's moderately close, but using a Pi constant on calculators is a lot more accurate than using 22/7.

Anyone here work at TI and know how that's done? I figure its probably 4*ATan(1) rounded to the nearest millionth or something.
I'd personally do as Joe suggests

You might be right about that, Joe.


Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: [JAVA] Calculate Pi!
« Reply #8 on: November 09, 2005, 12:06:01 am »
Anyone here work at TI and know how that's done? I figure its probably 4*ATan(1) rounded to the nearest millionth or something.

How what's done?  Calculating Pi?  There's a stored constant for Pi in all TI model's I've ever used.  Calculating it is pretty dumb.  Plus, all TI model's I've seen round to the nearest 10th digit (or at least that's what I understand).

trust

  • Guest
Re: [JAVA] Calculate Pi!
« Reply #9 on: November 09, 2005, 06:20:14 am »
infinity isn't a number.

I've debated it with my math teacher and that's what she says.

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: [JAVA] Calculate Pi!
« Reply #10 on: November 09, 2005, 08:34:39 am »
Infinity isn't a number.  But, then, neither is 0, so eh?

And by the way, taking the atan of 1 isn't calculating Pi, since the forumla for arctan uses Pi.  It's like "calculating" the constant C in a=bC by setting b to 1.  You aren't calculating anything.  The best way to calculate Pi in Java is Math.PI, I believe.

To actually calculate Pi, it's an infinite formula.  You can keep going and it gets more and more accurate the longer you iterate, until you run out of room in your variable (unless you're using java.Math.BigDecimal, then you can go forever). 

I believe this is it:

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: [JAVA] Calculate Pi!
« Reply #11 on: November 09, 2005, 10:25:19 am »
What is that, the sequence of squares over odd numbers (roughly)?
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: [JAVA] Calculate Pi!
« Reply #12 on: November 09, 2005, 05:42:08 pm »
Yeah, that sounds right.  It looks pretty recursive, and the deeper you go the more accurate you get.  Of course, on computess, double's are only see accurate in the first place, so..

Offline d&q

  • Hero Member
  • *****
  • Posts: 1427
  • I'm here.
    • View Profile
    • Site
Re: [JAVA] Calculate Pi!
« Reply #13 on: November 09, 2005, 06:15:51 pm »
Infinity isn't a number, its a concept.

I've used this formula for Pi since 'round sixth grade:

The writ of the founders must endure.

Offline Quik

  • Webmaster Guy
  • x86
  • Hero Member
  • *****
  • Posts: 3262
  • \x51 \x75 \x69 \x6B \x5B \x78 \x38 \x36 \x5D
    • View Profile
Re: [JAVA] Calculate Pi!
« Reply #14 on: November 09, 2005, 06:32:22 pm »
If infinity isn't a number, is e? I recently had a conversation with my math teacher about "the number e" (Euler's number)
Quote
[20:21:13] xar: i was just thinking about the time iago came over here and we made this huge bomb and light up the sky for 6 min
[20:21:15] xar: that was funny

Offline Newby

  • Moderator
  • Hero Member
  • *****
  • Posts: 10877
  • Thrash!
    • View Profile
Re: [JAVA] Calculate Pi!
« Reply #15 on: November 09, 2005, 07:21:06 pm »
If infinity isn't a number, is e? I recently had a conversation with my math teacher about "the number e" (Euler's number)

e isn't infinite. It comes really close, seeing as how it's a constant.
- Newby
http://www.x86labs.org

Quote
[17:32:45] * xar sets mode: -oooooooooo algorithm ban chris cipher newby stdio TehUser tnarongi|away vursed warz
[17:32:54] * xar sets mode: +o newby
[17:32:58] <xar> new rule
[17:33:02] <xar> me and newby rule all

I'd bet that you're currently bloated like a water ballon on a hot summer's day.

That analogy doesn't even make sense.  Why would a water balloon be especially bloated on a hot summer's day? For your sake, I hope there wasn't too much logic testing on your LSAT. 

Offline Quik

  • Webmaster Guy
  • x86
  • Hero Member
  • *****
  • Posts: 3262
  • \x51 \x75 \x69 \x6B \x5B \x78 \x38 \x36 \x5D
    • View Profile
Re: [JAVA] Calculate Pi!
« Reply #16 on: November 09, 2005, 07:25:31 pm »
If infinity isn't a number, is e? I recently had a conversation with my math teacher about "the number e" (Euler's number)

e isn't infinite. It comes really close, seeing as how it's a constant.

I know it's not infinte, it's irrational. (1 + 1/n)^n as n -> infinity

The question is, do you consider "e" to be a number? I believe it is, just an irrational one.
Quote
[20:21:13] xar: i was just thinking about the time iago came over here and we made this huge bomb and light up the sky for 6 min
[20:21:15] xar: that was funny

Offline Ender

  • x86
  • Hero Member
  • *****
  • Posts: 2390
    • View Profile
Re: [JAVA] Calculate Pi!
« Reply #17 on: November 09, 2005, 08:11:01 pm »
How about pi?

Or (22 / 7) (isn't that supposed to be pi?)

Pi is an irrational number, meaning that it can't be expressed as int / int.
The question is, do you consider "e" to be a number? I believe it is, just an irrational one.

Of course it is. We say the word number when we refer to "real numbers." And irrational numbers are a subset of real numbers.

Infinity isn't a number simply because we can't put numbers to it. It's a concept that helps us understand things. e is used in calculations, however. It's paramount in calculus. Why? Derivative of ln x = 1/x.

Offline d&q

  • Hero Member
  • *****
  • Posts: 1427
  • I'm here.
    • View Profile
    • Site
Re: [JAVA] Calculate Pi!
« Reply #18 on: November 09, 2005, 08:15:40 pm »
Yes, because it can be expressed as an irrational number.

[Edit]: Whoops, didn't see Ender's post.

[Edit #2]: Actually, sometimes I refer to imaginary numbers as "a number". By imaginary, I mean a complex number with a coefficient of i.
« Last Edit: November 09, 2005, 08:17:52 pm by Deuce »
The writ of the founders must endure.

Offline Quik

  • Webmaster Guy
  • x86
  • Hero Member
  • *****
  • Posts: 3262
  • \x51 \x75 \x69 \x6B \x5B \x78 \x38 \x36 \x5D
    • View Profile
Re: [JAVA] Calculate Pi!
« Reply #19 on: November 09, 2005, 08:35:43 pm »
Of course it is. We say the word number when we refer to "real numbers." And irrational numbers are a subset of real numbers.

This is my point. Usually, people refer to it as a letter.
Quote
[20:21:13] xar: i was just thinking about the time iago came over here and we made this huge bomb and light up the sky for 6 min
[20:21:15] xar: that was funny

Offline d&q

  • Hero Member
  • *****
  • Posts: 1427
  • I'm here.
    • View Profile
    • Site
Re: [JAVA] Calculate Pi!
« Reply #20 on: November 09, 2005, 09:21:12 pm »
But it can be expressed as an irrational number, which is what I think counts. I also view i as a number, because it can be defined as the square root of -1.
The writ of the founders must endure.

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: [JAVA] Calculate Pi!
« Reply #21 on: November 09, 2005, 09:49:52 pm »
If infinity isn't a number, is e? I recently had a conversation with my math teacher about "the number e" (Euler's number)

Yes, it's just as much of a constant as Pi is. :P

You can round Pi and e; you can't round infinite.

Offline Joe

  • B&
  • Moderator
  • Hero Member
  • *****
  • Posts: 10319
  • In Soviet Russia, text read you!
    • View Profile
    • Github
Re: [JAVA] Calculate Pi!
« Reply #22 on: November 09, 2005, 10:03:35 pm »
rounded to the nearest tenth is

Joe > Sidoh.

EDIT -
Nice, google </3 hotlinkers.
I'd personally do as Joe suggests

You might be right about that, Joe.


Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: [JAVA] Calculate Pi!
« Reply #23 on: November 09, 2005, 10:07:48 pm »
rounded to the nearest tenth is

Joe > Sidoh.

EDIT -
Nice, google </3 hotlinkers.

That's not rounding.  It's like symbolizing a universe with a dot.  Don't be an idiot, Joe.  I guess that kind of is asking a lot of you though, isn't it? :P

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: [JAVA] Calculate Pi!
« Reply #24 on: November 09, 2005, 10:18:12 pm »
If infinity isn't a number, is e? I recently had a conversation with my math teacher about "the number e" (Euler's number)

Yes.  e is a constant, infinity is not; for example, you could have one infinity larger than another.  Suppose:
sum[i = 0 to infinity] i / i2 + 1.  Obviously i summed from 0 to infinity would be infinity, but the denominator's infinity is larger, and so we call the series convergent.
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: [JAVA] Calculate Pi!
« Reply #25 on: November 09, 2005, 11:28:10 pm »
In case there's some question about whether i is a number:
- We know that x + 1 = 0 is a valid equation; however, if we only had regular "counting" numbers available, we couldn't solve it.  We would have to invent a concept of negative numbers, which we are all comfortable with .
- Then we have the equation x2 + 1 = 0.  It also had no solution without inventing the concept of imaginary numbers.
--> Imaginary numbers are negative numbers are both pretty abstract.  We can't see or touch either, but they seem to be numbers in a purely mathematical sense. 

Ok, so the next question is, is 0 a number?  It seems that 0 is just a placeholder.  Doesn't "0" represent the lack of a number, not an actual number?

If 0 is a number, is it even or odd?  What is the definition of even and odd that shows that 0 is even? Can it be shown that 0 also fits into the odd category?

Is the 0 in 2304 the same as the number 0?  How are they related?

What is x in 2x = 6? Is it a number?  It doesn't look like a number, but to anybody with more than a few years of math experience, it's immediately obvious that it's 3.  If x can be considered a number, is it possible that our definition of numbers isn't as clear as we think?

What about x in 0x = 6? Is x still a number?  Any number, real, rational, irrational, imaginary, etc. can be place in front of the x.  But when the number 0 is, x no longer has a value.  It seems like 0 isn't behaving as a number here. 

Or, is there a case for considering 1/0 to be a number?  Is the result infinite or undefined? Why? Is there a case for looking at it either way? 

I think this is the most important question of all:
How are 0 and infinite related?  Think about how to get the result of infinite in a finite equation.  The only way to get it is to use a 0.  This means that 0 and infinite are related, and that infinite can be derived from 0.  Because, as it was already discussed here, infinite isn't a number, does that show that 0 isn't either? 


By the way, most of these questions were inspired by or ripped from a variety of sources.  I post them here to provoke discussion, and maybe we'll all learn something. :)

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: [JAVA] Calculate Pi!
« Reply #26 on: November 10, 2005, 01:30:25 am »
In case there's some question about whether i is a number:
- We know that x + 1 = 0 is a valid equation; however, if we only had regular "counting" numbers available, we couldn't solve it.  We would have to invent a concept of negative numbers, which we are all comfortable with .
- Then we have the equation x2 + 1 = 0.  It also had no solution without inventing the concept of imaginary numbers.
--> Imaginary numbers are negative numbers are both pretty abstract.  We can't see or touch either, but they seem to be numbers in a purely mathematical sense. 

Ok, so the next question is, is 0 a number?  It seems that 0 is just a placeholder.  Doesn't "0" represent the lack of a number, not an actual number?

If 0 is a number, is it even or odd?  What is the definition of even and odd that shows that 0 is even? Can it be shown that 0 also fits into the odd category?

Is the 0 in 2304 the same as the number 0?  How are they related?

What is x in 2x = 6? Is it a number?  It doesn't look like a number, but to anybody with more than a few years of math experience, it's immediately obvious that it's 3.  If x can be considered a number, is it possible that our definition of numbers isn't as clear as we think?

What about x in 0x = 6? Is x still a number?  Any number, real, rational, irrational, imaginary, etc. can be place in front of the x.  But when the number 0 is, x no longer has a value.  It seems like 0 isn't behaving as a number here. 

Or, is there a case for considering 1/0 to be a number?  Is the result infinite or undefined? Why? Is there a case for looking at it either way? 

I think this is the most important question of all:
How are 0 and infinite related?  Think about how to get the result of infinite in a finite equation.  The only way to get it is to use a 0.  This means that 0 and infinite are related, and that infinite can be derived from 0.  Because, as it was already discussed here, infinite isn't a number, does that show that 0 isn't either? 


By the way, most of these questions were inspired by or ripped from a variety of sources.  I post them here to provoke discussion, and maybe we'll all learn something. :)

Those are some pretty interesting points.

  It's funny how life is.  I used to hate math--it was my least favorite subject.  Just this year, I really started enjoying it.  It probably started when I showed some respect for the potential it had to do anything any other "tool" humans have.

Offline d&q

  • Hero Member
  • *****
  • Posts: 1427
  • I'm here.
    • View Profile
    • Site
Re: [JAVA] Calculate Pi!
« Reply #27 on: November 10, 2005, 04:31:17 pm »
In case there's some question about whether i is a number:
- We know that x + 1 = 0 is a valid equation; however, if we only had regular "counting" numbers available, we couldn't solve it.  We would have to invent a concept of negative numbers, which we are all comfortable with .
- Then we have the equation x2 + 1 = 0.  It also had no solution without inventing the concept of imaginary numbers.
--> Imaginary numbers are negative numbers are both pretty abstract.  We can't see or touch either, but they seem to be numbers in a purely mathematical sense. 

My argument for both infinity and i is their placement in the number system.

Number System:

All  Numbers-
      Imaginary Numbers- Numbers using the quantity i[/i(Complex Numbers). i defined as being the square root of -1.
      Real Numbers- A number that can be expressed on a number line.
           Irrational Numbers- A number that cannot be written as a result of the calculation: a/b.
           Rational Numbers- Can be written as a result of the calculation: a/b. This includes repeating decimals, such as 5/7 or 1/3.
                Integer- A number that is in the set of Natural numbers, 0, and the negatives of the natural numbers.
                    Whole Number- A number is in the set of Natural numbers, and 0.
                    Natural Number- A number in the set [1, 2, 3, 4, ...]

This is by no means the entire set of numbers, just what I think of when I thinking about what a particular value is. Since i fits, it's a number, and since ∞ does not, it is not a number.
               
Ok, so the next question is, is 0 a number?  It seems that 0 is just a placeholder.  Doesn't "0" represent the lack of a number, not an actual number?

I agree that zero is a lack of a number, but for practical uses, we have to regard it as a whole number.

If 0 is a number, is it even or odd?  What is the definition of even and odd that shows that 0 is even? Can it be shown that 0 also fits into the odd category?

An even number is a number that can be expressed as (2*x). Seeing that 2*0=0, 0 is even.


Is the 0 in 2304 the same as the number 0?  How are they related?

The 0 in 2304, means that in base 10, the second place, which is 10^1, has no value. 0 used in that text means that in whatever place it is, regardless of base, it means that that particular place has no value.


What is x in 2x = 6? Is it a number?  It doesn't look like a number, but to anybody with more than a few years of math experience, it's immediately obvious that it's 3.  If x can be considered a number, is it possible that our definition of numbers isn't as clear as we think?

x in 2x=6 is a variable. It is a symbol used to represent a quantity. In this case however, the hidden value "x", is 3. Which is a number.


What about x in 0x = 6? Is x still a number?  Any number, real, rational, irrational, imaginary, etc. can be place in front of the x.  But when the number 0 is, x no longer has a value.  It seems like 0 isn't behaving as a number here.

In this case, x cannot be defined, as we cannot divide by zero. 

Or, is there a case for considering 1/0 to be a number?  Is the result infinite or undefined? Why? Is there a case for looking at it either way?

I like to view it in baby terms. Lets say we have "1" of something. If we divide it upon 0 people, has it been divided at all, or has it been divided to 0 people, but just in unknown quantities? I had to look this up, and this is what wikipedia said:

Quote
Division: 0 / x = 0, for nonzero x. But x / 0 is undefined, because 0 has no multiplicative inverse, a consequence of the previous rule. For positive x, as y in x / y approaches zero from positive values, its quotient increases toward positive infinity, but as y approaches zero from negative values, the quotient increases toward negative infinity. The different quotients confirms that division by zero is undefined.

I think this is the most important question of all:
How are 0 and infinite related?  Think about how to get the result of infinite in a finite equation.  The only way to get it is to use a 0.  This means that 0 and infinite are related, and that infinite can be derived from 0.  Because, as it was already discussed here, infinite isn't a number, does that show that 0 isn't either? 

The only possible way I could think to produce ∞ from an equation would be x*0=0. But as that is undefined, I do not see any other way.

---------------

Whew! That was long post  :P.
The writ of the founders must endure.

Offline Joe

  • B&
  • Moderator
  • Hero Member
  • *****
  • Posts: 10319
  • In Soviet Russia, text read you!
    • View Profile
    • Github
Re: [JAVA] Calculate Pi!
« Reply #28 on: November 10, 2005, 05:05:36 pm »
Sweet, I sparked a nice conversation by being an idiot!
I'd personally do as Joe suggests

You might be right about that, Joe.


Offline rabbit

  • x86
  • Hero Member
  • *****
  • Posts: 8092
  • I speak for the entire clan (except Joe)
    • View Profile
Re: [JAVA] Calculate Pi!
« Reply #29 on: November 10, 2005, 05:32:47 pm »
Also, pi is not only a number, but the 16th letter in the greek alphabet.


It's also a function.  Also, it's another (different) function.  So, pi is officially a letter, number, and two functions.  Hrm.

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: [JAVA] Calculate Pi!
« Reply #30 on: November 10, 2005, 05:36:01 pm »
Sweet, I sparked a nice conversation by being an idiot!

You're actually pretty good at that, I've noticed. :P

Offline d&q

  • Hero Member
  • *****
  • Posts: 1427
  • I'm here.
    • View Profile
    • Site
Re: [JAVA] Calculate Pi!
« Reply #31 on: November 10, 2005, 06:15:18 pm »
rabbit: What do you mean Pi itself is a function?
The writ of the founders must endure.

Offline Joe

  • B&
  • Moderator
  • Hero Member
  • *****
  • Posts: 10319
  • In Soviet Russia, text read you!
    • View Profile
    • Github
Re: [JAVA] Calculate Pi!
« Reply #32 on: November 10, 2005, 07:11:42 pm »
rabbit: What do you mean Pi itself is a function?

Yeah, I don't quite get that either.
I'd personally do as Joe suggests

You might be right about that, Joe.


Offline AntiVirus

  • Legendary
  • x86
  • Hero Member
  • *****
  • Posts: 2521
  • Best
    • View Profile
Re: [JAVA] Calculate Pi!
« Reply #33 on: November 11, 2005, 01:08:28 pm »
Quote
         Rational Numbers- Can be written as a result of the calculation: a/b. This includes repeating decimals, such as 5/7 or 1/3.
I may be wrong.  But, don't raitonal numbers have numbers that repeat after teh decimal?  Such as .3333333 ect.  But, 5/7 doesn't fit the description, so did you mean to put that in irrational?  Or am I just wrong?
The once grove of splendor,
Aforetime crowned by lilac and lily,
Lay now forevermore slender;
And all winds that liven
Silhouette a lone existence;
A leafless oak grasping at eternity.


"They say that I must learn to kill before I can feel safe, but I rather kill myself then turn into their slave."
- The Rasmus

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: [JAVA] Calculate Pi!
« Reply #34 on: November 11, 2005, 01:15:13 pm »
Quote
         Rational Numbers- Can be written as a result of the calculation: a/b. This includes repeating decimals, such as 5/7 or 1/3.
I may be wrong.  But, don't raitonal numbers have numbers that repeat after teh decimal?  Such as .3333333 ect.  But, 5/7 doesn't fit the description, so did you mean to put that in irrational?  Or am I just wrong?
You're just wrong :-P

Rational numbers have numbers that repeat, as well as numbers that terminate (I forget what they're called), an integers, whole numbers, and natural numbers. 

Irrational numbers contain all rational numbers, and everything below it. 

Offline d&q

  • Hero Member
  • *****
  • Posts: 1427
  • I'm here.
    • View Profile
    • Site
Re: [JAVA] Calculate Pi!
« Reply #35 on: November 11, 2005, 06:23:47 pm »
Haha, 5/7 does repeat  :), there is as cool little pattern to know what any x/7 repeating decimal is.

@iago, Actually, I believe irrational numbers do not contain rational numbers, as irrational numbers cannot be written as "a/b".
The writ of the founders must endure.

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: [JAVA] Calculate Pi!
« Reply #36 on: November 11, 2005, 07:00:41 pm »
@iago, Actually, I believe irrational numbers do not contain rational numbers, as irrational numbers cannot be written as "a/b".
You are correct, Real numbers are the set of rational numbers plus irrationational numbers, like the set of all numbers contains real and imaginary numbers, whcih are mutually exclusive.  ;)
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: [JAVA] Calculate Pi!
« Reply #37 on: November 11, 2005, 08:03:24 pm »
@iago, Actually, I believe irrational numbers do not contain rational numbers, as irrational numbers cannot be written as "a/b".
You are correct, Real numbers are the set of rational numbers plus irrationational numbers, like the set of all numbers contains real and imaginary numbers, whcih are mutually exclusive.  ;)
Ah, you're right, I was mixing up irrational and real.  Stupid mistake :)

Offline rabbit

  • x86
  • Hero Member
  • *****
  • Posts: 8092
  • I speak for the entire clan (except Joe)
    • View Profile
Re: [JAVA] Calculate Pi!
« Reply #38 on: November 12, 2005, 12:58:35 pm »
The first pi function (lowercase pi, as we usually see it), is the number of primes less than the argument.
IE:


The second pi function (uppercase pi) is the expression for the process of Eratosthenes' Sieve (the multiplication of all factors of the argument).
IE:
« Last Edit: November 12, 2005, 02:08:17 pm by rabbit »

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: [JAVA] Calculate Pi!
« Reply #39 on: November 12, 2005, 01:18:52 pm »
The first pi function (lowercase pi, as we usually see it), is the number of primes less than the argument.
IE:


The second pi function (uppercase pi) is the expression for the process of Eratosthenes' Sieve (the multiplication of all factors of the argument).
IE:

That seems off.  Number of primes less than 60 is not 46.7 billion.  They are: 2,3,5,7,11,13,17,19,23,27,31,37,41,43,47,53,57.

The multiplication of all positive integral factors of 12 = 1 * 2 * 3 * 4 * 6 = 144.

Unless I'm misunderstanding you.
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline rabbit

  • x86
  • Hero Member
  • *****
  • Posts: 8092
  • I speak for the entire clan (except Joe)
    • View Profile
Re: [JAVA] Calculate Pi!
« Reply #40 on: November 12, 2005, 02:07:35 pm »
I got it backwards!!  Whoops....fixing...

Fixed.  Even still, you should have noticed it was backwards considering I said the case of pi...and then had the different cases.

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: [JAVA] Calculate Pi!
« Reply #41 on: November 12, 2005, 02:31:02 pm »
But in any case, neither of those has anything to do with the constant Pi, doe they?

Offline rabbit

  • x86
  • Hero Member
  • *****
  • Posts: 8092
  • I speak for the entire clan (except Joe)
    • View Profile
Re: [JAVA] Calculate Pi!
« Reply #42 on: November 12, 2005, 04:27:20 pm »
Sure they do!  They are all represented by the Greek letter Pi.

Offline Tomcat

  • Newbie
  • *
  • Posts: 6
  • Hi! I'm new!
    • View Profile
Re: [JAVA] Calculate Pi!
« Reply #43 on: November 14, 2005, 08:10:25 pm »
e is like pi, I believe.  My ti-83 says it's approximately 2.71828182.  If by "like infinity" you mean not a number, then no, it's a number.  It's more like Pi in that they are both irrational numbers.  I would, however, relate it more closely to phi (phi is approximately 1.618...), because both were discovered frequently in nature.  Phi is a very interresting number.

-EDIT-
Quote
The only possible way I could think to produce ∞ from an equation would be x*0=0. But as that is undefined, I do not see any other way.
x*0 equals 0.  It's defined as 0, isn't it?  anything * 0 is 0, or so I thought.
« Last Edit: November 14, 2005, 08:37:03 pm by Tomcat »

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: [JAVA] Calculate Pi!
« Reply #44 on: November 14, 2005, 08:57:17 pm »
e is like pi, I believe.  My ti-83 says it's approximately 2.71828182.  If by "like infinity" you mean not a number, then no, it's a number.  It's more like Pi in that they are both irrational numbers.  I would, however, relate it more closely to phi (phi is approximately 1.618...), because both were discovered frequently in nature.  Phi is a very interresting number.

-EDIT-
Quote
The only possible way I could think to produce ∞ from an equation would be x*0=0. But as that is undefined, I do not see any other way.
x*0 equals 0.  It's defined as 0, isn't it?  anything * 0 is 0, or so I thought.

I think those things have already been mentioned.  :P

x * 0 = 0 is one way to think of infinitie, but since you can't devide by zero due to mathematical laws, it's undefined, not infinite.

Offline Tomcat

  • Newbie
  • *
  • Posts: 6
  • Hi! I'm new!
    • View Profile
Re: [JAVA] Calculate Pi!
« Reply #45 on: November 14, 2005, 09:01:58 pm »
Yeah I saw something I knew about, and decided to go ahead and post about it.  I didn't read past page 2.  Oops  ;D ;D

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: [JAVA] Calculate Pi!
« Reply #46 on: November 14, 2005, 09:10:53 pm »
By the way, e is more formally defined as one of the following (I learned it in Calculus about two months ago, but I'm ripping the images from Wikipedia):






Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: [JAVA] Calculate Pi!
« Reply #47 on: November 14, 2005, 09:42:24 pm »
I don't see how e can be the sum of 1/n! from 0 to infinity.  1/0! = 1/0 = undefined.
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline d&q

  • Hero Member
  • *****
  • Posts: 1427
  • I'm here.
    • View Profile
    • Site
Re: [JAVA] Calculate Pi!
« Reply #48 on: November 15, 2005, 03:11:17 pm »
Wrong  :-*! 0! = 1.
The writ of the founders must endure.

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: [JAVA] Calculate Pi!
« Reply #49 on: November 15, 2005, 03:55:16 pm »

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: [JAVA] Calculate Pi!
« Reply #50 on: November 15, 2005, 05:09:34 pm »
Wrong  :-*! 0! = 1.
Oh yeah that's right.  *reaches back 3 years* I remember arguing over that with my calculus teacher.  He won.
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: [JAVA] Calculate Pi!
« Reply #51 on: November 15, 2005, 10:16:08 pm »
Oh yeah that's right.  *reaches back 3 years* I remember arguing over that with my calculus teacher.  He won.

Haha.  I don't think I ever remember learning the reasoning behind it.  I just remember learning 0! = 1. :)

Offline d&q

  • Hero Member
  • *****
  • Posts: 1427
  • I'm here.
    • View Profile
    • Site
Re: [JAVA] Calculate Pi!
« Reply #52 on: November 15, 2005, 10:41:44 pm »
Basically, its that you can only arrange nothing in one way.
The writ of the founders must endure.

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: [JAVA] Calculate Pi!
« Reply #53 on: November 15, 2005, 11:28:42 pm »
Basically, its that you can only arrange nothing in one way.

Makes perfect sense. :)

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: [JAVA] Calculate Pi!
« Reply #54 on: November 16, 2005, 03:12:22 pm »
By the way, here's another math problem: Are there more natural numbers (1, 2, 3, ...) or integers (...., -2, -1, 0, 1, 2, ....)?

For every natural number x, there are two integers, x and -x.  So there are twice as many integers as naturals numbers, plus 1 (for 0).  Right?

Offline Hitmen

  • B&
  • x86
  • Hero Member
  • *****
  • Posts: 1913
    • View Profile
Re: [JAVA] Calculate Pi!
« Reply #55 on: November 16, 2005, 03:17:12 pm »
By the way, here's another math problem: Are there more natural numbers (1, 2, 3, ...) or integers (...., -2, -1, 0, 1, 2, ....)?

For every natural number x, there are two integers, x and -x.  So there are twice as many integers as naturals numbers, plus 1 (for 0).  Right?
Well, there's an infinate number for both, one just gets to infinity slightly faster :)
Quote
(22:15:39) Newby: it hurts to swallow

Offline rabbit

  • x86
  • Hero Member
  • *****
  • Posts: 8092
  • I speak for the entire clan (except Joe)
    • View Profile
Re: [JAVA] Calculate Pi!
« Reply #56 on: November 16, 2005, 04:59:02 pm »
Actually, if either could reach infinity, neither would be faster.

Offline d&q

  • Hero Member
  • *****
  • Posts: 1427
  • I'm here.
    • View Profile
    • Site
Re: [JAVA] Calculate Pi!
« Reply #57 on: November 16, 2005, 05:10:24 pm »
There are varying levels of infinity. Numerically, as in counting from 1, 2 ,3, 4 etc, they are infinity, but cardinally, as in {1, 2, 3, ...}, integers are greater. I believe they are alaph numbers..

[Edit]: Whoops, Aleph* Numbers
« Last Edit: November 16, 2005, 05:12:02 pm by Deuce »
The writ of the founders must endure.

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: [JAVA] Calculate Pi!
« Reply #58 on: November 16, 2005, 06:48:08 pm »
No number set will ever reach infinite.  Infinite isn't a value, it's a concept.

Offline d&q

  • Hero Member
  • *****
  • Posts: 1427
  • I'm here.
    • View Profile
    • Site
Re: [JAVA] Calculate Pi!
« Reply #59 on: November 16, 2005, 08:43:25 pm »
Not reach infinite, be infinite.  :o
The writ of the founders must endure.

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: [JAVA] Calculate Pi!
« Reply #60 on: November 16, 2005, 08:51:28 pm »
So they're both infinite, but one has twice as many values? :)

And by the way, you are absolutely right:
There are varying levels of infinity. Numerically, as in counting from 1, 2 ,3, 4 etc, they are infinity, but cardinally, as in {1, 2, 3, ...}, integers are greater. I believe they are alaph numbers..

[Edit]: Whoops, Aleph* Numbers
Rational, whole, natural, etc., are all "countable" infinite sets.  So is Real, apparently, but we haven't proven that one yet. 

It's still neat to think that there are the same "number" of even numbers as even+odd numbers. 

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: [JAVA] Calculate Pi!
« Reply #61 on: November 16, 2005, 09:05:53 pm »
Not reach infinite, be infinite.  :o

Actually, if either could reach infinity, neither would be faster.

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: [JAVA] Calculate Pi!
« Reply #62 on: November 16, 2005, 09:14:34 pm »
We're not talking about whether either could reach infinity, we're talking about the value of the count of numbers in the series.  Integers have 2 x (count of whole numbers) + 1 items.  Assuming (count of whole numbers) is infinity, the count of integers is 2x(whole numbers count infinity) + 1, which makes it a bigger infinity.

If you put (whole numbers count infinity) / (count of integers infinty) you'd get a value infinitesimally approaching 0.5 from the left.
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: [JAVA] Calculate Pi!
« Reply #63 on: November 16, 2005, 09:20:30 pm »
Aah, I see what you're saying now.  :)

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: [JAVA] Calculate Pi!
« Reply #64 on: November 16, 2005, 09:35:50 pm »
We're not talking about whether either could reach infinity, we're talking about the value of the count of numbers in the series.  Integers have 2 x (count of whole numbers) + 1 items.  Assuming (count of whole numbers) is infinity, the count of integers is 2x(whole numbers count infinity) + 1, which makes it a bigger infinity.

If you put (whole numbers count infinity) / (count of integers infinty) you'd get a value infinitesimally approaching 0.5 from the left.

Aha, you are correct; however, look at this mapping:

N| 1 2  3 4  5 6  7 ....
------------------------
Z| 0 1 -1 2 -2 3 -3 ....


Assuming we continue doing that to infinity, we can convert any natural number to an integer:
Z
  • = N
  • / 2   --> if x is even and not 0

Z
  • = -(N
  • / 2) + 1 --> if x is odd and not 0

Z
  • = 0 --> if x = 0


So, for every integer Z
  • , there's a corresponding natural number N
  • , and vice versa.  So there aren't twice as many, since there is a 1:1 mapping.  Despite the fact that for every natural number, there's two integers, there's still a one-to-one mapping. 


Isn't infinity great? :)

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: [JAVA] Calculate Pi!
« Reply #65 on: November 16, 2005, 10:55:25 pm »
Perhaps, but there's also a 2:1 mapping! :P
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline Joe

  • B&
  • Moderator
  • Hero Member
  • *****
  • Posts: 10319
  • In Soviet Russia, text read you!
    • View Profile
    • Github
Re: [JAVA] Calculate Pi!
« Reply #66 on: November 16, 2005, 11:23:40 pm »
e is like pi, I believe. My ti-83 says it's approximately 2.71828182. If by "like infinity" you mean not a number, then no, it's a number. It's more like Pi in that they are both irrational numbers. I would, however, relate it more closely to phi (phi is approximately 1.618...), because both were discovered frequently in nature. Phi is a very interresting number.

-EDIT-
Quote
The only possible way I could think to produce ∞ from an equation would be x*0=0. But as that is undefined, I do not see any other way.
x*0 equals 0. It's defined as 0, isn't it? anything * 0 is 0, or so I thought.

I think those things have already been mentioned. :P

x * 0 = 0 is one way to think of infinitie, but since you can't devide by zero due to mathematical laws, it's undefined, not infinite.


Technically, dividing something means splitting it into equal piles. A good way of thinking of this is dealing cards. How do you deal cards to 0 people?
52/0 = 0R52 (you didn't give anyone any cards) = 1.

Division by 0 equals 1.
I'd personally do as Joe suggests

You might be right about that, Joe.


Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: [JAVA] Calculate Pi!
« Reply #67 on: November 16, 2005, 11:43:59 pm »
Technically, dividing something means splitting it into equal piles. A good way of thinking of this is dealing cards. How do you deal cards to 0 people?
52/0 = 0R52 (you didn't give anyone any cards) = 1.

Division by 0 equals 1.

No, division by 0 = undefined.  Try it on any calculator.  That's why there's an error in games and things of this nature that reads "Error: Cannot divide by 0."

Lern 2 do math

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: [JAVA] Calculate Pi!
« Reply #68 on: November 16, 2005, 11:48:32 pm »
e is like pi, I believe. My ti-83 says it's approximately 2.71828182. If by "like infinity" you mean not a number, then no, it's a number. It's more like Pi in that they are both irrational numbers. I would, however, relate it more closely to phi (phi is approximately 1.618...), because both were discovered frequently in nature. Phi is a very interresting number.

-EDIT-
Quote
The only possible way I could think to produce ∞ from an equation would be x*0=0. But as that is undefined, I do not see any other way.
x*0 equals 0. It's defined as 0, isn't it? anything * 0 is 0, or so I thought.

I think those things have already been mentioned. :P

x * 0 = 0 is one way to think of infinitie, but since you can't devide by zero due to mathematical laws, it's undefined, not infinite.


Technically, dividing something means splitting it into equal piles. A good way of thinking of this is dealing cards. How do you deal cards to 0 people?
52/0 = 0R52 (you didn't give anyone any cards) = 1.

Division by 0 equals 1.
By your example, you'd be giving out cards forever, because you'd be sitting there with the deck giving one to each of the 0 people.  So your deck would never lose a card.  So it would work out to infinity, or undefined, depending on how long you sit around, I suppose..

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: [JAVA] Calculate Pi!
« Reply #69 on: November 17, 2005, 12:28:49 am »
By your example, you'd be giving out cards forever, because you'd be sitting there with the deck giving one to each of the 0 people.  So your deck would never lose a card.  So it would work out to infinity, or undefined, depending on how long you sit around, I suppose..

Hehe, exactly. :D

Offline rabbit

  • x86
  • Hero Member
  • *****
  • Posts: 8092
  • I speak for the entire clan (except Joe)
    • View Profile
Re: [JAVA] Calculate Pi!
« Reply #70 on: November 17, 2005, 08:44:49 pm »
e is like pi, I believe. My ti-83 says it's approximately 2.71828182. If by "like infinity" you mean not a number, then no, it's a number. It's more like Pi in that they are both irrational numbers. I would, however, relate it more closely to phi (phi is approximately 1.618...), because both were discovered frequently in nature. Phi is a very interresting number.

-EDIT-
Quote
The only possible way I could think to produce ∞ from an equation would be x*0=0. But as that is undefined, I do not see any other way.
x*0 equals 0. It's defined as 0, isn't it? anything * 0 is 0, or so I thought.

I think those things have already been mentioned. :P

x * 0 = 0 is one way to think of infinitie, but since you can't devide by zero due to mathematical laws, it's undefined, not infinite.


Technically, dividing something means splitting it into equal piles. A good way of thinking of this is dealing cards. How do you deal cards to 0 people?
52/0 = 0R52 (you didn't give anyone any cards) = 1.

Division by 0 equals 1.
Division is more accurately described as "division among/between".  IE: Division by 1 means "division among 1", and thus the source remains whole, as it all goes to 1 "thing".