# Maxima of almost quadratic function.

Consider $f(x) = x^2 - \sqrt{(ax + b\sin(\theta))^2+(b \cos(\theta))^2}$, for some $a, b, \theta$ real and positive.

Then: $f'(x) = 2x - \frac{a(ax + b \sin(\theta)}{\sqrt{(ax + b\sin(\theta))^2+(b \cos(\theta))^2}}$

I'm looking for some relation between $a, b, \theta$ (for nonzero $a, b$) such that $f(x)$ has 2 minimums and 1 maxima, or just one minima. (Those are the only cases possible I believe, feel free to prove me wrong).

For example, if $\theta = 0$, then for $a^2 > 2b$ we have 2 minimas and one maximum at $x =-\frac{\sqrt{a^4 - 4b^2}}{2a}, 0 , \frac{\sqrt{a^4 - 4b^2}}{2a}$. Ofcourse one could set $f'(x)=0$, move the ugly term to RHS and square both sides but I wasn't able to neatly solve the resolving 4'th order polynomial.

Experimenting numerically, I have found that if we set $a,b$ such that $a^2 > 2b$ and increase $\theta$ from zero to $\pi/2$ we will go from having 3 zero's for $f'(x)$ to 1 and back to 3 again.

I'm more interested in amount of maxima/minima, instead of their location.

Any and all help would be appreciated.

Edit: Numerical experiments were done using Newton -Rhapson and the second derivite is: $f''(x) = 2 - \frac{(ab\cos(\theta))^2}{((ax + b\sin(\theta))^2+(b \cos(\theta))^2)\sqrt{(ax + b\sin(\theta))^2+(b \cos(\theta))^2}}$

Edit2: Trying to solve $f'(x) = 0$ yelds:

$\alpha x^4 + \beta x^3 + c x^2 + dx +e =0$ with $\alpha = 4a^2$, $\beta = 8ab\sin(\theta)$, $c = 4b^2 -a^4$, $d = -2a^3b\sin(\theta)$, $e = - a^2b^2\sin^2(\theta)$. I'm looking for the number of real roots.

• I think that "if $\theta = 0$, then for $a^2 > 2b$ we have 2 minimas and one maximum at $x =-\frac{\sqrt{a^4 - 4b^2}}{2a}, 0 , \frac{\sqrt{a^4 - 4b^2}}{2a}$" should be wrong. If I'm not mistaken, for $\sin(\theta)=0$, there exist two real numbers $\alpha,\beta$ where $\beta\lt 0\lt \alpha$ such that $f(x)$ is increasing for $x\lt\beta$ or $x\gt \alpha$ and is decreasing for $\beta\lt x\lt \alpha$, no matter what $a,b$ are. Aug 23, 2016 at 6:16
• No, I'm looking for the minimas and maximas of $f(x)$. I know for sure that the $x$ I gave are the ones for which $f'(x) = 0$ and if $a^2 > 2b$ were not to hold they would be imaginary right? Aug 23, 2016 at 6:38
• Ah, sorry I was partly wrong. You are right with additional condition $a^4\gt 4b^2$. Without it, you should be wrong. Take $a=1,b=-1$, see the graph of $f(x)$. (I guess that you are implicitly assuming that both $a$ and $b$ are positive.) Aug 23, 2016 at 6:48
• Oh, yes. I am assuming $a$ and $b$ to be positive. Aug 23, 2016 at 6:57
• Can one make use of Rolle's theorem to find the intervals of the zeros of your equation of order 4? A cubic is well understood (even if tedious). Also, the second derivative is a cubic whose sign tells if is a maximum or a minimum.
– Chip
Aug 25, 2016 at 7:23

HINT

To analyse roots of the derivation, we can consider the function

$$g(t)=\dfrac1bf(x)=\dfrac1{2d}t^2-\sqrt{t^2+2st+1},\quad |s|\leq1,\quad d>0,$$ where $$t=\dfrac {ax}{b},\quad s=\sin\theta,\quad d=\dfrac{a^2}{2b}.$$ Then $$g'(t) = \dfrac td - \dfrac{t+s}{\sqrt{t^2+2st+1}} = 0,$$ $$P(t)=t^4+2st^3+t^2-d^2(t+s)^2=0.$$

For $s=0,$ $$P(t)=t^2(t^2+1-d^2).$$ If $d\not=1,$ we have two multiple roots, what doesn't correspond to the condition.
If $d=1,$ we have one multiple root, what corresponds to the condition.

For $s=\pm1,\ d>0,$ $$P(t)=(t+s)^2(t^2-d^2),\quad g(t)=\dfrac1{2d}t^2-|t+s|,$$ and there is a discontinuity of the derivative $$\quad g'(-s-0)=-\dfrac1d s+1,\quad g'(-s+0)=-\dfrac1d s-1.$$ If $s=-1,$ then $$g'(1-0) = \dfrac1d+1,\quad g'(1+0)=\dfrac1d-1,$$ so we have one minimum for $0<d\leq1$ and one maximum and two minima for $d>1.$
If $s=1,$ then $$g'(-1-0) = -\dfrac1d+1,\quad g'(-1+0)=-\dfrac1d-1,$$ so we have one minimum for $0<d\leq1$ and one maximum and two minima for $d>1.$

