Post Reply 
DB48X: HP48-like RPL implementation for DM42
Yesterday, 11:18 PM
Post: #499
RE: DB48X: HP48-like RPL implementation for DM42
(Yesterday 05:05 PM)n1msr Wrote:  It becomes important when the Comb[inations] function is used (…)

I just cobbled together this program for the HP-15C to calculate:

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

Code:
   001 {    44  0 } STO 0
   002 {    42  0 } f x!
   003 {       34 } X<=>Y
   004 {    42  0 } f x!
   005 {    43 36 } g LSTx
   006 { 45 30  0 } RCL - 0
   007 {    42  0 } f x!
   008 {       10 } /
   009 {       34 } X<=>Y
   010 {       10 } /

Example

5 ENTER 3
R/S

10.0000

Nothing to see here. That's what we expected.
But it also allows us to calculate values of \(\binom{0.5}{k}\) for consecutive \(k\).

Examples

0.5 ENTER 0
R/S

1.0000

0.5 ENTER 1
R/S

0.5000

0.5 ENTER 2
R/S

-0.1250

0.5 ENTER 3
R/S

0.0625

0.5 ENTER 4
R/S

-0.039062500

0.5 ENTER 5
R/S

0.027343750

0.5 ENTER 6
R/S

-0.020507813

Compare this to the Taylor series of:

\(
\begin{align}
\sqrt{1+x}
&= (1+x)^{\frac{1}{2}} \\
&= 1+\frac{x}{2}-\frac{x^2}{8}+\frac{x^3}{16}-\frac{5x^4}{128}+\frac{7x^5}{256}-\frac{21x^6}{1024}+\cdots
\end{align}
\)

As we can see in this example, there are good reasons to allow non-integer values in binomial coefficients.



Hint: Don't try this with an HP 20b.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
DB48X v0.4.8 is out - c3d - 10-22-2023, 11:31 PM
Release v0.5.0: Statistics and flags - c3d - 11-20-2023, 08:57 AM
v0.6.5: Minor bug fixes - c3d - 02-11-2024, 11:23 PM
Release 0.7.1 "Whip" - Bug fixes - c3d - 03-04-2024, 12:46 AM
DB48X v0.7.4 release is out - c3d - 04-14-2024, 03:05 PM
DB48X v0.7.6: Solving menu - c3d - 05-13-2024, 12:04 AM
DB48X v0.7.7: Units in solver - c3d - 06-02-2024, 11:36 PM
v0.7.10 - Interactive stack - c3d - 07-14-2024, 11:31 PM
DB48X v0.7.13 is out - c3d - 08-05-2024, 07:31 AM
DB48X v0.7.15 - c3d - 08-25-2024, 08:45 PM
DB48X v0.7.16 - c3d - 09-02-2024, 01:36 AM
DOSUBS command - grbrum - 09-04-2024, 03:37 PM
v0.7.18 - APPLY, SUBST, WHERE - c3d - 09-15-2024, 11:58 PM
Program Editing Question - spiff72 - 09-16-2024, 03:27 PM
press 2 simultaneous buttons? - grbrum - 09-30-2024, 09:01 PM
CST Custom Menu - grbrum - 10-04-2024, 05:00 AM
v0.8.2: Assignments, Custom menu - c3d - 10-21-2024, 05:49 AM
CST - grbrum - 11-05-2024, 08:07 PM
Stuttgart video - c3d - 11-07-2024, 08:22 PM
Long Name Menus - usability - grbrum - 11-08-2024, 07:47 PM
Release v0.8.5: Keyboard fixes - c3d - 11-12-2024, 01:05 AM
CONVERT bug - grbrum - 11-12-2024, 07:44 PM
Christmas wishlist is open - c3d - 12-02-2024, 07:09 PM
DB48X/50X CATALOG 'behaviour' - n1msr - 12-03-2024, 10:24 AM
DB48x v0.8.8 - Power usage reduction - c3d - 12-08-2024, 11:40 PM
RE: DB48X: HP48-like RPL implementation for DM42 - Thomas Klemm - Yesterday 11:18 PM



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