I have small problem with too big float numbers in Python. Overflow errors occur.
The function look like this:
N(t + 1) = (1 + c) N(t) - (c / d) * N(t)**2
where t is time, and c and d are constants.
I need it to calculate up to one minute (t = 60). But after t= 8, 9 or 10 I got overflow error.
def nValue(t):
n_calc = []
c = 2.3 # 0..3
d = 95 # 1..250
n_0 = 450 # 0..600
n_1 = (1 + c) * n_0 - c / d * n_0**2
n_calc.append(n_0)
n_calc.append(n_1)
for i in range(2, t+1):
n_curr = (1 + c) * n_calc[i- 1] - (c / d) * (n_calc[i- 1]**2)
n_calc.append(n_curr)
return n_calc
Should I use Decimal type, BigFloat or something different?
Finally I have to draw plot... (2D Matplotlib plot). Maybe I should "scale" somehow this equation?