Re: HP80 Function Question Message #7 Posted by Thomas Klemm on 13 Feb 2012, 6:32 p.m., in response to message #6 by Gerson W. Barbosa
Yet another implementation using Python:
def diff(xs):
y = xs.pop(0)
ys = []
for x in xs:
ys.append(x  y)
y = x
return ys
x, y, z, t = 0, 0, 0, 0
xs = []
for i in range(10):
x, y, z, t = x + y, z + 1, t + x**2, t + x**2
xs.append(x)
print xs
dxs = diff(xs)
print dxs
d2xs = diff(dxs)
print d2xs
I calculated the difference between sequent elements:
[0, 1, 2, 3, 5, 11, 26, 66, 227, 1064]
[1, 1, 1, 2, 6, 15, 40, 161, 837]
[0, 0, 1, 4, 9, 25, 121, 676]
This shows that the 2nd difference is the same as the initial sequence squared and shifted.
Or as a recursive formula:
x_{n+3} = 2 x_{n+2}  x_{n+1} + x_{n}^{2}
together with the initial values: x_{0}=0, x_{1}=1, x_{2}=2.
This leads to the simple program:
x = [0, 1, 2]
for n in range(10):
x.append(2*x[n+2]  x[n+1] + x[n]**2)
print x
... which produces the same result:
[0, 1, 2, 3, 5, 11, 26, 66, 227, 1064, 6257, 62979, 1251797]
I've tried in vain to use
WolframAlpha to find a closed form. So I'm afraid there isn't.
Cheers
Thomas
Edited: 13 Feb 2012, 7:06 p.m.
