need to try to find Pi, need some help

I have need to try to find some of the values of Pi,but when i try math.PI i only get down to like 8 decimals.I need some help.Not sure were to start either!Message was edited by: Aten
[226 byte] By [Atena] at [2007-11-26 12:40:46]
# 1

Math.PI is a double. It should have more than 8 decimal digits. (Well, actually it has binary digits, but when formatted as a decimal there should be more than 8 digits.)

Try using a different formatter.

Or better yet...why do you need pi? What are you planning to do with the value? Why do you feel that the value given by Math.PI isn't good enough?

paulcwa at 2007-7-7 16:12:48 > top of Java-index,Java Essentials,Java Programming...
# 2
I am trying to how many digits i can find in a period of time, my teacher said he can help me display the numbers and count them if i can get the code that will find many digits of Pi.I hope that clears things up
Atena at 2007-7-7 16:12:48 > top of Java-index,Java Essentials,Java Programming...
# 3
In that case, you're not supposed to use Math.PI at all. You're supposed to implement an algorithm that will generate the digits of pi. Using Math.PI would be cheating.
paulcwa at 2007-7-7 16:12:48 > top of Java-index,Java Essentials,Java Programming...
# 4
This may be helpful: http://en.wikipedia.org/wiki/Pi#AnalysisLeibniz's looks easiest.
paulcwa at 2007-7-7 16:12:48 > top of Java-index,Java Essentials,Java Programming...
# 5
I'v heard that Leibniz's is the easiest but im taking Algebra 2 right now and none of them make much sense to me, sorry, but could you help me with that?
Atena at 2007-7-7 16:12:48 > top of Java-index,Java Essentials,Java Programming...
# 6

You're just adding terms together.There's a series of them, so you need a loop. Each pass through the loop could add one more term. Note that each term has a denominator that is bigger by 2, and it's either added or subtracted (or to look at it another way, you're adding negatives alternately).

The main issue is how accurate you want it to be. You can't add the digits together forever. So you have to choose a stopping point. You can stop based on a time period (when you've run out of time, stop adding new terms) or on precision (when two subsequent values are close enough to each other, stop).

You'll probably want to use java.math.BigDecimal.

If you give some more details about the assignment I can make some more suggestions.

Why don't you give it a try and see how it works?

paulcwa at 2007-7-7 16:12:48 > top of Java-index,Java Essentials,Java Programming...
# 7

> I'v heard that Leibniz's is the easiest but im taking

> Algebra 2 right now and none of them make much sense

> to me, sorry, but could you help me with that?

Maybe, but I've heard the frozen hotdog method is more fun

http://www.wikihow.com/Calculate-Pi-by-Throwing-Frozen-Hot-Dogs

tjacobs01a at 2007-7-7 16:12:48 > top of Java-index,Java Essentials,Java Programming...