Post Reply 
(48G/50g) Binomial Transform, Difference Table
05-27-2019, 09:07 PM (This post was last modified: 10-19-2024 01:20 PM by John Keith.)
Post: #8
RE: (48G/50g) Binomial Transform, Difference Table
Following on from the last two posts, a much faster binomial transform program for sequences defined by simple polynomials. Sequences defined by an nth degree polynomial are binomial transforms of a sequence beginning with n+1 terms followed by an arbitrary number of zeros. For instance, A000292, the tetrahedral numbers, is the binomial transform of { 1 3 3 1 0 0 0... }.

The following program requires a list of the non-zero terms on level 2 and a number on level 1 which is the number of terms to return. The list on level 2 must have at least two terms. For example, with { 1 3 3 1 } on level 2 and 12 on level 1, the program will return a list of the first 12 tetrahedral numbers.

Code:

\<< OVER SIZE 2. - \-> n s
  \<< EVAL n LASEQ
    IF s
    THEN 1. s
      START SWAP :: + LSCAN
      NEXT
    END
  \>>
\>>

This program is HP 50g only since it uses commands from the ListExt Library

The following version is compatible with the HP-48G. It is longer and slower than the HP 50 version but still reasonably fast. The list on level 2 must have at least two terms.

Code:

\<< OVER SIZE 2 - ROT OBJ\->
  2 + ROLL LASTARG ROLL \-> m n s
  \<< n m * OVER + 1 -
    FOR j j m
    STEP n \->LIST
    IF s
    THEN 1 s
      START 1
        \<< OVER +
        \>> DOSUBS +
      NEXT
    END
  \>>

Edited to remove reference to GoferLists and replace GoferLists functions with those from ListExt.
Edited to improve the above programs.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: (48G/50g) Binomial Transform, Difference Table - John Keith - 05-27-2019 09:07 PM



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