\(P=4sin^2x+\sqrt{2}\left(sin2x.cos\frac{\pi}{4}+cos2x.sin\frac{\pi}{4}\right)\)
\(P=4sin^2x+sin2x+cos2x\)
\(P=2\left(1-cos2x\right)+sin2x+cos2x\)
\(P=2+sin2x-cos2x\)
\(P=2+\sqrt{2}sin\left(2x-\frac{\pi}{4}\right)\)
Do \(sin\left(2x-\frac{\pi}{4}\right)\le1\Rightarrow P\le2+\sqrt{2}\)
\(\Rightarrow P_{max}=2+\sqrt{2}\) khi \(sin\left(2x-\frac{\pi}{4}\right)=1\Leftrightarrow x=\frac{3\pi}{8}+k\pi\)