Notes: A family of ramp functions and the Beta function

Sometimes in a numerical method, you need to be able to continuously turn a calculation on or off in space or time (here I will pretend it’s in time). This can be easily accomplished if you have a function that starts at a value of 0 before some first time , and rises up to a value of 1 by time . Through an affine transformation you can always map . An example “ramp” function is plotted above.

Now if this function appears in a differential equation, and you are integrating it with an order method, then it’s not enough for the function to be continuous: you probably want the first n derivatives to match (and thus vanish) at each endpoint.

Let’s go for a piecewise ramp function,

\begin{align} R_n(t) = \begin{cases} 0 & t < 0 \\ p_n(t) & 0 \le t \le 1 \\ 1 & 1 < t \end{cases} \end{align}

where is some polynomial in t. Some counting tells you that these 2 endpoint values and 2n derivative conditions can be satisfied with a polynomial of degree 2n+1. Try changing the value of n above and see how the smoothness changes.

Now for any value of n, it’s a straightforward algebra problem to set up the polynomial and solve for the coefficients. You probably want to know the answer for the general case, and a simple approach is to do a few examples and look for the pattern. Here are the first few:

\begin{align} p_0(t) &= t \\ p_1(t) &= t^2 (3-2t) \\ p_2(t) &= t^3 (10 - 15 t + 6 t^2) \\ p_3(t) &= t^4 (35 - 84 t + 70 t^2 - 20 t^3) \\ p_4(t) &= t^5 (126 - 420 t + 540 t^2 - 315 t^3 + 70 t^4) \end{align}

Can you spot the pattern? Don’t feel bad if you can’t, that’s why we have the OEIS. If you search for the above integers as a sequence, you’ll find A091811.

With this newfound knowledge, we can now write down the closed form for the polynomial,

\begin{align} \label{eq:def} p_n(t) = t^{n+1} \sum_{k=0}^n (-1)^k \binom{n+k}{k} \binom{2n+1}{n-k} t^k \,. \end{align}

But was there a better way to find this than relying on the OEIS to already have the result? But of course!

Rather than thinking about itself, let’s think about . Since is strictly increasing, is positive, while going to zero at the endpoints. In fact it goes to zero like at one endpoint, and at the other endpoint, because we wanted n derivatives to vanish at each endpoint. Therefore we know the proportionality

\begin{align} p_n^\prime(t) \propto t^n (1-t)^n \,. \end{align}

The only thing to get right is the normalization, which we enforce by asking that the integral of is 1 at . If you’ve spent enough time on probability and statistics, then you’ll recognize as a special case of the Beta distribution, with shape parameters . So we know the normalization,

\begin{align} p_n^\prime(t) = \frac{1}{B(n+1, n+1)} t^n (1-t)^n \,, \end{align}

where is the beta function, and we can now call the regularized incomplete beta function, .

The incomplete beta function has a representation in terms of the Gauss hypergeometric function,

\begin{align} B_x(a,b) = \frac{x^a}{a} F(a, 1-b; a+1; x) \,. \end{align}

The important fact for us is that we’re interested in , in which case one of the first two arguments is a non-positive integer, and therefore the series will terminate as a finite-degree polynomial. This way, you can prove Eq. \eqref{eq:def}!