Problem 443
Hard Curve Sketching

Find the extrema of f(x) = (frac12-x) cos x+ sin x

Find the extrema of $\displaystyle f(x) = \left(\frac12-x\right)\cos x+\sin x-\frac{x^{2}-x}{4}$.

Explanation of Method

The derivative factors into a linear and a trigonometric part.

Step 1: The derivative, factored

\[ f'(x) = -\cos x-\left(\frac12-x\right)\sin x+\cos x-\frac{2x-1}{4} = \left(x-\frac12\right)\sin x-\frac{2x-1}{4}, \] and taking out the common factor $2x-1$: \[f'(x) = \frac{2x-1}{2}\sin x-\frac{2x-1}{4} = \frac{\bigl(2x-1\bigr)\bigl(2\sin x-1\bigr)}{4}. \tag{1}\]

Step 2: Critical points

\[ x = \frac12; \qquad \sin x = \frac12 \;\Longrightarrow\; x = \frac{\pi}{6}+2k\pi \ \text{ or }\ x = \frac{5\pi}{6}+2k\pi, \qquad k\in\mathbb{Z}. \]

Step 3: Sign of the derivative

By (1) the sign of $f'$ is the product of the signs of $2x-1$ and $2\sin x-1$. The first is negative to the left of $\tfrac12$ and positive to the right; the second is positive exactly on the intervals $\left(\tfrac{\pi}{6}+2k\pi,\ \tfrac{5\pi}{6}+2k\pi\right)$. Hence

\[ x\gt \frac12:\ \operatorname{sign}f' = \operatorname{sign}\bigl(2\sin x-1\bigr); \qquad x\lt \frac12:\ \operatorname{sign}f' = -\operatorname{sign}\bigl(2\sin x-1\bigr). \tag{2} \]

The linear factor reverses the pattern on the left half-line — which is why the two sides must be classified separately.

Step 4: To the right of $\tfrac12$

There $f'$ has the sign of $2\sin x-1$, so at each point where $\sin x$ crosses $\tfrac12$ upwards the derivative goes from $-$ to $+$, and where it crosses downwards from $+$ to $-$:

\[ x = \frac{\pi}{6}+2k\pi \ (k\ge0):\ \text{minima}; \qquad x = \frac{5\pi}{6}+2k\pi \ (k\ge0):\ \text{maxima}. \]

Step 5: To the left of $\tfrac12$

There the sign is reversed, so the roles of the two families are exchanged: \[x = \frac{\pi}{6}+2k\pi \ (k\le-1):\ \text{maxima}; \qquad x = \frac{5\pi}{6}+2k\pi \ (k\le-1):\ \text{minima}.\]

Step 6: The point $x = \tfrac12$

Just to the left, $2x-1\lt 0$ and $2\sin x-1\lt 0$ (since $\sin\tfrac12 = 0.4794\lt \tfrac12$), so $f'\gt 0$; just to the right, $2x-1\gt 0$ while $2\sin x-1$ is still negative up to $x = \tfrac{\pi}{6}$, so $f'\lt 0$. The change from $+$ to $-$ makes it a local maximum:

\[ f\!\left(\frac12\right) = \sin\frac12+\frac{1}{16} = 0.5419255. \]

The neighbouring minimum at $x = \dfrac{\pi}{6} = 0.5236$ is astonishingly close to it: \[f\!\left(\frac{\pi}{6}\right) = \frac12+\frac{\pi}{24}-\frac{\pi^{2}}{144}+\frac{\sqrt3\bigl(3-\pi\bigr)}{12} = 0.5419236,\] the two values differing by less than $2\cdot10^{-6}$: a tiny dip squeezed between $x = \tfrac12$ and $x = \tfrac{\pi}{6}$.

Step 7: Global behaviour

The quadratic term dominates at both ends. Since $\bigl|\bigl(\tfrac12-x\bigr)\cos x+\sin x\bigr|\le|x|+\tfrac32$, \[f(x) \le |x|+\frac32-\frac{x^{2}}{4}+\frac{x}{4} \le \frac{5|x|}{4}+\frac32-\frac{x^{2}}{4} \longrightarrow -\infty \quad (|x|\to\infty). \tag{3}\]

So there is no global minimum. But a global maximum does exist: by (3), $f(x)\lt -4$ once $|x|\ge8$, so the largest value is attained among the finitely many critical points in $\bigl[-8,8\bigr]$, whose values are

\[ -7.3819,\quad -3.8121,\quad 0.5419,\quad 0.5419,\quad 1.2753,\quad -14.8432 \] at $x = \tfrac{5\pi}{6}-2\pi,\ \tfrac{\pi}{6}-2\pi,\ \tfrac12,\ \tfrac{\pi}{6},\ \tfrac{5\pi}{6},\ \tfrac{\pi}{6}+2\pi$. The largest is \[ f\!\left(\frac{5\pi}{6}\right) = \frac12+\frac{5\pi}{24}-\frac{25\pi^{2}}{144}+\frac{\sqrt3\bigl(5\pi-3\bigr)}{12} = 1.2752620. \]

Step 8: Verification

\[f'\!\left(\tfrac{\pi}{6}-2\pi\mp0.01\right) = \pm0.054:\ \text{a maximum at } \tfrac{\pi}{6}-2\pi,\ \text{not a minimum} \;\;\checkmark\]

\[f'\!\left(\tfrac{5\pi}{6}-2\pi\mp0.01\right) = \mp0.036:\ \text{a minimum there} \;\;\checkmark\]

\[f(\pm30) = -223.0,\ -226.8;\ \text{a scan of } \bigl[-40,40\bigr] \text{ gives the largest value } 1.2752620 \text{ at } x = \tfrac{5\pi}{6} \;\;\checkmark\]


Result

Final answer:

\[\boxed{\,f' = \frac{\bigl(2x-1\bigr)\bigl(2\sin x-1\bigr)}{4}\,}\]

Final answer:

\[\boxed{\,x>\tfrac12:\ \text{minima at } \tfrac{\pi}{6}+2k\pi,\ \text{maxima at } \tfrac{5\pi}{6}+2k\pi; \qquad x<\tfrac12:\ \text{the reverse}\,}\]

Final answer:

\[\boxed{\,\text{local maximum } f\!\left(\tfrac12\right) = \sin\tfrac12+\tfrac1{16}; \qquad \max_{\mathbb{R}}f = f\!\left(\tfrac{5\pi}{6}\right) = 1.2752620; \qquad \text{no minimum}\,}\]

Remark

Remark. Two traps are worth naming. First, the factor $2x-1$ flips the sign pattern, so the same trigonometric condition $\sin x = \tfrac12$ produces minima on one side of $x = \tfrac12$ and maxima on the other. Second, the parabola $-\tfrac{x^{2}}{4}$ drags the function to $-\infty$ in both directions — the local extreme values do not grow without bound — and a continuous function tending to $-\infty$ at both ends must attain a greatest value, here $1.2753$ at $x = \tfrac{5\pi}{6}$.