Given,
$y =2 \tan x-\tan ^{2} x\,...(i)$
$\therefore \, \frac{d y}{d x} =2 \sec ^{2} \,x-2 \tan x \cdot \sec ^{2} \,x$
$=2 \sec ^{2} x(1-\tan x)\,...(ii)$
At point of maxima,
$\frac{d y}{d x}=0$
$2 \sec ^{2} x(1-\tan x)=0$ [From E (ii)]
$\therefore \, x=\frac{\pi}{4}, \frac{\pi}{2} $
Here, $x=\frac{\pi}{2}$ is not possible]
$\therefore\, x=\frac{\pi}{4} $
$[\because x \in\left[0, \frac{\pi}{2}\right]$ (given)
Now, $\frac{d^{2} y}{d x^{2}}=4 \sec x \cdot \sec x \cdot \tan x(1-\tan x) +2 \sec ^{2} x\left(0-\sec ^{2} x\right)$
$=4 \sec ^{2} \,x \tan\, x-4 \sec ^{2} x \tan ^{2} x-2 \sec ^{4} \,x$
$\left.\therefore \frac{d^{2} y}{d x^{2}}\right|_{x-\frac{\pi}{4}}= 4 \sec ^{2} \frac{\pi}{4} \tan \frac{\pi}{4}-4 \sec ^{2} \frac{\pi}{4} $
$ \tan ^{2} \frac{\pi}{4}-2 \sec ^{4} \frac{\pi}{4} $
$= 4(\sqrt{2})^{2} \cdot 1-4(\sqrt{2})^{2} \cdot(1)^{2}-2 \cdot(\sqrt{2})^{4} $
$= 8-8-8$
$=-8$ which is negative.
$\therefore$ At $x=\frac{\pi}{4}$, function $y=2 \tan x-\tan ^{2} x$
has maximum value.
$\therefore$ Maximum value of function at point $x=\frac{\pi}{4}$, will be
$[y]_{x-\frac{\pi}{4}}=1$