Post Reply 
Double factorial [wp34s]
02-12-2016, 02:21 PM (This post was last modified: 02-12-2016 02:24 PM by Gerson W. Barbosa.)
Post: #6
RE: Double factorial [wp34s]
(02-12-2016 07:49 AM)Dieter Wrote:  
(02-12-2016 06:27 AM)Paul Dale Wrote:  cos(pi x) can be replaced by (-1)^x which should save a few steps at the start and be faster and more accurate.

Let's not forget CNST, a handy command that IMHO is overlooked too often. CNST 86 is pi/2, and after rearranging the x!! formula to...

\(x!!=2^{\frac{x}{2}}\cdot\left(\frac{\pi}{2}\right)^{\frac{\cos \left ( \pi x \right )-1}{4}}\cdot \left(\frac{x}{2}\right)!\)

...the A program gets quite a bit shorter:

Code:
LBL A
CNST 86
RCL Y
(-1)^x
DEC X
#004
/
y^x
#1/2
RCLx Z
2^x
STOx Y
x<> L
x!
x
RTN

7/12th shorter, actually!

The following preverves the Y register, but I need two more steps:

Code:

LBL A
ENTER
ENTER
||
2^x
RCL L
x!
*
x<>y
(-1)^x
DEC X
4
/
CNST 86
x<>y
y^x
*
RTN

Ideally, both Y and Z stack registers should be saved. Thus I would not need the alternative definition in program 01. The implementation of the rising and falling factorials might be more interesting, but they are defined in terms of the ordinary factorial and would take just a few steps each.

Walter's Blue Book is worth looking at sometimes. If I only knew the whereabouts of mine... (hidden somewhere in the house).

Thank you all for the optimization suggestions, formula rearrangement and comments.

Gerson.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Double factorial [wp34s] - Paul Dale - 02-12-2016, 06:27 AM
RE: Double factorial [wp34s] - Dieter - 02-12-2016, 07:49 AM
RE: Double factorial [wp34s] - Gerson W. Barbosa - 02-12-2016 02:21 PM
RE: Double factorial [wp34s] - Dieter - 02-12-2016, 07:54 PM
RE: Double factorial [wp34s] - Paul Dale - 02-13-2016, 12:14 AM
RE: Double factorial [wp34s] - Paul Dale - 02-12-2016, 10:45 AM
RE: Double factorial [wp34s] - Paul Dale - 02-12-2016, 10:33 PM
RE: Double factorial [wp34s] - Paul Dale - 02-13-2016, 10:41 PM
RE: Double factorial [wp34s] - Dieter - 02-15-2016, 07:03 AM
RE: Double factorial [wp34s] - emece67 - 02-13-2016, 12:57 AM
RE: Double factorial [wp34s] - Paul Dale - 02-13-2016, 04:46 AM
RE: Double factorial [wp34s] - Dieter - 02-13-2016, 06:53 AM
RE: Double factorial [wp34s] - Paul Dale - 02-13-2016, 07:05 AM
RE: Double factorial [wp34s] - Dieter - 02-13-2016, 07:00 PM
RE: Double factorial [wp34s] - emece67 - 02-13-2016, 09:15 AM
RE: Double factorial [wp34s] - John Keith - 02-14-2016, 03:24 PM



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