I'm trying to create a table of values based upon tanh(x) (nevermind the cubic function for the moment):
#!/usr/bin/python
import math
def cubic(y0, y1, y2, y3, mu):
a0 = y3 - y2 - y0 + y1
a1 = y0 - y1 - a0
a2 = y2 - y0
a3 = y1
mu2 = mu*mu
return (a0*mu*mu2+a1*mu2+a2*mu+a3)
for i in range(0,1001):
x = (i * .004) - 2
y = math.tanh(x)
table[i] = y
But when I run it, I get the following error:
Traceback (most recent call last):
File "./cubictable.py", line 16, in <module>
table = y
NameError: name 'table' is not defined
How am I supposed to pre-define the list table[]? Thanks!