factorial
Factorial of symbolic input
Syntax
Description
Examples
Factorial for Symbolic Number
Compute Factorial Function for Symbolic Expression
Compute the factorial function for a symbolic expression. factorial
returns exact symbolic output as the function call.
syms n
expr = n^2 + 1;
f = factorial(expr)
f =
Calculate the factorial for a value of n = 3
. Substitute the value of n
by using subs
.
fVal = subs(f,n,3)
fVal =
Differentiate Factorial Function
Differentiate an expression containing the factorial function
syms n
f = factorial(n^2 + n + 1)
f =
df = diff(f)
df =
The derivative of the factorial function is expressed in terms of the psi
function.
Expand Factorial Function
Expand an expression containing the factorial function.
syms n
f = factorial(n^2 + n + 1);
f1 = expand(f)
f1 =
Limit of Factorial Function
Compute the limit at infinity for an expression containing the factorial function.
syms n
f = factorial(n)/exp(n);
fLim = limit(f,n,Inf)
fLim =
Compute Factorial for Array Input
Compute factorial for array input. factorial
acts element-wise on array input.
A = sym([1 3; 4 5]); f = factorial(A)
f =
Input Arguments
n
— Input
number | vector | matrix | array | symbolic number | symbolic variable | symbolic array | symbolic function | symbolic expression
Input, specified as a number, vector, matrix, or array, or a symbolic number, variable, array, function, or expression.
More About
Factorial Function
The factorial of a number n is defined as follows.
The factorial of 0 is 1.
Tips
Calling
factorial
for a number that is not a symbolic object invokes the MATLAB®factorial
function.
Version History
Introduced in R2012a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)