HP Forums
Rational Binomial Coefficients - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: HP Prime Software Library (/forum-15.html)
+--- Thread: Rational Binomial Coefficients (/thread-12074.html)



Rational Binomial Coefficients - Eddie W. Shore - 01-03-2019 05:52 AM

Introduction

Let p be a rational fraction, p = num/dem. The rational binomial coefficients of order n are defined by:

B_0(p) = 1

B_n(p) = COMB(p, n) = ( p * (p - 1) * (p - 2) * (p - 3) * ... * (p - n + 1) ) / n!

There are algorithms, but the program RATBIN uses the definition.

HP Prime Program RATBIN

Arguments: rational fraction, order
Code:

EXPORT RATBIN(p,n)
BEGIN
// 2018-12-26 EWS
// p-q, n
// Rational Binomial Coefficient
LOCAL X;
IF n==0 THEN
RETURN 1;
ELSE
IF n==1 THEN
RETURN p;
ELSE
RETURN QPI(ΠLIST(p-MAKELIST(X,X,0,n-1))/n!);
END;
END;
END;

* Note: the result is not always a fraction, but you can convert the answer to fraction by pressing [ a b/c ]

Blog Link: https://edspi31415.blogspot.com/2019/01/hp-prime-and-casio-fx-5800p-rational.html

Examples:

b_2(1/2) = -1/8

b_3(1/2) = 1/16

b_4(1/2) = -5/128

b_5(1/2) = 7/256

Source:

Henrici, Peter. Computational Analysis With the HP-25 Calculator A Wiley-Interscience Publication. John Wiley & Sons: New York 1977 . ISBN 0-471-02938-6


RE: Rational Binomial Coefficients - Thomas Klemm - 01-03-2019 08:05 AM

(01-03-2019 05:52 AM)Eddie W. Shore Wrote:  There are algorithms, but the program RATBIN uses the definition.

With the HP-15C we can use:

\(\binom{p}{n}=\frac{p!}{n!(p-n)!}\)

Code:
001-    42 0    x!
002-      34    x<>y
003-   43 36    LSTx
004-      34    x<>y
005-    42 0    x!
006-      34    x<>y
007-   43 36    LSTx
008-      30    -
009-    42 0    x!
010-      20    ×
011-      10    ÷

Examples:

2 ENTER 0.5 R/S
-0.1250

3 ENTER 0.5 R/S
0.0625

4 ENTER 0.5 R/S
-0.0391

5 ENTER 0.5 R/S
0.0273

Cheers
Thomas