I am writing some material on the trinomial theorem and Pascal's pyramid, and I'm trying to typeset a single layer. Here is my code so far:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\pgfkeys{/pgf/number format/.cd,int trunc}
\small
\begin{tikzpicture}
\pgfmathsetmacro{\n}{8}
\foreach \i in {0,1,...,\n}
{
\foreach \j in {0,...,\i}
{
\draw (\j-\i*0.5,\i*0.866,) -- ++(1,0) -- ++(-0.5,-0.866) -- cycle;
\node[align=center] at (0.1+\j-\i*0.5,-0.65+\i*0.866)
{\pgfmathparse{factorial(\n)/factorial(\n-\i)%
/factorial(\j)/factorial(\i-\j)}\pgfmathprintnumber{\pgfmathresult}};
}
}
\end{tikzpicture}
\end{document}
This works fine up to n=7, but crashes with an arithmetic overflow on n=8. As you can see, the computation is simply finding the values of some multinomial coefficients. But why the crash on n=8? And what's the best way around it?
\pgfmathparse{factorial(8)}\pgfmathresult;and also\pgfmathparse{8!}\pgfmathresult;does not work for some reasons. (also all values greater doesn't work for me) Error:! Arithmetic overflow. \pgfmath@iterate ...pgfmath@x by\c@pgfmath@counta \advance \c@pgfmath@counta... l.25 \pgfmathparse{factorial(8)} \pgfmathresult; I can't carry out that multiplication or division, since the result is out of range.– Bobyandbob Aug 04 '17 at 05:10xintfor my computations, or farm my computations to an external package such as GNU Maxima or Sage. – Alasdair Aug 04 '17 at 11:33xintinstead ofpgfmath, and computed the numbers I wanted with{\xinttheexpr binomial(\n,\i)*binomial(\i,\j)\relax}. – Alasdair Aug 04 '17 at 12:41