Post Reply 
(HP49/50) Laguerre Polynomials
02-22-2020, 06:02 PM
Post: #1
(HP49/50) Laguerre Polynomials
The following program returns the value of the nth Laguerre polynomial L_n(x) at x. To use the program, n (which must be an integer) should be on level 2, and x should be on level 1. If x is an integer, the result will be an integer or a rational number.

The formula given on the Wikipedia page is very slow to compute in practice because many intermediate terms have non-integer values. Instead the coefficients of the nth polynomial are computed and fed to the built-in PEVAL command which is quite fast.

Code:

\<< SWAP I\->R \-> x n
  \<<
    IF n 1. >
    THEN { 1 -1 } 2. n
      FOR k 0 SWAP + 0 + 2.
        \<< k NSUB + 1. - R\->I * SWAP -
        \>> DOSUBS
      NEXT DUP HEAD SWAP REVLIST AXL x PEVAL SWAP /
    ELSE n 1. SAME { x NEG 1 + } { 1 } IFTE
    END
  \>>
\>>
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(HP49/50) Laguerre Polynomials - John Keith - 02-22-2020 06:02 PM



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