TI-60: Triangle Numbers
|
12-16-2018, 03:35 AM
Post: #1
|
|||
|
|||
TI-60: Triangle Numbers
Here I exploit TI-60's RST function's ability to continue program execution and using the square root function as a "tester" to calculate triangle numbers.
Instructions: 1. In RUN mode (outside of LRN), store the following values: R0 = 0 R1 = n 2. Execute the program by pressing [RST], [R/S]. The program is done when you see "Error". 3. Clear the error by pressing [CE/C]. 4. Recall R0. This is your triangle number. (R1 will have -1). TI-60 Program: Triangle Numbers Code:
Link to blog post: https://edspi31415.blogspot.com/2018/12/...mbers.html |
|||
12-16-2018, 05:33 PM
Post: #2
|
|||
|
|||
RE: TI-60: Triangle Numbers
(12-16-2018 03:35 AM)Eddie W. Shore Wrote: Here I exploit TI-60's RST function's ability to continue program execution and using the square root function as a "tester" to calculate triangle numbers. This is essentially a "proof of concept" on how to do loops on a calculator with an extremely limited function set without tests and goto – rskey.org calls the TI-60 "almost programmable". ;-) In real life, if you want the sum of all integers from 1 to n you'd of course use the direct formula ½n(n+1) or ½(n²+n). Less steps, direct result. Dieter |
|||
12-16-2018, 07:08 PM
Post: #3
|
|||
|
|||
RE: TI-60: Triangle Numbers
(12-16-2018 03:35 AM)Eddie W. Shore Wrote: Here I exploit TI-60's RST function's ability to continue program execution Such a pain in the rear end that the TI-56 (and presumably the TI-55III) halt execution before resetting the program counter making it impossible to program loops of any kind! Even the prehistoric TI-53 does it "right" |
|||
12-16-2018, 09:56 PM
Post: #4
|
|||
|
|||
RE: TI-60: Triangle Numbers
(12-16-2018 05:33 PM)Dieter Wrote: In real life, if you want the sum of all integers from 1 to n you'd of course use the direct formula ½n(n+1) or ½(n²+n). Less steps, direct result. The TI-60 provides an nCr key with a bit weird usage: Quote:The values of n and r are entered as n.rrr. Thus we could use: Code: + Cheers Thomas |
|||
12-17-2018, 02:55 PM
(This post was last modified: 12-17-2018 02:56 PM by ijabbott.)
Post: #5
|
|||
|
|||
RE: TI-60: Triangle Numbers
(12-16-2018 09:56 PM)Thomas Klemm Wrote:(12-16-2018 05:33 PM)Dieter Wrote: In real life, if you want the sum of all integers from 1 to n you'd of course use the direct formula ½n(n+1) or ½(n²+n). Less steps, direct result. Using the formula saves a couple of program steps (assuming there are no pending operations before running the program): Code: + — Ian Abbott |
|||
12-19-2018, 04:23 AM
Post: #6
|
|||
|
|||
RE: TI-60: Triangle Numbers
(12-16-2018 05:33 PM)Dieter Wrote: This is essentially a "proof of concept" on how to do loops on a calculator with an extremely limited function set without tests and goto We could exploit the integration key and do some calculations in a loop as a side effect. This allows to implement a solver using fixed point iteration or Newton's method. However you could specify only up to 99 loops. To solve Kepler's equation: \( M = E - e \sin E \) We would rewrite it as a fixed point equation: \( E = M + e \sin E \) Using the following mapping to the data memories: E: 3 M: 4 e: 5 We could then use this program: Code: RCL 4 We don't really care about the lower and upper limits of the interval so we could just use: 0 STO 1 1 STO 2 The integration would be started with: ∫dx nn R/S The result could then be found in register 3. Using realistic values (e.g. e = 0.0167 for the Earth) this needs only a few iterations. Don't forget to put the calculator into the radian mode. Cheers Thomas |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)