# http://www.ex-parrot.com/~tom/calcs/calcs/encyc/progs/src/patfind.ctf # ======================================================================== # Program name: Polynomial Pattern Finder # # Version: 1.0 # Author: Tom Lynn # Date: 1994-7 # Models: 9700, 9800 # # # Description: # # Polynomial pattern finder, based on Babbage's Difference Engine. # Enter a sequence of numbers, and it outputs the equation which # generated the sequence, and the projected continuation. # e.g. 1,4,9,16 gives x^2, continuing 25, 36, etc. # # Originally written for the 7000, this version has been padded out # a little for clarity. # @@ Program "~PATFIND" " Pattern Finder" " " "Enter terms:" Mcl Defm 11 '11 MIN 1->B ?->L Lbl 7 Isz B ?->K[B] Lbl 0 1->C B->D Lbl 1 C=B-1=>Goto 7 1->E Lbl 2 F[6C+E]-E[6C+E]->K[6C+E] Isz E EGoto 2 Dsz D 1->E 1->A Lbl 3 E=D=>Goto 4 K[6C+E]->J L[6C+E]->K Abs (Int 1\exp9J-Int 1\exp9K>2)=>0->A 0->K Isz E Goto 3 Lbl 4 A=0=>Isz C A=0=>Goto 1 L[6C]/C!->E[C] 1->E Lbl 5 K[E]-E[C]*E^C->K[E] Isz E E<=B=>Goto 5 1->E Lbl 6 0->K Isz E K[E]->K J[E]->J Abs (Int 1\exp9J-Int 1\exp9K<=2)=>9!->K K=9!=>EGoto 6 E<>B=>Goto 0 I=0=>Goto A I_ " n^4" Lbl A H=0=>Goto B H_ " n^3" Lbl B G=0=>Goto C G_ " n\sqr" Lbl C F=0=>Goto D F_ " n" Lbl D Int 1\exp10L<>0=>L_ " " "Pattern continues:" Lbl 9 Isz B L+FB+GB\sqr+HB^3+IB^4_ Goto 9 # ======================================================================== # CTF compliant. See http://www.york.ac.uk/~tw104/casio/ for details. # # More programs and information at: # http://www.ex-parrot.com/~tom/calcs/calcs/encyc/ # # This file last compiled: Friday, 30 April, 1999 # ========================================================================