astonishing recurrence - Printable Version +- HP Forums (https://archived.hpcalc.org/museumforum) +-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html) +--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html) +--- Thread: astonishing recurrence (/thread-243676.html) |
astonishing recurrence - Thomas Klemm - 05-16-2013 Consider this definition of a sequence:
Cheers PS: Find the solution in a paper of Prof. W. Kahan. PPS: The other problems in this paper are worth reading as well. Edited: 16 May 2013, 6:26 p.m.
Re: astonishing recurrence - Michael Kathke - 05-17-2013 Very surprising result! Here is my first quick HP48SX RPL Solution. Now I have to think about it ;-) << DUP2 1500 ROT / NEG 815 + SWAP / NEG 108 + >> 'XNEXT' STO Put x0 and x1 on the stack. Then press 'XNEXT' each iteration.
x0 = 4
Edited: 17 May 2013, 7:33 p.m. after one or more responses were posted
Re: astonishing recurrence - Gilles Carpentier - 05-17-2013 To avoid potential problem of rounding, I use the 'exact mode' of the 50G :
In approx mode I got the same 'false' results of Michael
Edited: 17 May 2013, 9:07 a.m.
Re: astonishing recurrence - Mike Morrow - 05-17-2013 Quote: Well, this is some of the most interesting material I've read in a while. Thanks!
I've always been fascinated by the field of numerical analysis, and by one of its top mathematicians...the famous Dr. William Kahan. There is a 1997 DDJ interview with Dr. Kahan that is a short but enjoyable read.
Re: Michael Kathke - Marcel Samek - 05-17-2013 Since I had my Casio fx-9860GII sitting on my desk (recommended by members of this forum for its backlight), I thought I would give it a try. Interestingly, it gave different results if I entered the initial input value of 4.25 as a decimal, or if I entered it as a fraction. Otherwise the program was identical.
x0 = 4 If, however I input the initial variable as a fraction: 4/1/4
x0 = 4
Re: astonishing recurrence - Gerson W. Barbosa - 05-17-2013 Quote: Great idea! The recurrence has been set up to collapse under finite precision, no matter the number of digit. Even the wp34s in double precision eventually fails on that one:
ADDR OPCODE MNEMONIC Re: astonishing recurrence - Kiyoshi Akima - 05-18-2013 Could someone verify the N=6 case in the HP-97 column on page 2 of Kahan's paper? I don't have a 67/97 but neither my 19C nor 15C produce quite that value, though they agree with each other. They also agree with (most of) the succeeding values so I'm tempted to think it's a typo. I'm also getting a discrepancy for N=9, but I'm willing to chalk this one to rounding/truncating.
I realize the point of the exercise is to demonstrate getting incorrect results, but I thought the 67/97 did arithmetic the same as the 19C/15C.
Re: astonishing recurrence - Namir - 05-18-2013 Looking at the formula you can see that the limit is 100. Excel confirms that! If you change the first two values you should still get 100 as the limit. I found an exception!! If the fist two values are 5, you get 5 as the limit. Namir
Edited: 18 May 2013, 1:45 a.m.
Re: astonishing recurrence - Peter Murphy (Livermore) - 05-18-2013 And 3, 3 yields 3. A plot of the function obtained by replacing all three x-values in the recurrence with the symbol x shows zeros at 3, 5, and 100.
Re: astonishing recurrence - peacecalc - 05-18-2013 Hello Calc-Friends, If you suppose existing limits, then you can set X=X_n=X_n-1=X_n-2 and you get an third grade equation which can be written as: X^3 - 108X^2 + 815X -1500 = 0 and the hp 50 can this easily factorize to (X-100)(X-5)(X-3) = 0. There you have the three fixpoints. The recurrence is very unstable because of the difference. greetings
peaceglue Edited: 18 May 2013, 3:59 a.m.
Re: astonishing recurrence - Thomas Klemm - 05-18-2013 Quote: What you probably mean is that 100 is a fixed point. But that doesn't make it the limit of the sequence. Just have a look at Gilles results using the HP-50g in exact mode.
Quote: The same happens for the given initial values. But the path starting from there is very prone to rounding errors. As soon as you miss the exact path only a little the sequence converges to 100.
Cheers
PS: All the math is in Kahan's paper.
Re: astonishing recurrence - Thomas Klemm - 05-18-2013 Quote: The recurrence isn't unstable per se as 100 is an attractive fixed point. However this specific sequence is prone to rounding errors as it converges to a hyperbolic fixed point (saddle point).
Cheers Re: astonishing recurrence - Namir - 05-18-2013 Very good analysis!!! :-)
Namir
Re: astonishing recurrence - Willy R. Kunz - 05-18-2013 Yes, it's a typo. Both the emulator RPN-67 Pro (with "Enhanced Calculator" set to Off) and a real HP-67 return 5.745 for N=6 and -18.74 for N=9.
Re: astonishing recurrence - Thomas Klemm - 05-18-2013 Good catch! I can confirm your observations using the HP-15C as I get: N xN PREFIXI share your conclusions: probably a typo.
Kind regards Re: astonishing recurrence - Marcus von Cube, Germany - 05-18-2013 Gerson, a good example of compactness versus readability. ;)
Does the series move away from 5 as soon as the value goes beyond that threshold? It seems to converge versus 5 as long as the values stay below 5.
Re: astonishing recurrence - Michael Kathke - 05-18-2013 Very interesting stuff to me. I've heard about in theory but never really touched it. These days I am diving into parallel-computing and CUDA it would help a lot.
The Wikipedia article about floating point has some useful links and google ;-) PS: Here is another one:
x(n+1) = n * x(n) - 1 with x(0) = e-1 <- this was wrong. Sorry! What's the limit? ;-)
Edited: 20 May 2013, 5:10 p.m. after one or more responses were posted
Re: astonishing recurrence - Paul Dale - 05-18-2013 It doesn't move away from 5 once the value is greater than 5. For many inputs e.g. 1 and 3, it moves away immediately. The solution at 5 has to be approached along a very specific path to be found and any deviation will result in the solution at 100. The initial values were carefully chosen to be on the path. Even if you are on the path to 5, convergence is slow. A slightly shorter program for this is:
001: LBL A However, it is missing the inspired use of oF->oC command.
Re: astonishing recurrence - Thomas Klemm - 05-18-2013 Compared to this? STO 0 You can get a good visualisation of the dynamic of this sequence if you combine two succesive elements to a vektor zn = [ xn, xn+1 ]. If you follow the example in Kahan's paper and calculate the eigenvalues of the Jacobian matrix of first partial derivatives of F at the fixed-point [5, 5], you'll get 20 and 3/5. The corresponding eigenvectors are [20, 1] and [3/5, 1]. The first defines the direction that is repellant while the second is attractive. From that graph it should be obvious that there is as well a sequence converging to 5 with values bigger than 5. You may start with [8, 6.125].
Cheers Edited: 18 May 2013, 8:53 a.m.
Re: astonishing recurrence - Thomas Klemm - 05-18-2013 Quote: It's geometric with the factor 3/5. What do you consider slow?
Kind regards Re: astonishing recurrence - Paul Dale - 05-18-2013 The convergence certainly isn't fast.
Re: astonishing recurrence - Thomas Klemm - 05-18-2013 From Gilles post for N = 100: Quote:WolframAlpha gives the following result: 4.9999999999999999999998693362... But since (3/5)55 < 10-12 I assume about 55 elements should be enough. I agree with you that it's not super fast but still much better than the brute force summation of 1/k2 in a recent thread. We could also use convergence acceleration to improve on the result.
Kind regards Re: astonishing recurrence - peacecalc - 05-18-2013 Hello Michael, there's no limit: the first values are:
n=0 e-1 and so on....where is the problem?
Greetings Re: astonishing recurrence - Dave Shaffer (Arizona) - 05-18-2013 Quote: I think you mean "cubic"
At least I wasn't solving these when I was in third grade!
Re: astonishing recurrence - Walter B - 05-18-2013
Quote:Just for curiosity: How'd you call an equation going up to x^4 ? And to x^5 ? Thanks in advance for enlightenment.
d:-?
Re: astonishing recurrence - Peter Murphy (Livermore) - 05-18-2013 Quartic; quintic.
Re: astonishing recurrence - Gerson W. Barbosa - 05-18-2013 Quote: Biquadratic, quartic. Quintic. I think the point here is the use of "grade" for "degree". The former shouldn't be wrong, but it appears the latter is more common in English. I don't know what it's like in German, but in Portuguese we have only one word for both words: grau. Interestingly ensino de terceiro grau means "college-level education". Also, colégio means "high-school", not college. These are often mistranslated. In this example, for instance, "And I only got a third grade education" has been translated as "E eu só tenho uma educação de terceiro grau" (And I have only a college-level education), which causes perplexity: "Isn't that enough?" (In this corner of the world, it still is :-). Regards,
Gerson.
Re: astonishing recurrence - Thomas Klemm - 05-18-2013 Quote:These are possible translations of the german word Grad (as suggested by dict.cc):
Thomas
Re: astonishing recurrence - Gerson W. Barbosa - 05-18-2013 Quote:Perhaps not a good example of compactness, but surely an example of unreadability, absolutely not necessary for the WP-34S :-) These kind of tricks were important on the HP-32SII, which had only 384 bytes of RAM. Program A is neither compact nor readable, but it is 4 bytes shorter than program B*. The results match Michael Kathke's ones for the HP-48SX, as we would expect:
A01 LBL A B01 LBL B * These can be further optmized, of course. We can save at least 5 bytes in program B, for example.
Edited: 18 May 2013, 4:26 p.m.
Re: astonishing recurrence - Michael Kathke - 05-18-2013 Quote: The 50g has an exact mode? Interesting. The only follow up to my 48SX was the 49g. I dislike the hardware, put him into the drawer and go back to my 48SX. ;-) Let's see what HP offers next. Today I stick the keyboard stickers to build up the WP 34S. Now I have to solder some things and so on...
Re: astonishing recurrence - Thomas Klemm - 05-18-2013 But using Free42 the sequence first approaches 0 but then all of sudden turns negative and seems to diverge.
Kind regards Re: astonishing recurrence - Gerson W. Barbosa - 05-18-2013 Quote:
Yes, and so does the 49g.
Re: astonishing recurrence - peacecalc - 05-19-2013 Hello Thomas,
now I understand (I hope), it is a problem of the calcs and not
Greetings Re: astonishing recurrence - 39gII chokes / 40GS succeeds (sort of) - BruceH - 05-19-2013 Quote:I tried this on the 39gII using the Sequence app. It choked. Seems to half-draw the screen and then hangs. I had to take the batteries out to recover. :-(
Trying the same using the 40GS it takes a few minutes to come up with "UNDEF" as the value of the 3rd item in the sequence. It then takes another few minutes to come up with "UNDEF" for item 4 and so on. :-)
A suggestion for TW:- the soft key menu when entering a formula should be: Re: astonishing recurrence - Thomas Klemm - 05-19-2013 I was lazy and just copied the definition of the sequence into WolframAlpha. But we can solve the problem without that. A nested series for e can be obtained by factoring out 1/n:
In this form it's obvious what the sequence does with e: The problem here is that we can't start with the exact value of e. Therefore I assume even the HP-50g in exact mode will run into problems. I'm not sure wether I understand your statement correctly but I think the problem is more of how we interpret the results of our calculators.
Kind regards Re: astonishing recurrence - peacecalc - 05-19-2013 Hello Thomas, I'm not quite sure if we are talking about the same problem, I refer to
x(0) = e - 1 in the original post #30 from Michael Kathke (with correction). In my opinion this recurrence can be written in a closed forn as: X(N+1) = - SUMME(J;1;N;GAMMA(N)/GAMMA(N-J+1)); It reproduces the values I gave above, and there is no limit because every term of the sum is greater 1 and for N to infinity you get a lot of summands. The starting value is irrelevant because, if you calculate X(1) the starting value is multiplied with zero. Please give me a hint, where my misunderstanding is?
Greetings Re: astonishing recurrence - Thomas Klemm - 05-19-2013 I'd like to rewrite Michael Kathke's first (wrong) definition of the sequence by replacing n by n-1: x(0) = e-1
Your listing of the sequence is correct. WolframAlpha gave me a closed formula for your expression: - SUM[GAMMA(N)/GAMMA(N-J+1),{J,1,N}] =Only with this formula I was able to create a table: Table[-(e Gamma(n+1, 1)-1)/n, {n, 1, 6}]This agrees with your result: {-1, -2, -5, -16, -65, -326} This is the definition of the sequence after the correction: x(0) = e - 1Can you spot the difference? The factor is now n instead of (n-1). This sequence has limit 0.
Hopefully I could clarify things a little. Re: astonishing recurrence - 39gII chokes / 40GS succeeds (sort of) - Thomas Klemm - 05-19-2013 Apparently the 39gII is not among my favorite calculators and probably never will be. Seriously, are these calculators only capable to solve simple problems that are expected in the context of education? IMHO that sounds really bad.
Kind regards Re: astonishing recurrence - 39gII chokes / 40GS succeeds (sort of) - Walter B - 05-20-2013 Bruce, What happened to your calculator? The lower right part of it on your picture looks quite bent :-( Or is it the camera? @Thomas: I'd vote for "obviously" instead of "apparently".
d;-?
Re: astonishing recurrence - peacecalc - 05-20-2013 Hello Thomas, thank you very much for sharing your knowledge and time with me. Now I can see clearly now (@Johnny Nash ;-)). It's my mistake to suppose that n can be zero (which isn't possible, because the first element should be then X_(-1) and not X_0). Oh boy, I should first read exactly before I'm steeling other persons time and further investments.
Greetings Edited: 20 May 2013, 4:11 a.m.
Re: astonishing recurrence - Gilles Carpentier - 05-20-2013 The 49G+ and 50G hardware is far better than the 49G (keyboard, screen speed etc.) The 49G hardware was ...:(
When I try sometimes tu use my old 48SX I love the keyboard touch (but not the agencement except the big ENTER), but it's so slow and the screen is poor... Edited: 20 May 2013, 6:59 a.m.
Re: astonishing recurrence - 39gII chokes / 40GS succeeds (sort of) - Gilles Carpentier - 05-20-2013 Here is what I get with my 39GII and how to to 1/push APPS and choose 'Suite' (in french) 2/ Enter :
3/ Push PLOT if you want to see the graph :
4/ Push NUM if you want to see the value
I think it's well done but it is not stable and I also experimented some bad crashs both on real calc and emulator... As you can see, the numeric output is quite the same than many others HP Calcs
Edited: 20 May 2013, 8:14 a.m.
Re: astonishing recurrence - 39gII chokes / 40GS succeeds (sort of) - Gilles Carpentier - 05-20-2013 Hi Bruce ! Your HP39GII don't have to crash with this but there is a bug that I saw in the picture ... U2(N)=...U2(N)...
You may use
else you have a kind of recursive call without any exit and the 39GII crash... Edited: 20 May 2013, 10:39 a.m.
Re: astonishing recurrence - 39gII chokes / 40GS succeeds (sort of) - BruceH - 05-20-2013 Hi Gilles, You are exactly right - I entered the expression wrongly. (D'oh). Once corrected, the physical calc gives the same results you posted from the emulator. However, this episode has revealed a bug: the 40GS results that I quoted were also with the wrong expression - so the older model is able to cope with a recursive use of 'U1(N)' without crashing or hanging. It also allows me to interrupt the slow calculation with On+F3 which I couldn't get to work on the 39gII.
So, I withdraw my previous suggestion to Tim around changing the "N" menu item to "(N)" (as that simply encourages idiots like me to make make idiotic mistakes) ;-) and instead suggest that any entered expression be parsed for 'U1(N)' and a warning displayed if present.
Re: astonishing recurrence - 39gII chokes / 40GS succeeds (sort of) - BruceH - 05-20-2013 It's just lens distortion. I tried to take the picture from a more overhead position but just got a reflection of the camera in the screen.
Re: astonishing recurrence - 39gII chokes / 40GS succeeds (sort of) - bhtooefr - 05-20-2013 Or just add support to break from a recursion loop (or any other situation that crashes the calc).
(I wasn't able to break from an intentional recursion loop on the emulator, and it was FAR from running out of memory.)
Re: astonishing recurrence - Michael Kathke - 05-20-2013 Yes, that's right. Thank you for the clarification and sorry for the little mess ;-).
Re: astonishing recurrence - peacecalc - 05-21-2013 Hello Thomas, I only like to report that you are right with your statement: "The problem here is that we can't start with the exact value of e. Therefore I assume even the HP-50g in exact mode will run into problems." As long as you don't leave the exakt modus, the terms of recurrence are calculated right (output in the form: A*e - B, A and B are integers). One gets false values (after the twelfth step) if one puts ->NUM on the whole difference. If you type: A*e ->NUM B ->NUM - you get certainly the right answer: 0,0000.
Greetings
Re: astonishing recurrence - David Maier - 05-22-2013 The TI-Nspire CAS goes off the rails fairly quickly in approximate mode. It does have a handy function for generating sequences, however.
Approximate: seqGen(108-((815-((1500)/(u(n-2))))/(u(n-1))),n,u,{2,20},{4,4.25})Exact: (seqGen(108-((815-((1500)/(u(n-2))))/(u(n-1))),n,u,{2,70},{4,((17)/(4))}))->Decimal Approximate Exact Re: astonishing recurrence - Thomas Klemm - 05-22-2013 Is it possible to define a sequence based on an other sequence? So could you define a sequence a(n) that uses u(n), u(n+1) and u(n+2) in the definition? Because then you could use Aitken's delta-squared process to get a sequence that converges much faster:
Kind regards
PS: You really have to enter ((17)/(4)) to make it exact? That's a strange syntax.
Re: astonishing recurrence - David Maier - 05-24-2013 It does look like Aitken's process will converge much more quickly. (I used, in this case, the spreadsheet feature, rather than nested sequences.) The results are:
Exact AitkenUnfortunately, TI makes extracting your work pretty painful, including, it appears, adding some unnecessary parentheses. This, unfortunately, turned 17/4 into (17)/(4). Re: astonishing recurrence - Thomas Klemm - 05-24-2013 Thanks for taking the time to create the table, the more so as it was a pain to extract the data from the calculator.
Cheers Re: astonishing recurrence - David Maier - 05-27-2013 Can Aitken's process save the WP-34S in double precision mode? Double Precision Aitken Re: astonishing recurrence - Thomas Klemm - 05-27-2013 The result doesn't really surprise as the difference from the correct sequence is multiplied by 100 with each step. So if the base sequence deviates from the correct solution the accelerated sequence can't do much about it. Let's assume that the sequence is: xn = a + c qn with |q| < 1. Then the limit is certainly a as n goes to infinity. When Aitken's process is applied to that sequence we get the correct limit a with the first step using just the first three elements of the original sequence:x0, x1 and x2. Now our correct sequence is something like: xn = a + c 1 q1n + c2 q2n, with q1 = 3/5, q2 = 100 and c2 = 0. Due to rounding errors the second factor c2 isn't 0 anymore but a very small number. However this term gets blown up as n grows. When it gets dominant the Aitken's process uses this factor q2 = 100 instead of q1 = 3/5 to guess the limit. That's why we can observe an acceleration of the convergence to the limit 100 after x27.
Cheers |