# minimising the value of an integral

Given the integral

$$I \equiv \int_{0}^{\pi/2}\left\vert\,\cos\left(x\right) - kx^{2}\,\right\vert \,{\rm d}x$$

Find the value of $k$ so that $I$ is minimum.

Help would be appreciated.

Thanks.

-
wolfram alpha suggests that it is minimum at $x=0$ (wolframalpha.com/input/…) –  Sabyasachi Mar 15 '14 at 9:49
I don't get what you're trying to say. The question here is to find the value of k. –  randomwalker Mar 15 '14 at 9:57
$k=0$, I presume. –  Claude Leibovici Mar 15 '14 at 9:58
If that's the case then, k=1 gives me a lower value of I than k=0. –  randomwalker Mar 15 '14 at 10:01
@VijayRaghavan I meant k=0. Typo. –  Sabyasachi Mar 15 '14 at 10:01

## 2 Answers

We have to minimize the function $$I(p):=\int_0^{\pi/2}\bigl|\cos x -p x^2\bigr|\ dx\qquad(p\in{\mathbb R})\ .$$ When $p<0$ then obviously $I(p)>I(0)=1$. When $p>0$ then the parabola $y=p\,x^2$ intersects the curve $y=\cos x$ at a point $x=t$ with $0<t<{\pi\over2}$ depending on $p$. We now let $t>0$ be our new parameter and then have $$p={\cos t\over t^2}\ .$$ This means that we now have to minimize the function \eqalign{g(t)&:=I(\cos t/ t^2)\cr &=\int_0^t (\cos x-x^2\cos t/t^2)\ dx+ \int_t^{\pi/2} (x^2\cos t /t^2-\cos x)\ dx\cr &=2\sin t+{\pi^3-16t^3\over 24 t^2}\cos t -1\qquad(0<t<\pi/2)\ .\cr} When the function $g$ is not monotone then this will necessitate the solution of the transcendental equation $g'(t)=0$. Therefore we shall look at the problem using Mathematica. Here is the output:

It turns out that $g$ has a minimum at $t_*\doteq1.25$, and one obtains $g(t_*)\doteq0.89592$.

-
The answer can be directly derived by Maple code $$Optimization:-Minimize(k-> int(abs(cos(x)-k*x^2), x = 0 .. (1/2)*Pi), -10 .. 10);$$ which outputs $[ 0.895904446499112050, \left[ \begin {array}{c} 0.204850391620377660 \end {array} \right] ] .$ –  user64494 Mar 15 '14 at 13:03

## 1. Heuristic Calculation

Differentiating under the integral sign, we have

$$I'(k) = \int_{0}^{\pi/2} \operatorname{sign}(\cos x - kx^{2}) (-x^{2}) \, dx.$$

Let $k_{0}$ be the minimum point and $\cos\alpha - k_{0}\alpha^{2} = 0$. Then

$$0 = I'(k_{0}) = - \int_{0}^{\alpha} x^{2} \, dx + \int_{\alpha}^{\pi/2} x^{2} \, dx = \frac{\pi^{3}}{24} - \frac{2\alpha^{3}}{3}.$$

Solving this, we get $\alpha = \frac{\pi}{2^{4/3}}$ and therefore

$$k_{0} = \frac{\cos \alpha}{\alpha^{2}} = \frac{2^{8/3}}{\pi^{2}} \cos \left( \frac{\pi}{2^{4/3}} \right) \approx 0.20485055820305523635\cdots.$$

## 2. Preliminary

The following observations are introduced for rigor. You can skip the detail when you are only interested in the actual calculation.

Observation 1. $I(k)$ has a minimum point, and every minimum point of $I(k)$ lies on $[0, \infty)$.

Proof. By the triangle inequality,

$$I(k) \geq \int_{0}^{\pi/2} |k| x^{2} - \cos x \, dx = \frac{\pi^{3}|k|}{24} - 1 \xrightarrow{|k|\to\infty} \infty.$$

and hence $I(k) \to \infty$ as $|k| \to \infty$. In other words, $I(k)$ is coercive. So $I$ attains a minimum at some point. Also, if $k \leq 0$, then $|\cos x - kx^{2}| = \cos x - kx^{2}$ and hence

$$I(k) = 1 - \frac{\pi^{3}k}{24}, \quad k \leq 0,$$

which is decreasing. This shows that if $I$ has the minimum, then it occurs when $k \geq 0$. ////

Observation 2. If $k > 0$, the unique solution $x = \alpha(k)$ to $$\cos x - kx^{2} = 0, \quad 0 < x < \tfrac{\pi}{2}$$ defines a smooth function $\alpha : k \mapsto \alpha(k)$.

Proof. Let $D = \{ (x, k) : 0 < x < \frac{\pi}{2} \text{ and } k > 0 \}$ and $F : D \to \Bbb{R}$ be defined as

$$F(x, k) = \cos x - kx^{2}.$$

Then $F$ is strictly decreasing for each $k > 0$:

$$\frac{\partial F}{\partial x} = -\sin x - 2kx < 0. \tag{*}$$

Moreover, $F(0, k) = 1$ and $F(\frac{\pi}{2}, k) < 0$. Thus by Intermediate Value Theorem, for each $k > 0$ there exists a unique $\alpha(k) \in (0, \frac{\pi}{2})$ such that $F(\alpha(k), k) = 0$.

Now by Implicit Function Theorem with $\text{(*)}$, the level set $F(x, k) = 0$ is locally graph of smooth function. But we already know that the set $F(x, k) = 0$ is the graph of $\alpha$. Therefore $\alpha$ is smooth. ////

## 3. Justification of Heuristics

Now we are ready to calculate the minimum point. Notice that

\begin{align*} I(k) &= \int_{0}^{\alpha(k)} (\cos x - kx^{2}) \, dx - \int_{\alpha(k)}^{\pi/2} (\cos x - kx^{2}) \, dx. \tag{1} \end{align*}

is a smooth function of $k$ for $k > 0$. Differentiating $\text{(1)}$ and utilizing the identity

$$\cos\alpha(k) - k \alpha(k)^{2} = 0,$$

we get the following simple result for $k > 0$:

\begin{align*} I'(k) &= \int_{0}^{\alpha(k)} (-x^{2}) \, dx - \int_{\alpha(k)}^{\pi/2} (-x^{2}) \, dx = \frac{\pi^{3}}{24} - \frac{2\alpha(k)^{3}}{3}. \end{align*}

Since $\alpha(0^{+}) = \frac{\pi}{2}$, we have $I(0^{+}) < 0$ and hence $I$ is also decreasing near $k = 0$. So any minimum point $k_{0}$ of $I$ occurs on $k_{0} > 0$.

Thus we must get $I'(k_{0}) = 0$, and solving this equation in terms of $\alpha(k_{0})$ gives

$$\alpha(k_{0}) = \frac{\pi}{2^{4/3}} \approx 1.2467418707910012667\cdots.$$

Therefore the minimum point $k_{0}$ is unique and it is given by

$$k_{0} = \frac{\cos \alpha(k_{0})}{\alpha(k_{0})^{2}} = \frac{2^{8/3}}{\pi^{2}} \cos \left( \frac{\pi}{2^{4/3}} \right) \approx 0.20485055820305523635\cdots.$$

-