Factorial of symbolic input
Compute the factorial for a symbolic number.
f = factorial(sym(20))
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 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 an expression containing the factorial function.
syms n f = factorial(n^2 + n + 1); f1 = expand(f)
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.
factorial acts element-wise on array input.
A = sym([1 3; 4 5]); f = factorial(A)
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.
factorial for a number
that is not a symbolic object invokes the MATLAB®