Math problem | Page 2 | Golden Skate

Math problem

OK, so calculating the result in Excel, we get 0.239560747 . This is as many decimal places as Excel can do.

Now, let's write a computer program in the Pascal programming language.

program foxtrot;
var k, goal : longint;
one, factor, sum, previous : real;

begin
write(' How many iterations? ');
readln( goal );
writeln;
sum := 0.0;
one := -1.0;
factor := 0.0;
k := 0;
repeat
previous := factor;
k := k + 1;
one := -1.0 * one;
factor := ( one * k * k ) / ( 1.0 * k * k * k + 1.0 );
sum := factor + sum
until k = goal;
writeln;
writeln(' The sum = ', sum, ' after ', k, ' iterations. ');
writeln
end.

Let's compare the answer with the number of iterations.

iterations ....................... result
1,000 ....................... 0.23906099734
10,000 ..................... 0.23951074984
100,000 .................... 0.23955574735
1,000,000 ................. 0.23956024728
10,000,000 ............... 0.23956069736
100,000,000 ............. 0.23956074230
200,000,000 ............. 0.23956074479
300,000,000 ............. 0.23956074562
400,000,000 ............. 0.23956074603
500,000,000 ............. 0.23956074628
1,000,000,000 ........... 0.23956074677

So as we can see, it took a billion iterations to achieve the Excel result to 9 decimal places.
 
Last edited:
:clap:

Notice that this sequence converges only as fast as the logarithm. That is, for N iterations the answer is accurate only up to about log(N) decimal places.

This is because each term is on the order of n^2/n^3 = 1/n. :)
 
So that means if we wanted more decimal places, it would have taken more iterations.

decimal places ......... iterations
9 .......................... one billion
12 ........................ one trillion
15 ........................ one quadrillion
18 ........................ one quintillion
21 ........................ one ***tillion ( Looks like the board censor is activated. ) :laugh:
 
Back
Top