Let's say we have a square grid with n steps each. One starts at the lower left corner, takes $2n$ steps; $n$ of them to the right and $n$ of them to the upwards and ends up at the upper right corner. If we want to count the number of paths that don't cross the main diagonal and stay on a particular side of it, we get the Catalan numbers, $C\_n=\frac{2n \choose n}{(n+1)}$. Accounting for both sides, the total paths that don't cross the main diagonal then become $2 C\_n$. A natural question to ask is: how many paths cross the main diagonal exactly $k$ times? Let's call this number $R\_{k,n}$. I want to find a closed-form expression for $R\_{k,n}$. Obviously, $R\_{0,n}=2C\_n$

---

**My attempt and some thoughts**

The question here: [Using the Catalan numbers](https://math.stackexchange.com/questions/95822/using-the-catalan-numbers/124622?noredirect=1#comment7646824_124622) provides a warm-up. Both @joriki and @robjohn calculate the number of paths that have a segment that is positive (possibly empty) followed by a segment that is negative (possibly empty). Let's denote this sequence, $G\_n$ as joriki does. They do this by noting that conditional on some cut-off point, we simply get two Catalan sequences. Hence, the number of such paths becomes the convolution of the Catalan numbers with themselves. joriki notes that this sequence will have a generating function that is the square of the generating function of the Catalan numbers. He uses this to determine that it is simply the $n+1$th Catalan number. Another way to go about finding this would have been to use the general formula here: [Proof of identity about generalized binomial sequences.](http://math.stackexchange.com/questions/3064256/proof-of-identity-about-generalized-binomial-sequences/3064511#3064511) with $k=2$. The two yield the same answer. This can be used to get $R\_{1,n}$ per the following equation (we divide $R\_{1,n}$ by 2 because the sequence only considers paths which were negative first and then positive while $R\_{1,n}$ includes sequences that were positive first):

$$G\_n=C\_{n+1}=2C\_n+\frac{R\_{1,n}}{2}$$
$$=> R\_{1,n}=2C\_{n+1}-4C\_n$$

Now, can we apply this "convolution trick" to get $R\_{k,n}$?

One way is to consider paths that have three sections. They start off with a section (possibly empty) below the main diagonal. Then, they cross it and there is a section (possibly empty) above the main diagonal. Then, they cross it again and there is a third section (possibly empty) that stays below the main diagonal. Unlike before, there are two cut-off points and it seems we have a three-way convolution of the Catalan numbers with themselves. The first thought is that the number of such paths (say $H\_n$) will have a generating function that is the cube of that of the Catalan numbers. And if we increase the number of segments further, we get higher and higher powers of the generating function. But this can't be right since as we keep increasing the number of such segments, the number of paths should keep increasing per equation (5.70) here: [Proof of identity about generalized binomial sequences.](https://math.stackexchange.com/questions/3064256/proof-of-identity-about-generalized-binomial-sequences/3064511#3064511). In reality, we'll reach an upper bound at some point when we simply cover all ${2n \choose n}$ paths. So, what is the error in the "three way convolution leading to a generating function becoming the cube of the Catalan number generating function" argument? One resolution might be that the argument is fine, but increasing the cut-off points starts double and triple counting the paths.