fact

From DavinciWiki
(Difference between revisions)
Jump to: navigation, search
m
m (Reorganized description)
 
(3 intermediate revisions by one user not shown)
Line 1: Line 1:
 
{{DavinciWiki_Function|Factorial.
 
{{DavinciWiki_Function|Factorial.
 
|
 
|
Arguments: One (a 1x1x1 numeric array) integer or half-integer between 0 and 13; factorial is defined for half-integers such that fact(1/2) = ½√π
+
Arguments: One numeric array
 
   
 
   
Return Value: The factorial of the input (a 1x1x1 array; int for integer input, float for half-integer input)
+
Return Value: The factorial of the input
 
+
If no arguments are input, fact() prints its description, as shown below.
+
 
|
 
|
 
[[Syntax]]: fact(x)
 
[[Syntax]]: fact(x)
 
   
 
   
'x' - a 1x1x1 array whose value is an integer or half-integer x, such that 0 ≤ x < 13
+
'x' - a numeric array whose value is an integer or half-integer x, such that -0.5 ≤ x ≤ 34
 +
 
 +
fact(n) = n! = n*(n-1)*(n-2)*...*2*1 for integers; 0! = 1
 +
 
 +
n! = n*(n-1)*(n-2)*...0.5*fact(-0.5) for half-integers; (-0.5)! = √π
 +
 
 +
Return format:
 +
 
 +
int, when all elements of input are integers less than or equal to 12 (any format)
 +
 
 +
float, when some elements of input are half-integer floats, or when the maximum value of the input is greater than 12
 +
 
 +
double, when some elements of input are half-integer doubles
 +
 
 +
In general, the function returns the simplest format that can accurately represent the value of the factorial.
 +
 
 +
If no arguments are input, fact() prints its description, as shown below.
 
|
 
|
 
  dv> fact()
 
  dv> fact()
 
   
 
   
 
  Factorial
 
  Factorial
  fact(n), integer or half-integer 0 <= n < 13
+
  fact(n), integers or half-integers -0.5 <&#61; n <&#61; 34
  Does NOT work for arrays, only for 1x1x1 inputs
+
  Works for arrays
  S.Marshall 12-06-2007
+
  S.Marshall 02-17-2008
 
   
 
   
 
  0
 
  0
  dv> fact(0)
+
  dv> fact(create(7))
  1
+
7x1x1 array of int, bsq format [28 bytes]
  dv> fact(0.5)
+
  1       1      2      6      24      120    720
0.886227
+
  dv> fact(-0.5//0.//0.5//1.//1.5//2.)
dv> fact(1)
+
  6x1x1 array of float, bsq format [24 bytes]
1
+
  1.77245 1.00000 0.886227        1.00000 1.32934 2.00000
dv> fact(6)
+
  dv> fact(-1)
  720
+
  dv> fact(12)
+
479001600
+
dv> fact(12.5)
+
1.71054e+09
+
  dv> fact(13)
+
 
   
 
   
  Input must be integer or half-integer 0 &lt;&#61; n &lt; 13
+
  Input must be integers or half-integers -0.5 <&#61; n <&#61; 34
 +
 +
0
 +
dv> fact(33)
 +
8.68332e+36
 +
dv> fact(34)
 +
2.95233e+38
 +
dv> fact(35)
 +
 +
Input must be integers or half-integers -0.5 <&#61; n <&#61; 34
 
   
 
   
 
  0
 
  0
 
|
 
|
 
|
 
|
*[[atan]]
+
*[[float]]
*[[floor]]
+
*[[int]]
 +
*[[isint]]
 
*[[isnum]]
 
*[[isnum]]
*[[sqrt]]
+
*[[max]]
 +
*[[min]]
 +
*[[type]]
 +
|
 +
*[[factor]]
 +
*[[gamma]]
 +
*[[intprod]]
 +
*[[nCk]]
 +
*[[nPk]]
 +
*[[product]]
 
|
 
|
 +
1.10
 
|
 
|
*math.dvrc
 
 
|
 
|
 
}}
 
}}

Latest revision as of 16:47, 18 November 2009


Description

Factorial.

Arguments and Return Values

Arguments: One numeric array

Return Value: The factorial of the input

Usage

Syntax: fact(x)

'x' - a numeric array whose value is an integer or half-integer x, such that -0.5 ≤ x ≤ 34

fact(n) = n! = n*(n-1)*(n-2)*...*2*1 for integers; 0! = 1

n! = n*(n-1)*(n-2)*...0.5*fact(-0.5) for half-integers; (-0.5)! = √π

Return format:

int, when all elements of input are integers less than or equal to 12 (any format)

float, when some elements of input are half-integer floats, or when the maximum value of the input is greater than 12

double, when some elements of input are half-integer doubles

In general, the function returns the simplest format that can accurately represent the value of the factorial.

If no arguments are input, fact() prints its description, as shown below.

Examples

dv> fact()

Factorial
fact(n), integers or half-integers -0.5 <= n <= 34
Works for arrays
S.Marshall 02-17-2008

0
dv> fact(create(7))
7x1x1 array of int, bsq format [28 bytes]
1       1       2       6       24      120     720
dv> fact(-0.5//0.//0.5//1.//1.5//2.)
6x1x1 array of float, bsq format [24 bytes]
1.77245 1.00000 0.886227        1.00000 1.32934 2.00000
dv> fact(-1)

Input must be integers or half-integers -0.5 <= n <= 34

0
dv> fact(33)
8.68332e+36
dv> fact(34)
2.95233e+38
dv> fact(35)

Input must be integers or half-integers -0.5 <= n <= 34

0

DavinciWiki Mini-Nav Bar

Contents


Contact Developers

  • davinci-dev [AT] mars.asu.edu

All other topics

  • See navigation on the left

Major Sub-Functions

Related Functions

Recent Library Changes

Created On: 12-07-2007
Modified On: 11-18-2009

Personal tools