Name: Anonymous 2006-04-08 9:31
I am a noob in programming and I am trying to write up an algorithm for my maths project. One of the problems seems to be the lack of precision.
This is how the algorithm goes.
Given a number x, you take the floor of x say [x] and find x-[x], if x-[x] is non zero, you find the reciprocal of x-[x] and put that to be the "new" x. And then repeat the process until x-[x] is zero (guaranteed if x is rational) where the algorithm terminates. The problem about the lack of precision seems to occur at the reciprocal step. For example if you take x = 4.3, we have diff = x-[x]=0.3 and 1/diff = 10/3 = 3.333333... . The computer seems to eventually terminate this decimal expansion and when taking the floor and then the respective difference I think it plays havoc on the following reciprocal step.
I have asked one of my friends, who had a go at writing the algorithm as well and he was the one who said I would be needing an Arbitary precision library. Could anyone help me?
This is how the algorithm goes.
Given a number x, you take the floor of x say [x] and find x-[x], if x-[x] is non zero, you find the reciprocal of x-[x] and put that to be the "new" x. And then repeat the process until x-[x] is zero (guaranteed if x is rational) where the algorithm terminates. The problem about the lack of precision seems to occur at the reciprocal step. For example if you take x = 4.3, we have diff = x-[x]=0.3 and 1/diff = 10/3 = 3.333333... . The computer seems to eventually terminate this decimal expansion and when taking the floor and then the respective difference I think it plays havoc on the following reciprocal step.
I have asked one of my friends, who had a go at writing the algorithm as well and he was the one who said I would be needing an Arbitary precision library. Could anyone help me?