# College Math Teaching

## March 16, 2019

### The beta function integral: how to evaluate them

My interest in “beta” functions comes from their utility in Bayesian statistics. A nice 78 minute introduction to Bayesian statistics and how the beta distribution is used can be found here; you need to understand basic mathematical statistics concepts such as “joint density”, “marginal density”, “Bayes’ Rule” and “likelihood function” to follow the youtube lecture. To follow this post, one should know the standard “3 semesters” of calculus and know what the gamma function is (the extension of the factorial function to the real numbers); previous exposure to the standard “polar coordinates” proof that $\int^{\infty}_{-\infty} e^{x^2} dx = \sqrt{\pi}$ would be very helpful.

So, what it the beta function? it is $\beta(a,b) = \frac{\Gamma(a) \Gamma(b)}{\Gamma(a+b)}$ where $\Gamma(x) = \int_0^{\infty} t^{x-1}e^{-t} dt$. Note that $\Gamma(n+1) = n!$ for integers $n$ The gamma function is the unique “logarithmically convex” extension of the factorial function to the real line, where “logarithmically convex” means that the logarithm of the function is convex; that is, the second derivative of the log of the function is positive. Roughly speaking, this means that the function exhibits growth behavior similar to (or “greater”) than $e^{x^2}$

Now it turns out that the beta density function is defined as follows: $\frac{\Gamma(a+b)}{\Gamma(a)\Gamma(b)} x^{a-1}(1-x)^{b-1}$ for $0 < x < 1$ as one can see that the integral is either proper or a convergent improper integral for $0 < a < 1, 0 < b < 1$.

I'll do this in two steps. Step one will convert the beta integral into an integral involving powers of sine and cosine. Step two will be to write $\Gamma(a) \Gamma(b)$ as a product of two integrals, do a change of variables and convert to an improper integral on the first quadrant. Then I'll convert to polar coordinates to show that this integral is equal to $\Gamma(a+b) \beta(a,b)$

Step one: converting the beta integral to a sine/cosine integral. Limit $t \in [0, \frac{\pi}{2}]$ and then do the substitution $x = sin^2(t), dx = 2 sin(t)cos(t) dt$. Then the beta integral becomes: $\int_0^1 x^{a-1}(1-x)^{b-1} dx = 2\int_0^{\frac{\pi}{2}} (sin^2(t))^{a-1}(1-sin^2(t))^{b-1} sin(t)cos(t)dt = 2\int_0^{\frac{\pi}{2}} (sin(t))^{2a-1}(cos(t))^{2b-1} dt$

Step two: transforming the product of two gamma functions into a double integral and evaluating using polar coordinates.

Write $\Gamma(a) \Gamma(b) = \int_0^{\infty} x^{a-1} e^{-x} dx \int_0^{\infty} y^{b-1} e^{-y} dy$

Now do the conversion $x = u^2, dx = 2udu, y = v^2, dy = 2vdv$ to obtain:

$\int_0^{\infty} 2u^{2a-1} e^{-u^2} du \int_0^{\infty} 2v^{2b-1} e^{-v^2} dv$ (there is a tiny amount of algebra involved)

From which we now obtain

$4\int^{\infty}_0 \int^{\infty}_0 u^{2a-1}v^{2b-1} e^{-(u^2+v^2)} dudv$

Now we switch to polar coordinates, remembering the $rdrd\theta$ that comes from evaluating the Jacobian of $x = rcos(\theta), y = rsin(\theta)$

$4 \int^{\frac{\pi}{2}}_0 \int^{\infty}_0 r^{2a +2b -1} (cos(\theta))^{2a-1}(sin(\theta))^{2b-1} e^{-r^2} dr d\theta$

This splits into two integrals:

$2 \int^{\frac{\pi}{2}}_0 (cos(\theta))^{2a-1}(sin(\theta))^{2b-1} d \theta 2\int^{\infty}_0 r^{2a +2b -1}e^{-r^2} dr$

