The Museum of HP Calculators

HP Forum Archive 21

 HP PRIME: interlinked sequences?Message #1 Posted by Alasdair McAndrew on 20 Nov 2013, 7:06 p.m. In attempting to experiment with Jacobi iteration for solution of linear equations, I entered the sequences: ```U1(1) = 1 U1(N) = (4 - U2(N-1) + U3(N-1))/4 U2(1) = 1 U2(N) = (2 - 2*U1(N-1) - U3(N-1))/5 U3(1) = 1 U3(N) = (11 - U1(N-1))/3 ``` Now there's nothing mathematically wrong with these, except that the HP Prime doesn't like them. I can't use "Eval" for any of the definitions, as that gives rise to a never-ending mess of iterated definitions. I would have hoped that these sequences could simply be evaluated "as is", but I can't find a way to do so. In fact, I can't even check any of the sequences for inclusion in the numerical listing of their values or for plotting. Is there any way to coerce the HP Prime to perform this sort of interlinked iteration?

 Re: HP PRIME: interlinked sequences?Message #2 Posted by Tim Wessman on 21 Nov 2013, 9:55 a.m.,in response to message #1 by Alasdair McAndrew Interlinked sequences is something quite hard with the possibility of recursions and so forth. Some might work, while others will never resolve. This is something that is not supported at the moment but is definitely on the list of items to revisit once more important things get taken care of to see if we can figure out how to make it work well. There is a sequence solving in the CAS, but I am not certain if it will handle interlinked sequences either. TW

 Re: HP PRIME: interlinked sequences?Message #3 Posted by cyrille de Brébisson on 22 Nov 2013, 2:16 a.m.,in response to message #1 by Alasdair McAndrew Hello, The "problem" in your example is that U1(N) can be expanded as: (4 - (2 - 2*U1(N-2) - U3(N-2))/5 + U3(N-1))/4 which can itself be expanded as: (4 - (2 - 2*U1(N-2) - (11 - U1(N-3))/3)/5 + (11 - U1(N-2))/3)/4 this show the dependency from U1(N) to U1(N-3)... but Prime can only handle 2 level recursion, not 3... Cyrille

 Re: HP PRIME: interlinked sequences?Message #4 Posted by Patrice on 23 Nov 2013, 5:29 p.m.,in response to message #3 by cyrille de Brébisson Bonjour Cyrille, Vu que toute série peut être étendue jusqu'à avoir des références à U(N-3) ou pire, je ne vois pas bien le pourquoi de ton explication. Il suffirait que l'on calcule les éléments indice N de toutes les suites avant de calculer les éléments indice N+1 et le tour est joué. Par exemple une suite de Fibonacl: U(N)=U(N-1)+U(N-2) peut être étendue à U(N)=U(N-2)+2*U(N-3)+U(N-4) mais c'est pas un problème pour l'évaluer.

 Re: HP PRIME: interlinked sequences?Message #5 Posted by Alasdair McAndrew on 23 Nov 2013, 10:39 p.m.,in response to message #3 by cyrille de Brébisson The thing is that you can't expand these definitions: you will end up with infinite recursion. On the other hand, they can be computed simply as they are, by starting with U1(1), U2(1) and U3(1), then using all of those values to compute U1(2), U2(2) and U3(2) and so on. In a sense what we have is really an iteration of vectors: [u1, u2, u3] -> [(4 - u2 + u3)/4, (2 - 2*u1 - u3)/5, (11 - u1)/3] which would be trivial if the sequence app could manage sequences of vectors, as well as numbers.

Go back to the main exhibit hall