Mini-challenge: Fast F(93) on HP-16C
|
08-08-2023, 07:15 AM
Post: #10
|
|||
|
|||
RE: Mini-challenge: Fast F(93) on HP-16C
I realised I wasn't making use of R3 (which was keeping track of the current point in the sequence) so here's a version without that (shaving another second off the time for F(93):
Code: 001 LBL A For an explanation: 001-014 filters out special cases. If we get past there, then n is in the range 2-93. 015-025 set up initial values: R0 = n R1 = F(0) R2 = F(1) R4 = 128 026-033 uses R4 to find the largest power of 2 less than n. This will determine how many loops to run. If the result is 2^k then we will do k loops. 034-037, 066-070 are the loop control. We shift R4 right each loop and stop when we get to 0. At this point, each loop starts with: R1 = F(k) R2 = F(k+1) 038-044 calculates (2F(k+1) - F(k)) x F(k) [= F(2k)] 045-052 calculates F(k)^2 + F(k+1)^2 [= F(2k+1)] 055-059 checks if this loop was for an odd number in generating n. If so, then: 060-065 we bump up one by setting R1,R2 = (R2, R1+R2) 071-073 once the loop has finished, R1 has the final result. I guess squaring could have been done as [RCL 1, ENTER, x], etc, but I felt that [RCL 1, RCL 1, x] is more obvious and I expect they take the same time and certainly use the same number of steps. |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Mini-challenge: Fast F(93) on HP-16C - Joe Horn - 08-06-2023, 05:35 PM
RE: Mini-challenge: Fast F(93) on HP-16C - ThomasF - 08-06-2023, 08:24 PM
RE: Mini-challenge: Fast F(93) on HP-16C - SlideRule - 08-07-2023, 02:21 AM
RE: Mini-challenge: Fast F(93) on HP-16C - ThomasF - 08-07-2023, 06:04 AM
RE: Mini-challenge: Fast F(93) on HP-16C - Joe Horn - 08-07-2023, 07:52 AM
RE: Mini-challenge: Fast F(93) on HP-16C - ThomasF - 08-07-2023, 07:59 AM
RE: Mini-challenge: Fast F(93) on HP-16C - Joe Horn - 08-07-2023, 08:15 AM
RE: Mini-challenge: Fast F(93) on HP-16C - Voldemar - 08-07-2023, 09:50 AM
RE: Mini-challenge: Fast F(93) on HP-16C - MarkB - 08-07-2023, 11:48 AM
RE: Mini-challenge: Fast F(93) on HP-16C - MarkB - 08-08-2023 07:15 AM
RE: Mini-challenge: Fast F(93) on HP-16C - Joe Horn - 08-08-2023, 07:59 AM
|
User(s) browsing this thread: 1 Guest(s)