Thus, the case $s=\pm1$ corresponds the condition.

Consider the case $0<|s|<1,$ in which $t=0$ and $t=-s$ aren't the roots of derivation.

The derivative is the difference between linear and nonlinear terms, with a nonlinear term has a horizontal asymptote $+1$ at $t\to +\infty$ and $-1$ at $t\to -\infty$ , and one point of inflection. Geometrically, this means that for $s\not=0$ for one of the horizontal half-lines (positive or negative) there is exactly one intersection of terms, and on the other half-line there are 0,1 or 2 intersections. Thus, the derivative may have one, two or three roots, with two roots when $g'(t)=g''(t)=0,$ or $$\begin{cases} \dfrac td - \dfrac{t+s}{\sqrt{t^2+2st+1}} = 0\\ \dfrac1d-\dfrac{1-s^2}{(t^2+2st+1)^{3/2}}=0,\\ \end{cases}$$ $$\begin{cases} (t^2-d^2)(t+s)^2 + t^2(1-s^2) = 0\\[4pt] \dfrac1d-\dfrac{(1-s^2)t^3}{d^3(t+s)^3}=0, \end{cases}$$ $$\begin{cases} t+s=\sqrt[3]{\dfrac{1-s^2}{d^2}}t\\[4pt] d^2-t^2=(1-s^2)\left(\sqrt[3]{\dfrac{d^2}{1-s^2}}\,\right)^2, \end{cases}$$ $$\begin{cases} t=\dfrac{s}{\sqrt[3]{\dfrac{1-s^2}{d^2}}-1}\\[4pt] \dfrac{s^2}{\left(\sqrt[3]{\dfrac{1-s^2}{d^2}}-1\right)^2} = d^2-d\sqrt[3]{d(1-s^2)}, \end{cases}$$ $$s^2=\left(d^{2/3}-\sqrt[3]{1-s^2}\right)^3,$$ $$d=\left(\sqrt[3]{s^2}+\sqrt[3]{1-s^2}\right)^{3/2}.\qquad(1)$$ Function $(1)$ determines values $d$ for $s\in(-1,1)$ when multiple root exists, but according graphs show that the resulting stationary point is a saddle. Thus, in considering case, the function in question has either one minimum or two minima and maximum.

To answer how many extrema $f$ has, and of which nature they are, we look at the zeroes of the derivative $$0 = f'(x) = 2x - \frac{a(ax + b \sin(\theta) )}{\sqrt{(ax + b\sin(\theta))^2+(b \cos(\theta))^2}}$$ Squaring, and clearing denominators, gives $$4 x^2 [ (ax + b\sin(\theta))^2+(b \cos(\theta))^2 ] = a^2 (ax + b \sin(\theta) )^2$$

However this will also generate solutions for the case with negative sign $-2x$: $$0 = f'(x) = - 2x - \frac{a(ax + b \sin(\theta) )}{\sqrt{(ax + b\sin(\theta))^2+(b \cos(\theta))^2}}$$ Therefore, we additionally must require (since the root is positive) $${\rm{sign}}(x) = {\rm{sign}}(ax + b \sin(\theta))$$

Formal methods to find the the zeroes of quartics exist, however they are tedious to elaborate. Here, a solution is presented after linear transformations which do not affect the number and nature of the solutions.

