(49g 50g) EXP, LOG and Multinomial Transforms
11-27-2019, 09:54 PM
Post: #1 John Keith Senior Member Posts: 492 Joined: Dec 2013
(49g 50g) EXP, LOG and Multinomial Transforms
These four programs compute the EXP (exponential), LOG (logarithmic), MNL (multinomial) and IML (inverse multinomial) transforms of number sequences. Definitions and examples can be found at A274804, A274805, A274760 and A274844.

These programs require the GoferLists and ListExt libraries. They are listed here as a directory (DIR) object for convenience and because IMLXF calls LOGXF. The two pairs of transforms (EXP and LOG), (MNL and IML) are inverses, meaning that if a sequence is transformed by first one transform then the other, the original sequence will return.

The transforms listed here may return (non-integer) rational numbers as terms, and all four programs will accept lists with rational number terms. That is the reason for the EVALs in each program.

Code:
 DIR   EXPXF   \<< DUP SIZE R\->I \-> b n     \<< b 1. 1. SUB { 1 } 2 n       FOR k 0 + :: + DOSUBS DUP2 * b 1 k SUB LPOPR UNROT REV * LSUM + EVAL ROT SWAP + SWAP 1 SWAP +       NEXT DROP     \>>   \>>   LOGXF   \<< DUP SIZE R\->I \-> b n     \<< b 1. 1. SUB { } 2 n       FOR k 1 SWAP + 1 + :: + DOSUBS DUP2 * b 1 k SUB LPOPR UNROT REV * k 1 - LSEQ * LSUM k / - EVAL ROT SWAP + SWAP       NEXT DROP     \>>   \>>   MNLXF   \<< DUP SIZE R\->I \-> b n     \<< n 1 - LSEQ 1 :: * Scanl b 1. 1. SUB 1 n       FOR k OVER 1 k SUB REV DUP HEAD NEWOB SWAP / b 1 k SUB * OVER REV * LSUM EVAL +       NEXT NIP TAIL     \>>   \>>   IMLXF   \<< LOGXF DUP SIZE 1. - R\->I LSEQ 1 :: * Scanl 2.     \<< / EVAL     \>> DOLIST   \>> END
 « Next Oldest | Next Newest »

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