Factorial of symbolic input
Factorial for Symbolic Number
Compute the factorial for a symbolic number.
f = factorial(sym(20))
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)
Calculate the factorial for a value of
n = 3. Substitute the value of
n by using
fVal = subs(f,n,3)
Differentiate Factorial Function
Differentiate an expression containing the factorial function
syms n f = factorial(n^2 + n + 1)
df = diff(f)
The derivative of the factorial function is expressed in terms of the
Expand Factorial Function
Expand an expression containing the factorial function.
syms n f = factorial(n^2 + n + 1); f1 = expand(f)
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)
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)
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.
The factorial of a number n is defined as follows.
The factorial of 0 is 1.
factorialfor a number that is not a symbolic object invokes the MATLAB®