a)\(\Rightarrow P=\dfrac{\left(\sqrt{x}+1\right)\left(\sqrt{x}+2\right)+2\sqrt{x}\left(\sqrt{x}-2\right)-5\sqrt{x}-2}{\left(\sqrt{x}+2\right)\left(\sqrt{x}-2\right)}\)
\(=\dfrac{x+3\sqrt{x}+2+2x-4\sqrt{x}-5\sqrt{x}-2}{\left(\sqrt{x}+2\right)\left(\sqrt{x}-2\right)}\)
\(=\dfrac{3x-6\sqrt{x}}{\left(\sqrt{x}+2\right)\left(\sqrt{x}-2\right)}=\dfrac{3\sqrt{x}\left(\sqrt{x}-2\right)}{\left(\sqrt{x}-2\right)\left(\sqrt{x}+2\right)}=\dfrac{3\sqrt{x}}{\sqrt{x}+2}\)
b) Ta có P=2
\(\dfrac{\Leftrightarrow3\sqrt{x}}{\sqrt{x}+2}=2\Leftrightarrow3\sqrt{x}=2\sqrt{x}+4\)
\(\Leftrightarrow\sqrt{x}=4\Leftrightarrow x=16\left(n\right)\)
Vậy x=16 thì P=2