getcontext().prec = 60

def printRecurrence():
    x = [0] * 51
x[0] = Decimal(1)
x[1] = Decimal(1) / Decimal(3)
for i in range(1, 50):
    x[i + 1] = Decimal(13) / Decimal(3) * x[i] - Decimal(4) / Decimal(3) * x[
        i - 1]
print((float(x[i + 1]), 3 ** -(i + 1), float(x[i + 1] - Decimal(3) ** -(i + 1))
    ))
printRecurrence()
Recurrence Relations in python