Double factorial [wp34s]
02-12-2016, 12:03 AM
Post: #1
 Gerson W. Barbosa Senior Member Posts: 1,091 Joined: Dec 2013
Double factorial [wp34s]
Code:
 // Opcode map source: wp34s.op (local directory) // Opcode SVN version: -- unknown -- // wp34s_asm.exe: Source file(s): wp34s.dat 0001 **LBL A 0002 ENTER[^] 0003 1 0004 +/- 0005 ACOS 0006 RCL[times] Y 0007 COS 0008 DEC X 0009 4 0010 / 0011 x[<->] Y 0012 2 0013 / 0014 RCL- Y 0015 RCL L 0016 x! 0017 x[<->] Y 0018 2[^x] 0019 [times] 0020 x[<->] Y 0021 # [pi] 0022 x[<->] Y 0023 y[^x] 0024 [times] 0025 RTN 0026 **LBL B 0027 RCL+ X 0028 DEC X 0029 DEC X 0030 STO+ Y 0031 x[<->] L 0032 XEQ C 0033 RTN 0034 **LBL C 0035 STO+ X 0036 RCL- Y 0037 +/- 0038 x[<->] Y 0039 XEQ 001 0040 x[<->] Y 0041 XEQ 001 0042 / 0043 RTN 0044 **LBL 001 0045 # 1/2 0046 x[<->] Y 0047 RCL[times] Y 0048 x! 0049 x[<->] Y 0050 RCL+ L 0051 2[^x] 0052 [times] 0053 # [pi] 0054 [sqrt] 0055 / 0056 RTN 0057 **LBL D 0058 ENTER[^] 0059 INC X 0060 # 002 0061 IDIV 0062 XEQ C 0063 RTN 0064 END // 64 total instructions used. // 64 total words used. // 64 single word instructions. // 0 double word instructions.

Program A: double factorial. This uses the formula used by Wolfram Alpha:

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

4 A --> 8
6 A --> 48
7.77 A --> 290.3223156096666
8.88 +/- A --> 0.01106808239125682
3.33 +/- A --> -1,065802995433050
5 +/- A --> 0.3333333333333334

Program B: rising double factorial.

9.8 ENTER 3 B --> 1595.832000000000 ; 9.8 * 11.8 * 13.8 = 1595.832
8.1 ENTER 4 B --> 13957.60410000001 ; 8.1 * 10.1 * 12.1 * 14.1 = 13957.6041

Program C: falling double factorial.

7.7 ENTER 2 C --> 43.88999999999996 ; 7.7 * 5.7 = 43.89
6.6 ENTER 3 C --> 78.93600000000006 ; 6.6 * 4.6 * 2.6 = 78.936

Program D: double factorial (integer arguments). This and programs B and C uses a more simple formula found at Wikipedia.

5 +/- D --> 0.3333333333333334
3 +/- D --> -1
4 D --> 8.000000000000001
 « Next Oldest | Next Newest »

 Messages In This Thread Double factorial [wp34s] - Gerson W. Barbosa - 02-12-2016 12:03 AM 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] - Gerson W. Barbosa - 02-12-2016, 11:52 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] - Didier Lachieze - 02-12-2016, 11:56 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] - Gerson W. Barbosa - 02-14-2016, 05:44 AM RE: Double factorial [wp34s] - Dieter - 02-15-2016, 07:03 AM RE: Double factorial [wp34s] - Didier Lachieze - 02-15-2016, 07:48 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] - Marcus von Cube - 02-13-2016, 07:50 PM RE: Double factorial [wp34s] - emece67 - 02-13-2016, 09:15 AM RE: Double factorial [wp34s] - Gerson W. Barbosa - 02-13-2016, 01:36 AM RE: Double factorial [wp34s] - John Keith - 02-14-2016, 03:24 PM RE: Double factorial [wp34s] - Gerson W. Barbosa - 02-14-2016, 04:55 PM

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