(50g) Numeric List Commands

01162019, 11:24 PM
(This post was last modified: 01162019 11:28 PM by John Keith.)
Post: #1




(50g) Numeric List Commands
The following are RPL implementations of some commands from the Wolfram Language (aka Mathematica) that I find useful. Both programs require the ListExt Library.
The first command generates a list of integers based on the linear recurrence of the integer sequence. It is similar to the Wolfram Language command LinearRecurrence except that the order of the lists is reversed. Level 3 should contain a list of the initial terms of the sequence. Level 2 should contain a list of coefficients. Level 1 should contain an integer representing the number of terms to be generated. The list on level 2 cannot be longer than the list on level 3. Code:
For example, if level 3 contains the list { 0 1 }, level 2 contains the list { 1 1 }, and level 1 the number 10, the program will return the first 10 Fibonacci numbers. While not as fast as an efficient program for computing e.g. Fibonacci numbers, this program makes it easy to explore a wide variety of integer sequences. Many examples can be found here. The next program performs convolution of lists. It is similar to the Wolfram Language command ListConvolve but again the order of the lists is reversed. The input list should be on level 2, and the kernel on level one. Convolution in this sense is related to the dot product of vectors except that the two lists do not have to be the same length. Code:


01292019, 07:13 PM
(This post was last modified: 01292019 07:14 PM by John Keith.)
Post: #2




RE: (50g) Numeric List Commands
Here is another list convolution program. It takes two lists (which must be the same length) and returns a list of convolutions of increasing subsets of the input lists.
The program will run on the HP48G if UNROT is replaced with ROT ROT. The 0 + in the program is necessary because \GSLIST will error with a list size of 1. Code:
An example from http://oeis.org/A000330: Code:


05182019, 09:26 PM
Post: #3




RE: (50g) Numeric List Commands
Updating this thread to add a program for deconvolution. Given a list on level 2 that is the (suspected) result of the convolution of two lists, and a "test" list on level 1, the program will return the list which must be convolved with the level 1 list to produce the level 2 list.
Note that unlike convolution, deconvolution is sensitive to the order of the lists. If the stack order of the lists is reversed, the program will return nonsense results. Also, the lengths of the two lists must be the same. As an example, in level 2, { 1 6 20 50 105 196 336 } which are the 4dimensional pyramidal numbers and on level 1, { 1 3 5 7 9 11 13 }  the odd numbers. The program returns { 1 3 6 10 15 21 28 }  the triangular numbers. Code:
For HP48G compatibility, replace UNROT with ROT ROT and replace PICK3 with 3 PICK. 

« Next Oldest  Next Newest »

User(s) browsing this thread: 1 Guest(s)