# Using LaTeX to render hypergeometric function notation

I decided to look if the solution Caramdir gave in this question would work as well for my attempts to use a new notation for hypergeometric functions. However, trying

{}_3 F_2\left(\begin{matrix}a& &b& &c\\&d& &e&\end{matrix}\middle;z\right)


resulted in the arguments before the semicolon being too widely spaced. I could of course just give up on the "staggered array notation" and align by columns what can be aligned by columns, or just use a two row, one column matrix and then use commas as delimiters, but I kind of like to see how to do a staggered array in LaTeX, and reserve matrix for the case of the number of parameters in both rows being equal.

So, how does one do a tighter looking (but still nicely spaced) staggered array?

-
I am not sure a staggered array is a way to go here, what if you need to do something like {}_3 F_2\left(\begin{matrix}a-b+1& &b+a-1& &c+d-1\\&d-a+1& &e+d-b-1&\end{matrix}\middle;z\right), even if you make the the array tighter, there will still be a lot of space left. How about something like this: {}_3 F_2\left(\begin{matrix}a\quad b\quad c\\d\quad e\end{matrix}\middle;z\right)? –  Jan Hlavacek Aug 29 '10 at 4:34
That doesn't compile for me because ; isn't a math delimiter. –  TH. Aug 29 '10 at 5:08
I've seen it with both semicolons and bars delimiting the argument from the parameters. I guess any of the two would work for me. –  user914 Aug 29 '10 at 7:29
To get prepended subscripts, you may also consider using the tensor package, see tex.stackexchange.com/questions/334/non-kludgey-left-subscripts –  Willie Wong Aug 29 '10 at 15:08
Interesting question there, thanks Willie. –  user914 Aug 30 '10 at 0:50

\setlength\arraycolsep{1pt}
{}_3 F_2\left(\begin{matrix}a& &b& &c\\&d&
&e&\end{matrix};z\right)


That tightens up the spacing quite a bit. I made a hypergeometric macro previously, but it doesn't support the ;z, unfortunately.

\newcommand*\pFq[2]{{}_{#1}F_{#2}\genfrac[]{0pt}{}}


Then you use \pFq{3}{2}{a,b,c}{d,e}. (Or replace the commas with any other sort of spacing you want.) I was fairly happy with that.

Edit: Actually, how about something like this?

\newcommand*\pFqskip{8mu}
\catcode,\active
\newcommand*\pFq{\begingroup
\catcode\,\active
\def ,{\mskip\pFqskip\relax}%
\dopFq
}
\catcode\,12
\def\dopFq#1#2#3#4#5{%
{}_{#1}F_{#2}\biggl[\genfrac..{0pt}{}{#3}{#4};#5\biggr]%
\endgroup
}


Change \pFqskip to whatever spacing you want between the elements. You use it like

\pFq{3}{2}{a,b,c}{d,e}{z}

-
wow, I guess I'll swing with your macro instead. Thanks a lot! I guess with a little tinkering I could get it to render the Meijer G function and other multivariate hypergeometrics as well! –  user914 Aug 29 '10 at 7:27
Hmm, wait... I see you use \Bigl and \Bigr here; I'm still confused when to use these instead of \left and \right. Mind explaining why? –  user914 Aug 29 '10 at 10:03
It was a mistake. It should be \biggl and \biggr. I'll edit my answer. But the reason was that I wanted it to behave the same way \binom does. I find that most of the time \left and \right produce brackets that are too large. Most of the time, \bigX, \BigX, \biggX, \BiggX suffice. –  TH. Aug 29 '10 at 10:18
A more efficient definition of \pFq appears here –  egreg Mar 7 '12 at 8:41

A modification of TH's answer that allows \pFq to be in the argument of other commands.

\documentclass{article}
\usepackage{amsmath}
\newmuskip\pFqmuskip

\newcommand*\pFq[6][8]{%
\begingroup % only local assignments
\pFqmuskip=#1mu\relax
% make the comma math active
\mathcode\,=\string"8000
% and define it to be \pFqcomma
\begingroup\lccode\~=\,
\lowercase{\endgroup\let~}\pFqcomma
% typeset the formula
{}_{#2}F_{#3}{\left[\genfrac..{0pt}{}{#4}{#5};#6\right]}%
\endgroup
}
\newcommand{\pFqcomma}{\mskip\pFqmuskip}

\begin{document}
$\pFq{3}{2}{a,b,c}{d,e}{z} \qquad \pFq[4]{3}{2}{a,b,c}{d,e}{z} \qquad \textstyle\pFq{3}{2}{a,b,c}{d,e}{z}$
\end{document}


The trick is using math activation, rather than activation tout court. There's also an optional argument for changing the default spacing between the coefficients.

-

Mathematica gave me the folowing when I asked it to give the TeXForm of a generalized hypergeometric function

_2F_2\left(\frac{1}{2},\frac{1}{2};\frac{3}{2},\frac{3}{2};-c^2\right)

and it seems to work. Simple and general !

-

Although it doesn't use "matrix" notation you can adapt from one of the COOL package solutions. Check out page 30 of the COOL package manual. http://www.ctan.org/tex-archive/macros/latex/contrib/cool.

-