# The Naked Scientists Forum

### Author Topic: infinite geometric sequences  (Read 2398 times)

#### science_guy

• Hero Member
• Posts: 701
• I'm right there... inside neilep's head!
##### infinite geometric sequences
« on: 23/04/2008 05:09:37 »
apparently, adding up the total of the infinite geometric sequence 8+4+2+1+.5+.25+.125... and so on adds up to 16

it was explained to me that if you were to keep going, then you would never reach 16, and the most you could reach in your lifetime would be 15.9999999999999999... and so on, but if you were ever to reach infinite terms, then the total would reach 16.

ever the sceptic, I wrote a program that does this very thing in a programming loop, commanding it to stop the loop when 16 is reached.  the code was written to return the number of times the loop was run to reach the destination.

as I executed the program, I expected it to freeze the program as the computer tries to add up the impossible number in an infinite loop, but the code took virtually no time at all.

the number it gave me for how many times it ran the loop was 25.  How is this possible?

#### another_someone

• Guest
##### infinite geometric sequences
« Reply #1 on: 23/04/2008 10:15:48 »
It simply runs out of floating point precision after that point (i.e. the difference between the numbers you are testing are less that the smallest number the floating point engine can discriminate, so it assumes the difference to be zero).
« Last Edit: 23/04/2008 10:39:34 by another_someone »

#### science_guy

• Hero Member
• Posts: 701
• I'm right there... inside neilep's head!
##### infinite geometric sequences
« Reply #2 on: 23/04/2008 15:47:57 »
ah.

in retrospect, it makes sense that the computer doesn't have infinite memory, really

#### The Naked Scientists Forum

##### infinite geometric sequences
« Reply #2 on: 23/04/2008 15:47:57 »