Consider this difference equation:
The solution is
I am trying to solve it numerically in python, to explicate issues that arise with floating point computations.
I wrote a function that computes xn+1
def diff(n):
c = 1
b = -1/5.0
a = 0
for i in xrange(n):
a = 14/5.0*b+3/5.0*c
b, c = a, b
return a
but I don't know how to solve this numerically and then to explain why python can not provide the xn = (-1/5)n solution.
I can see that for larger n, the return value of my function diverges from the true value.