# How to plot multifactorial function?

The multifactorial function can be extended to the reals (see TheSimpliFire answer) like so:

It follows that we can extend the multifactorial function to the reals through

$$x!^{(k)}=k^{x/k}\Gamma\left(1+\frac{x}{k}\right)\prod_{i=1}^{k-1}\left(\frac{i k^{-i/k}}{\Gamma(1+i/k)}\right)^{\sin(\pi(x-i))\cot(\pi(x-i)/k)/k}$$

Multifactorial[x_, k_] := k^(x/k)*Gamma[1 + x/k]*
Product[((j k^(-(j/k)))/Gamma[(j + k)/k])^(1/k*Sin[Pi (x - j)] Cot[Pi*(x - j)/k]),
{j, 1, k - 1}]

Multifactorial[2, 5]
(*Error messages: "Indeterminate expression 0^0 encountered"*)

Plot[Multifactorial[x, 5], {x, -4, 4}]


How can get to work and plot (with Desmos, it works fine) the function?

• Note that Cot[π (-j + z)] Sin[π (-j + z)] simplifies to Cos[π (-j + z)] – J. M.'s torpor Feb 18 at 15:52
• @J.M. See my updated question? – Mariusz Iwaniuk Feb 18 at 16:05

## 2 Answers

The immediate cure is to instead use the Chebyshev polynomial of the second kind, $$U_n(x)$$, in the definition:

multiFactorial[x_, k_] := k^(x/k) Gamma[1 + x/k] Product[((j k^(-(j/k)))/Gamma[(j + k)/k])^
(Cos[(π (-j + x))/k]/k
ChebyshevU[k - 1, Cos[(π (-j + x))/k]]),
{j, 1, k - 1}]


For instance:

multiFactorial[x, 2] - x!! // FunctionExpand // Simplify
0

Plot[multiFactorial[x, 5], {x, -4, 4}] Clear["Global*"]

\$Version

(* "12.2.0 for Mac OS X x86 (64-bit) (December 12, 2020)" *)


Treat the case for integer x as a limit.

Edited to match revised question

Multifactorial[x_Integer, k_Integer?Positive] := Module[{z},
Limit[k^(z/k)*Gamma[1 + z/k]*
Product[((j k^(-(j/k)))/Gamma[(j + k)/k])^(1/k*
Sin[Pi (z - j)] Cot[Pi*(z - j)/k]), {j, 1, k - 1}], z -> x]]

Multifactorial[x_, k_Integer?Positive] :=
k^(x/k)*Gamma[1 + x/k]*
Product[((j k^(-(j/k)))/Gamma[(j + k)/k])^(1/k*
Sin[Pi (x - j)] Cot[Pi*(x - j)/k]), {j, 1, k - 1}]

Multifactorial[2, 5]

(* 2 *)

Multifactorial[2 - 10^-10, 5] // N

(* 2. *)

Multifactorial[2 + 10^-10, 5] // N

(* 2. *)

Show[
Plot[Multifactorial[x, 5], {x, -4, 4}],
DiscretePlot[Multifactorial[x, 5], {x, -4, 4}]] There are still issues if you enter an integer as a real, e.g.,

Multifactorial[2., 5]

(* Infinity::indet: Indeterminate expression 0. ComplexInfinity encountered.

Indeterminate *)


However, you can resolve this by rationalizing the input.

Multifactorial[2. // Rationalize, 5]

(* 2 *)

• I made a mistake.I'm update my question.Power in product is: 1/k*Sin[Pi (x - j)] Cot[Pi*(x - j)/k] not: Sin[Pi (x - j)] Cot[Pi*(x - j)]`. – Mariusz Iwaniuk Feb 18 at 16:02