Finding the maximum of $f(x) = 2x\cos(2x) - (x-2)^2, [2,4]$ using the first derivative. I am currently stuck on the part where we make the first derivative of a function equal to 0, I tried using trig identities and such but I couldn't make it zero.
we are given the following:
$$f(x) = 2x\cos(2x) - (x-2)^2, [2,4]$$
I find the derivative to be:
$$2\cos(2x) - 4x(\sin(2x)) - 2(x-2) = 0$$
At this point I am stuck with trying to either find the undefined or points in general that make the function (f'(x)) equal to 0. How do I approach solving for x?
 A: $$f'(x)=2\cos(2x)-4x\sin(2x)-2(x-2)$$
\begin{align}f''(x)&=-4x\sin(2x)-4\sin(2x)-8x\cos(2x)-2
\\&=-4(x+1)\sin(2x)-8x\cos(2x)-2\end{align}
$$\frac{f'(x)}{f"(x)}=-\frac{\cos(2x)-2x\sin(2x)-2(x-2)}{2(x+1)\sin(2x)+4x\cos(2x)+1}$$
From Newton's method
$$x_{n+1}=x_n-\frac{f'(x_n)}{f"(x_n)}$$
I have coded some simple python code here:
http://www.codeskulptor.org/#user42_uBhUshL1Zh_0.py 
the solution is roughly $3.13110627798$ and objective funciton  $4.98143395755$

A: Just for the fun and for your curiosity.
If you plot the derivative of the function as a function of $x$, you should notice that it does cancel close to $x=\pi$. $$f'(x)=2\cos(2x)-4x\sin(2x)-2(x-2)\implies f'(\pi)=6-2\pi$$ Sooner or later, you will learn that we can approximate functions using the so-called Pade approximants which are ratios of polynomials.
The simplest one would be $$f'(x) \approx \frac{-\frac{2 \left(19+2 \pi +16 \pi ^2\right) (x-\pi )}{1+4 \pi }-2 (\pi
   -3)}{1-\frac{6 (x-\pi )}{1+4 \pi }}$$ the solution of which being "simply" $$x=\frac{6+60 \pi -4 \pi ^2+32 \pi ^3}{38+4 \pi +32 \pi ^2}\approx 3.131107220$$ while the "exact"solution (Siong Thye Goh obtained it using Newton method) is $\approx 3.131106279$