Obviously, since the leading term in $f(x)$ is $x^2$, we have $f(x) \to \infty$ for $|x| \to \infty$. Hence $f(x)$ must have either only one minimum or two minima and one maximum (the OP's claim). Saddle points are possible.

Substituting $y = \frac ab x + \sin(\theta)$ gives ${\rm{sign}}(y - \sin(\theta)) = {\rm{sign}}(y)$ or $y \notin (0 \ldots \sin(\theta))$ and $$(y - \sin(\theta))^2 [ y^2+ (\cos(\theta))^2 ] = \frac{a^4}{4 b^2} y^2$$ Hence it is evident that the extrema do not depend on $a$ and $b$ separately, but on $q \stackrel{def}{=} \frac{a^4}{4 b^2}$ giving $$(y - \sin(\theta))^2 [ y^2+ (\cos(\theta))^2 ] = q\; y^2$$ Let us first look at four special cases and exclude them later.

Case 1: $q = 1$; $\theta = k \pi$; $k \in \cal{Z}$

This gives $$y^2 [ y^2+ 1 ] = y^2$$ and in turn only one extremum $y^* = 0$.

Case 2: $q > 1$; $\theta = k \pi$; $k \in \cal{Z}$ This gives $$y^2 [ y^2+ 1 ] = q \; y^2$$ and in turn three extrema $y^*_1 = 0$; $y^*_2 = \sqrt{q-1}$ ; $y^*_3 = -\sqrt{q-1}$.

Case 3: $q < 1$; $\theta = k \pi$; $k \in \cal{Z}$ This gives $$y^2 [ y^2+ 1 ] = q \; y^2$$ and in turn only one extremum $y^*_1 = 0$ since the other two solutions in case 2 have no real roots.

Case 4: $\theta = \pi/2 + k \pi$; $k \in \cal{Z}$

This is easier to view in the original formulation: $$f(x) = x^2 - \sqrt{(ax + b (-1)^k)^2} =x^2 - ax - b (-1)^k = (x-a/2)^2 - a^2/4 - b (-1)^k$$ which clearly has one minimum.

Case 5: $\theta \neq k \pi/2$; $k \in \cal{Z}$. This excludes the previous four cases and discusses the general case. Let us further substitute $y = z\sin(\theta)$ which gives ${\rm{sign}}(z - 1) = {\rm{sign}}(z)$ which is $$z \notin (0 \ldots 1)$$ and $$z^2 (\sin(\theta))^2+ (\cos(\theta))^2 = q\; \frac{z^2}{(z - 1)^2}$$ The number of solutions (i.e. extrema) can now be obtained from discussing both sides of this equation. To get a general overview, the following graph displays both the LHS (parabola, in red) for $\theta = \pi/4$ and the RHS (blue, diverging at $z=1$) for $q=6$:

It shows that there are four intersections of the curves. However, since $z \notin \{0,1\}$ is required, only three of those will be extrema.

For other values of $q$ and $\theta$ some general trends hold. Since at $z=0$, LHS=$(\cos(\theta))^2 > 0$ and RHS = 0, the two intersections for $z>0$ will always remain. Since, due to the singularity at $z=1$, they always are in the regions $z \in (0 \ldots 1)$ and $z > 1$, only the latter is an extremum.

For the extrema with $z<0$, we have three possibilities:

1. $q$ large: two extrema with $z<0$, as in the picture
2. the LHS and RHS curves touch: one extremum (saddle point) with $z<0$
3. the LHS and RHS curves do not intersect: no extremum with $z<0$

Together with the one extremum for $z>1$, this gives three (case 1) or one (case 3) extrema.

The condition for case 2. (touch) can be obtained by equating a) both the LHS and RHS and b) their derivatives. The latter gives

$$z (\sin(\theta))^2 = - q\; \frac{z}{(z - 1)^3}$$ or $$z = 1 - \sqrt[3] \frac{q}{(\sin(\theta))^2 }$$ We insert this in a), the equation to be equated, which can be written $$(\sin(\theta))^2+ (\cos(\theta))^2 / z^2 = q\; \frac{1}{(z - 1)^2}$$ Then we have $$(\sin(\theta))^2+ \frac{(\cos(\theta))^2}{(1 - \sqrt[3] \frac{q}{(\sin(\theta))^2 })^2} = q\; (\frac{(\sin(\theta))^2 }{q})^{2/3}$$ or $$(\sin(\theta))^2+ \frac{(\cos(\theta))^2}{(1 - \sqrt[3] \frac{q}{(\sin(\theta))^2 })^2} - q^{1/3}\; (\sin(\theta))^{4/3} = 0$$

EDIT: The solution given by Yuri Negometyanov reads, in variables $q, \theta$:

$$q = (\sin(\theta))^{2/3} + (\cos(\theta))^{2/3})^3$$

and the two formulations given above and by Yuri can be shown to be identical.

The solutions $\theta, q$ to this equation are determined by MATLAB and plotted below:

Now the $q$-condition for 2. (saddle point at $z<0$) is known, 1. (two extrema at $z<0$) will be obtained for larger $q$ than in the curve and 3. (no extremum at $z<0$) for smaller $q$ than in the curve. This is what is required to determine the number of extrema in the regions.

For $q<1$, there will always be no extremum for $z<0$, i.e. only one minimum in total. For $q>4$, there will always be two extrema for $z<0$, i.e. only three extrema in total.

Now the following statement of the OP can be discussed: "Experimenting numerically, I have found that if we set a,b such that $a^2>2b$ and increase $\theta$ from zero to $\pi/2$ we will go from having 3 zero's for $f′(x)$ to 1 and back to 3 again."

Obviously the OP has chosen $q>1$, however (he didn't say that) this must also have been a $q<4$, since, as the graph shows, then indeed, increasing $\theta$ from zero to $\pi/2$, one goes through the regions of 3 extrema into 1 extremum and then back to 3 extrema. If we had $q>4$, then, increasing $\theta$ from zero to $\pi/2$, one always stays in regions of 3 extrema.

Let us now give an example for the behavior of the orginal curve $f(x)$ near the "critical" values of $q$ and $\theta$.

An example point on the curve above is $q = 3.57588, \theta = 0.5$. With this value for $q$, we can choose $b = 1/2$ and $a = q^{1/4} = 1.3751$. Then we obtain a saddle point, as shown here:

and in more detail here:

Increasing $a$ slightly to $a = 1.4$ increases $q$, and we have an additional maximum and a minimum, as shown here:

Decreasing $a$ slightly to $a = 1.35$ decreases $q$, and we have nothing since the saddle point vanishes, as shown here: