Skip to content

Instantly share code, notes, and snippets.

@Thar0l
Created March 21, 2017 19:23
Show Gist options
  • Select an option

  • Save Thar0l/c00e1ef1fdd22d8ec238349715374e40 to your computer and use it in GitHub Desktop.

Select an option

Save Thar0l/c00e1ef1fdd22d8ec238349715374e40 to your computer and use it in GitHub Desktop.
a00 = -165
a10 = -10
a11 = 3
def calc(n, x, a0 , a1, a2):
a1 = a2 * x + a1
print a1
for i in range(2, n + 1):
ai = i*i/(i-1)*x*a1 - 4*a0*x*x
a0 = a1
a1 = ai
return ai
tn = []
tn1 = []
tn2 = []
for i in range(0, 40):
tn.append([0, 0, 0])
tn1.append([0, 0, 0])
tn2.append([0, 0, 0])
tn[0][0] = -165
tn[1][0] = -10
tn[1][1] = 3
tn1[2] = tn[1]
tn2[2] = tn[0]
n = input("insert n: ")
x = input("insert x: ")
print calc(n, x, a00, a10, a11)
for i in range(2, n + 1):
tn[i][0] = i * i / (i - 1) * tn1[i][0]
tn[i][1] = i * i / (i - 1) * tn1[i][1] - 4 * tn2[i][0]
tn[i][2] = -4 * tn2[i][1]
tn2[i + 1] = tn1[i]
tn1[i + 1] = tn[i]
print "tn\t", tn
print "tn1\t", tn1
print "tn2\t", tn2
res = 0
for i in range(0, n + 1):
res *= x
res = tn[i][0] + x*tn[i][1] + x*x*tn[i][2]
print res
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment