具有阶乘的组合函数 - 结果不正确 - Pgfplots

具有阶乘的组合函数 - 结果不正确 - Pgfplots
\begin{tikzpicture}
\begin{axis}[
axis lines = left,
xlabel = $Number of Elements$,
ylabel = {$Combinations=\frac{(n)!}{(n-r)!(r!)}$},
]
%Axis
\addplot [
domain=2:10, 
samples=100, 
color=red,
]
%{x!/((x-2)!(2!))};
{ factorial(x)/(factorial(x-2))(factorial(2)))};
\addlegendentry{$\frac{(n)!}{(n-r)!(r!)}$}
\end{axis}
\end{tikzpicture}

答案1

您的分组不正确,并且隐式乘法尚未实现。

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}
\begin{document}%


\begin{tikzpicture}
\begin{axis}[
axis lines = left,
xlabel = Number of Elements,
ylabel = {$\mathrm{Combinations}=\frac{(n)!}{(n-r)!(r!)}$},
]
%Axis
\addplot [
domain=2:10, 
samples=100, 
color=red,
]
%{x!/((x-2)!(2!))};
{ factorial(x)/(factorial(x-2)*factorial(2))};
\addlegendentry{$\frac{(n)!}{(n-r)!(r!)}$}
\end{axis}
\end{tikzpicture}
\end{document}

相关内容