The first of these integrals is just $\beta(a,b)$ so now we have:

$\Gamma(a) \Gamma(b) = \beta(a,b) 2\int^{\infty}_0 r^{2a +2b -1}e^{-r^2} dr$

The second integral: we just use $r^2 = x \rightarrow 2rdr = dx \rightarrow \frac{1}{2}\frac{1}{\sqrt{x}}dx = dr$ to obtain:

$2\int^{\infty}_0 r^{2a +2b -1}e^{-r^2} dr = \int^{\infty}_0 x^{a+b-\frac{1}{2}} e^{-x} \frac{1}{\sqrt{x}}dx = \int^{\infty}_0 x^{a+b-1} e^{-x} dx =\Gamma(a+b)$ (yes, I cancelled the 2 with the 1/2)

And so the result follows.

That seems complicated for a simple little integral, doesn’t it?

## August 28, 2017

### Integration by parts: why the choice of “v” from “dv” might matter…

We all know the integration by parts formula: $\int u dv = uv - \int v du$ though, of course, there is some choice in what $v$ is; any anti-derivative will do. Well, sort of.

I thought about this as I’ve been roped into teaching an actuarial mathematics class (and no, I have zero training in this area…grrr…)

So here is the set up: let $F_x(t) = P(0 \leq T_x \leq t)$ where $T_x$ is the random variable that denotes the number of years longer a person aged $x$ will live. Of course, $F_x$ is a probability distribution function with density function $f$ and if we assume that $F$ is smooth and $T_x$ has a finite expected value we can do the following: $E(T_x) = \int^{\infty}_0 t f_x(t) dt$ and, in principle this integral can be done by parts….but…if we use $u = t, dv = f_x(t), du = dt, v = F_x$ we have:

\

$t(F_x(t))|^{\infty}_0 -\int^{\infty}_0 F_x(t) dt$ which is a big problem on many levels. For one, $lim_{t \rightarrow \infty}F_x(t) = 1$ and so the new integral does not converge..and the first term doesn’t either.

But if, for $v = -(1-F_x(t))$ we note that $(1-F_x(t)) = S_x(t)$ is the survival function whose limit does go to zero, and there is usually the assumption that $tS_x(t) \rightarrow 0$ as $t \rightarrow \infty$

So we now have: $-(S_x(t) t)|^{\infty}_0 + \int^{\infty}_0 S_x(t) dt = \int^{\infty}_0 S_x(t) dt = E(T_x)$ which is one of the more important formulas.

## August 25, 2014

### Fourier Transform of the “almost Gaussian” function with a residue integral

This is based on the lectures on the Fourier Transform by Brad Osgood from Stanford:

And here, $F(f)(s) = \int^{\infty}_{-\infty} e^{-2 \pi i st} f(t) dt$ provided the integral converges.

The “almost Gaussian” integrand is $f(t) = e^{-\pi t^2}$; one can check that $\int^{\infty}_{-\infty} e^{-\pi t^2} dt = 1$. One way is to use the fact that $\int^{\infty}_{-\infty} e^{-x^2} dx = \sqrt{\pi}$ and do the substitution $x = \sqrt{\pi} t$; of course one should be able to demonstrate the fact to begin with. (side note: a non-standard way involving symmetries and volumes of revolution discovered by Alberto Delgado can be found here)

So, during this lecture, Osgood shows that $F(e^{-\pi t^2}) = e^{-\pi s^2}$; that is, this modified Gaussian function is “its own Fourier transform”.

I’ll sketch out what he did in the lecture at the end of this post. But just for fun (and to make a point) I’ll give a method that uses an elementary residue integral.

Both methods start by using the definition: $F(s) = \int^{\infty}_{-\infty} e^{-2 \pi i ts} e^{-\pi t^2} dt$

Method 1: combine the exponential functions in the integrand:

