Re: Computing pi to nth terms?

From: Kraig (tsi1990_at_gmail.com)
Date: 09/21/04


Date: Mon, 20 Sep 2004 17:05:22 -0500

I am attempting to pass powers of two, from one to 16777216, to a
calculation that approximates pi for each respective power of two
previously mentioned. It's the second loop, the calculation of pi using
the int created in the first loop, that is proving problematic.

kraig

Kai-Uwe Bux wrote:

> Kraig wrote:
>
>
>>After much wringing of hands and pulling of hair, I have arrived at:
>>
>>#include <iostream>
>>#include (cmath>
>>using namespace std;
>>
>>int main()
>>{
>> double pi = 0;
>> double n = 0;
>> double x = 0;
>> double y = 0;
>>
>> for(n = 1; n <=16777216; n*=2)
>> {
>> for(x = 1; x <= (2*n - 1); y++)
>> {
>> pi = pow(1, ((y +1)) * (4/x);
>
>
> This sets pi to 1 since pow(1,whatever) is 1.
>
>
>> pi += pi;
>
>
> Now, pi is 2.
>
>
>> x+=2;
>
>
> And it exits the loop as two.
>
>> }
>> cout << "pi value using " << n << " terms is " << pi << " " "
>>\n";
>> }
>>return 0;
>>}
>>
>>This seems to basically work, but the values in output are not correct.
>
>
> Obviously you are trying to add the terms of some series for pi. Which one
> do you have in mind.
>
>
> Best
>
> Kai-Uwe Bux



Relevant Pages

  • Re: Induction experiment part 2
    ... Except your calculation for B above is wrong. ... Amp/meter matches 4.36 amps. ... amps in the primary via the loop calculation. ... That is not the primary voltage. ...
    (sci.physics.electromag)
  • Re: Induction Experiment Part 5
    ... output voltage is 42.3 VAC RMS. ... measurement is 9.22 mV AC RMS so double the 60Hz measurement. ... The emf via E_k calculation is now 14.2 mV AC RMS for this ... field is current divided by the diameter of the circle loop. ...
    (sci.physics.electromag)
  • Re: Induction experiment part 2
    ... Except your calculation for B above is wrong. ... amps in the primary via the loop calculation. ... That is not the primary voltage. ... secondary measured voltage and got the magnetic flux. ...
    (sci.physics.electromag)
  • Re: Induction Experiment Part 5
    ... We have the same 7.62 meter parallel wire 18 gauge zip ... measurement is 9.22 mV AC RMS so double the 60Hz measurement. ... The emf via E_k calculation is now 14.2 mV AC RMS for this ... field is current divided by the diameter of the circle loop. ...
    (sci.physics.electromag)
  • Power Of The Day -- Lyndon
    ... calculations for the challenge totals. ... Powers, Emotion Control, ... loss for the challenge only regards the second calculation. ... You may use your power as a main player. ...
    (rec.games.board.ce)