What comes next?
|
10-19-2024, 12:03 AM
Post: #41
|
|||
|
|||
RE: What comes next?
Yes, I think so.
At least the following works with the HP-48: Code: DIR |
|||
10-19-2024, 12:03 AM
(This post was last modified: 10-19-2024 12:10 AM by FLISZT.)
Post: #42
|
|||
|
|||
RE: What comes next?
(10-18-2024 10:49 PM)Gil Wrote: Is really the above code complete as lastly written by Gilles? Yes, it does (tested with the list given above). As I don't have newRPL, I simply replaced RHEAD with Last from the GoferList library. Edit: I replaced + by ADD too. Several answers at the same time! Bruno Sanyo CZ-0124 ⋅ TI-57 ⋅ HP-15C ⋅ Canon X-07 + XP-140 Monitor Card ⋅ HP-41CX ⋅ HP-28S ⋅ HP-50G ⋅ HP-50G |
|||
10-19-2024, 12:17 AM
Post: #43
|
|||
|
|||
RE: What comes next?
Also the following works:
Code: \<< DUP LST SWAP \GDLIST DUP SIZE 1 > :: NEXT? IFT ADD |
|||
10-19-2024, 01:00 AM
Post: #44
|
|||
|
|||
RE: What comes next?
I changed the + sign at the end with ADD and it works perfectly now.
Thanks |
|||
10-19-2024, 01:29 AM
Post: #45
|
|||
|
|||
RE: What comes next?
(10-15-2024 01:34 PM)Gil Wrote: what is the code algorithm you used in your first post to get the binomial coefficient ? We don't need binomial coefficients for next number. Operator E, Ek f = f(x+k) Operator ∇, ∇ f = f(x) - f(x-1) = (1 - E-1) f ∇ = 1 - E-1 E = 1/(1-∇) = 1 + ∇ + ∇² + ∇³ + ... If we do polynomial fit, next number is simply sum of all the backward differences. This is why sum of below red numbers gives next number. (10-08-2024 02:31 PM)Thomas Klemm Wrote: Instead of the red numbers of Post #7 the following red numbers are stored: Only if we want a general formula, binomial coefficients is needed. E^n = (1-∇)^-n = 1 + comb(n,1) ∇ + comb(n+1,2) ∇² + comb(n+2,3) ∇³ + ... Example, from red numbers, to get next of next number --> n=2 20 + comb(2,1)*10 + comb(3,2)*4 + comb(4,3)*1 = 20 + 2*10 + 3*4 + 4*1 = 56 |
|||
10-19-2024, 08:12 AM
Post: #46
|
|||
|
|||
RE: What comes next?
Now this is a bit off topic, but the same method can be used to calculate square roots.
To calculate \(\sqrt{a}\), we use NEXT to calculate consecutive values of \(f(x)=x^2-a\). Once we overshoot, we go BACK one step, ZOOM in and rinse and repeat. This is the digit by digit method being used in most HP calculators. This program is for the HP-42S: Code: 00 { 129-Byte Prgm } Example 41 XEQ "ROOT" 6.40312423743(05) But this can also be done manually: 41 XEQ "INIT" XEQ "NEXT" -20 XEQ "NEXT" -18.5 XEQ "NEXT" -16 XEQ "NEXT" -12.5 XEQ "NEXT" -8 XEQ "NEXT" -2.5 XEQ "NEXT" 4 XEQ "BACK" -2.5 XEQ "ZOOM" (…) |
|||
10-19-2024, 06:08 PM
(This post was last modified: 10-19-2024 06:10 PM by Gil.)
Post: #47
|
|||
|
|||
RE: What comes next?
Binomial Coefficient in x
Nice to get the next number and, as does my program, an underlying polynomial as shown in post 20. |
|||
10-19-2024, 09:09 PM
Post: #48
|
|||
|
|||
RE: What comes next?
(10-19-2024 08:12 AM)Thomas Klemm Wrote: Now this is a bit off topic, but the same method can be used to calculate square roots. Just to clear up confusion, f(x) = k*(x^2-a), where k start at 0.5, scale-up by 10 for each correct x digit. Initially, f = 0.5*(x^2-a), ∇f = x-0.5, ∇²f = 1 This is the reason for INIT setup, at x=0: M03 = f = -0.5*a M02 = ∇f = -0.5 M01 = ∇²f = 1 Example, if we do √41 manually, digit by digit, we have: f(x=6) = 0.5*(6^2 - 41) = -0.5*41 + 0.5 + 1.5 + 2.5 + 3.5 + 4.5 + 5.5 = -2.5 f(x=6.4) = 5*(6.4^2 - 41) = -25 + 6.05 + 6.15 + 6.25 + 6.35 = -0.2 f(x=6.40) = 50*(6.40^2 - 41) = -2 f(x=6.403) = 500*(6.403^2 - 41) = -20 + 6.4005 + 6.4015 + 6.4025 = -0.7955 ... This is similar to HP calculator, but not quite. Calculator sqrt algorithm scale F by 100 for each correct digit, to keep ∇²F = 1, all the time. F(X=6) = -2.5 F(X=64) = -250 + 60.5 + 61.5 + 62.5 + 63.5 = -2 F(X=640) = -200 F(X=6403) = -20000 + 6400.5 + 6401.5 + 6402.5 = -795.5 ... https://www.hpmuseum.org/forum/thread-17...#pid152220 |
|||
10-19-2024, 11:25 PM
Post: #49
|
|||
|
|||
RE: What comes next?
A few links related to calculating the square root in HP calculators:
I find it interesting that with the correct setup the main loop is just these instructions: Code: 501 L01250: .1111...1. sqt15: c + 1 -> c[p] |
|||
10-20-2024, 08:44 PM
Post: #50
|
|||
|
|||
RE: What comes next?
(10-19-2024 09:09 PM)Albert Chan Wrote: Calculator sqrt algorithm scale F by 100 for each correct digit, to keep ∇²F = 1, all the time. For each digit, we can stop if (F + ∇F + ∇²F) > 0, eliminate routine BACK Stack Y = (-F) = -K*(x^2 - a) Stack X = (∇F + ∇²F) = K*((2x-1) + 2) = K*(2x+1) = ΔF Stop routine NEXT if stack X > Y Initial setup, K=0.5, x=0 --> Stack Y, X = a/2, 1/2 Code: 00 { 100-Byte Prgm } 41 XEQ "ROOT" → 6.40312423743 Here, we do √41 manually, digit by digit. Code: 41 |
|||
10-20-2024, 09:39 PM
(This post was last modified: 10-20-2024 09:43 PM by Thomas Klemm.)
Post: #51
|
|||
|
|||
RE: What comes next?
(10-19-2024 11:25 PM)Thomas Klemm Wrote: Compare this to the corresponding code of the TI-57: Code: 0x0655: 0x0381 LOAD C,C-A,000F FFFF FFFF FFFF Two subtractions instead of one and then another one to check the carry. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 9 Guest(s)