$\int^{\infty}_{-\infty} e^{-\pi(t^2 +2 i ts} dt$. Now complete the square to get: $\int^{\infty}_{-\infty} e^{-\pi(t^2 +2 i ts-s^2)-\pi s^2} dt$

Now factor out the factor involving $s$ alone and write as a square: $e^{-\pi s^2}\int^{\infty}_{-\infty} e^{-\pi(t+is)^2} dt$

Now, make the substitution $x = t+is, dx = dt$ to obtain:

$e^{-\pi s^2}\int^{\infty+is}_{-\infty+is} e^{-\pi x^2} dx$

Now we show that the above integral is really equal to $e^{-\pi s^2}\int^{\infty}_{-\infty} e^{-\pi x^2} dx = e^{\pi s^2} (1) = e^{-\pi s^2}$

To show this, we perform $\int_{\gamma} e^{z^2} dz$ along the retangular path $\gamma$: $-x, x, x+is, -x+is$ and let $x \rightarrow \infty$

Now the integral around the contour is 0 because $e^{-z^2}$ is analytic.

We wish to calculate the negative of the integral along the top boundary of the contour. Integrating along the bottom gives 1.
As far as the sides: if we fix $s$ we note that $e^{-z^2} = e^{(s^2-x^2)+2si}$ and the magnitude goes to zero as $x \rightarrow \infty$ So the integral along the vertical paths approaches zero, therefore the integrals along the top and bottom contours agree in the limit and the result follows.

Method 2: The method in the video
This uses “differentiation under the integral sign”, which we talk about here.

Stat with $F(s) = \int^{\infty}_{-\infty} e^{-2 \pi i ts} e^{-\pi t^2} dt$ and note $\frac{dF}{ds} = \int^{\infty}_{-\infty} (-2 \pi i t) e^{-2 \pi i ts} e^{-\pi t^2} dt$

Now we do integration by parts: $u = e^{-2 \pi i ts}, dv = (-2 \pi i t)e^{-\pi t^2} \rightarrow v = i e^{-\pi t^2}, du = (-2 \pi i s)e^{-2 \pi i ts}$ and the integral becomes:

$(i e^{-\pi t^2} e^{-2 \pi i ts}|^{\infty}_{-\infty} - (i)(-2 \pi i s) \int^{\infty}_{-\infty} e^{-2 \pi i ts} e^{-\pi t^2} dt$

Now the first term is zero for all values of $s$ as $t \rightarrow \infty$. The second term is merely:

$-(2 \pi s) \int^{\infty}_{-\infty} e^{-2 \pi i ts} e^{-\pi t^2} dt = -(2 \pi s) F(s)$.

So we have shown that $\frac{d F}{ds} = (-2 \pi s)F$ which is a differential equation in $s$ which has solution $F = F_0 e^{- \pi s^2}$ (a simple separation of variables calculation will verify this). Now to solve for the constant $F_0$ note that $F(0) = \int^{\infty}_{-\infty} e^{0} e^{-\pi t^2} dt = 1$.

The result follows.

Now: which method was easier? The second required differential equations and differentiating under the integral sign; the first required an easy residue integral.

By the way: the video comes from an engineering class. Engineers need to know this stuff!

## October 25, 2013

### A Laplace Transform of a function of non-exponential order

Many differential equations textbooks (“First course” books) limit themselves to taking Laplace transforms of functions of exponential order. That is a reasonable thing to do. However I’ll present an example of a function NOT of exponential order that has a valid (if not very useful) Laplace transform.

Consider the following function: $n \in \{1, 2, 3,...\}$

$g(t)= \begin{cases} 1,& \text{if } 0 \leq t \leq 1\\ 10^n, & \text{if } n \leq t \leq n+\frac{1}{100^n} \\ 0, & \text{otherwise} \end{cases}$

Now note the following: $g$ is unbounded on $[0, \infty)$, $lim_{t \rightarrow \infty} g(t)$ does not exist and
$\int^{\infty}_0 g(t)dt = 1 + \frac{1}{10} + \frac{1}{100^2} + .... = \frac{1}{1 - \frac{1}{10}} = \frac{10}{9}$

One can think of the graph of $g$ as a series of disjoint “rectangles”, each of width $\frac{1}{100^n}$ and height $10^n$ The rectangles get skinnier and taller as $n$ goes to infinity and there is a LOT of zero height in between the rectangles.

Needless to say, the “boxes” would be taller and skinnier.

Note: this is an example can be easily modified to provide an example of a function which is $l^2$ (square integrable) which is unbounded on $[0, \infty)$. Hat tip to Ariel who caught the error.

It is easy to compute the Laplace transform of $g$:

$G(s) = \int^{\infty}_0 g(t)e^{-st} dt$. The transform exists if, say, $s \geq 0$ by routine comparison test as $|e^{-st}| \leq 1$ for that range of $s$ and the calculation is easy:

$G(s) = \int^{\infty}_0 g(t)e^{-st} dt = \frac{1}{s} (1-e^{-s}) + \frac{1}{s} \sum^{\infty}_{n=1} (\frac{10}{e^s})^n(1-e^{\frac{-s}{100^n}})$

Note: if one wants to, one can see that the given series representation converges for $s \geq 0$ by using the ratio test and L’Hoptial’s rule.

## June 5, 2012

### Quantum Mechanics, Hermitian Operators and Square Integrable Functions

In one dimensional quantum mechanics, the state vectors are taken from the Hilbert space of complex valued “square integrable” functions, and the observables correspond to the so-called “Hermitian operators”. That is, if we let the state vectors be represented by $\psi(x) = f(x) + ig(x)$ and we say $\psi \cdot \phi = \int^{\infty}_{-\infty} \overline{\psi} \phi dx$ where the overline decoration denotes complex conjugation.

The state vectors are said to be “square integrable” which means, strictly speaking, that $\int^{\infty}_{-\infty} \overline{\psi}\psi dx$ is finite.
However, there is another hidden assumption beyond the integral existing and being defined and finite. See if you can spot the assumption in the following remarks:

Suppose we wish to show that the operator $\frac{d^2}{dx^2}$ is Hermitian. To do that we’d have to show that:
$\int^{\infty}_{-\infty} \overline{\frac{d^2}{dx^2}\phi} \psi dx = \int^{\infty}_{-\infty} \overline{\phi}\frac{d^2}{dx^2}\psi dx$. This doesn’t seem too hard to do at first, if we use integration by parts:
$\int^{\infty}_{-\infty} \overline{\frac{d^2}{dx^2}\phi} \psi dx = [\overline{\frac{d}{dx}\phi} \psi]^{\infty}_{-\infty} - \int^{\infty}_{-\infty}\overline{\frac{d}{dx}\phi} \frac{d}{dx}\psi dx$. Now because the functions are square integrable, the $[\overline{\frac{d}{dx}\phi} \psi]^{\infty}_{-\infty}$ term is zero (the functions must go to zero as $x$ tends to infinity) and so we have: $\int^{\infty}_{-\infty} \overline{\frac{d^2}{dx^2}\phi} \psi dx = - \int^{\infty}_{-\infty}\overline{\frac{d}{dx}\phi} \frac{d}{dx}\psi dx$. Now we use integration by parts again:
$- \int^{\infty}_{-\infty}\overline{\frac{d}{dx}\phi} \frac{d}{dx}\psi dx = -[\overline{\phi} \frac{d}{dx}\psi]^{\infty}_{-\infty} + \int^{\infty}_{-\infty} \overline{\phi}\frac{d^2}{dx^2} \psi dx$ which is what we wanted to show.

Now did you catch the “hidden assumption”?

Here it is: it is possible for a function $\psi$ to be square integrable but to be unbounded!

If you wish to work this out for yourself, here is a hint: imagine a rectangle with height $2^{k}$ and base of width $\frac{1}{2^{3k}}$. Let $f$ be a function whose graph is a constant function of height $2^{k}$ for $x \in [k - \frac{1}{2^{3k+1}}, k + \frac{1}{2^{3k+1}}]$ for all positive integers $k$ and zero elsewhere. Then $f^2$ has height $2^{2k}$ over all of those intervals which means that the area enclosed by each rectangle (tall, but thin rectangles) is $\frac{1}{2^k}$. Hence $\int^{\infty}_{-\infty} f^2 dx = \frac{1}{2} + \frac{1}{4} + ...\frac{1}{2^k} +.... = \frac{1}{1-\frac{1}{2}} - 1 = 1$. $f$ is certainly square integrable but is unbounded!

It is easy to make $f$ into a continuous function; merely smooth by a bump function whose graph stays in the tall, thin rectangles. Hence $f$ can be made to be as smooth as desired.

So, mathematically speaking, to make these sorts of results work, we must make the assumption that $lim_{x \rightarrow \infty} \psi(x) = 0$ and add that to the “square integrable” assumption.

## February 19, 2012

### Divergent Improper Integrals: change of variables to an unbounded integrand.

Filed under: calculus, change of variable, improper integrals, integrals, integration by substitution, pedagogy — collegemathteaching @ 10:41 pm

This post was motivated by a student question: my student wanted help with the following problem:

$\int^{\infty}_{1} \frac{x^2}{\sqrt{x^3 +1}} dx$
Of course the idea is to do a substitution: $u = x^3 + 1$ which transforms the integral into $\frac{1}{3} \int^{\infty}_{2} \frac{1}{\sqrt{u}} du$ which diverges. So far, so good. But then I told him one of my calculus tips: “it is often a good idea to try to guess the answer ahead of time” and then pointed out that for large values of $x, \frac{x^2}{\sqrt{x^3 +1}} \approx \frac{x^2}{\sqrt{x^3}} = \sqrt{x}$ and of course $\int^{\infty}_1 \sqrt{x} dx$ diverges because the integrand does not go to zero (in fact, is unbounded!) as $x$ tends to infinity.

Then I realized that a change of variables had taken an unbounded function to a bounded one…though one which did not produce a convergent improper integral.

That lead to the natural question: if one has an integrand which is positive but monotonically decreasing to zero on $[1, \infty )$, is there a change of variables which will change the integrand to either an unbounded function on $[1, \infty )$ or at least one that does not decrease to zero?

I admit that I have not answered this question yet, nor have I looked it up. But I can answer this question for a certain class of functions:

Theorem

Given $\int^{\infty}_1 \frac{1}{x^r} dx$
If $0 < r < 1$, let $k > \frac{1}{1-r}$. Then the change of variable $u = x^{\frac{1}{k}}$ transforms $\int^{\infty}_{1} \frac{1}{x^r} dx$ to $k \int^{\infty}_1 u^{k(1-r) -1} du$ and of course $u^{k(1-r) -1}$ is unbounded on $[1, \infty)$.

If $1 < r$ let $k < \frac{1}{1-r} < 0$. Then $\int^{\infty}_1 \frac{1}{x^r} dx$ is transformed into $|k|\int^{1}_{0} u^{-1+k(1-r)} du$ which is an integral of a bounded function over a bounded region.

In short, one class of functions whose improper integral diverges can be transformed to functions that tend to infinity and the class of functions whose integrals converge can be transformed into functions which are bounded over a bounded interval.

Here is such an example: We show the equivalent integrals $\int^{1.5}_{1} 3x^{\frac{1}{2}} dx$ and $\int^{(1.5)^3}_1 \frac{1}{\sqrt{u}} du$. The transformation is accomplished by using $u =x^3$. Note how the transformation stretches the interval of integration to account for the function “shrinkage”.

On the other hand, using $u^{-2}=x$ transforms $\int^{\infty}_1 \frac{1}{x^2} dx$ into $2\int^{1}_{0} u du$