Ta có: \(P=\frac{x}{x-\sqrt{x}}+\frac{2}{x+2\sqrt{x}}+\frac{x+2}{\left(\sqrt{x}-1\right)\left(x+2\sqrt{x}\right)}\)
\(=\frac{x\left(x+2\sqrt{x}\right)}{\sqrt{x}\cdot\left(\sqrt{x}-1\right)\left(x+2\sqrt{x}\right)}+\frac{2\sqrt{x}\left(\sqrt{x}-1\right)}{\sqrt{x}\left(\sqrt{x}-1\right)\left(x+2\sqrt{x}\right)}+\frac{\sqrt{x}\left(x+2\right)}{\sqrt{x}\cdot\left(\sqrt{x}-1\right)\left(x+2\sqrt{x}\right)}\)
\(=\frac{x^2+2x\sqrt{x}+2x-2\sqrt{x}+x\sqrt{x}+2\sqrt{x}}{x\left(\sqrt{x}-1\right)\left(\sqrt{x}+2\right)}\)
\(=\frac{x^2+3x\sqrt{x}+2x}{x\left(\sqrt{x}-1\right)\left(\sqrt{x}+2\right)}\)
\(=\frac{x^2+x\sqrt{x}+2x\sqrt{x}+2x}{x\left(\sqrt{x}-1\right)\left(\sqrt{x}+2\right)}\)
\(=\frac{x\sqrt{x}\left(\sqrt{x}+1\right)+2x\left(\sqrt{x}+1\right)}{x\left(\sqrt{x}-1\right)\left(\sqrt{x}+2\right)}\)
\(=\frac{x\left(\sqrt{x}+1\right)\left(\sqrt{x}+2\right)}{x\left(\sqrt{x}-1\right)\left(\sqrt{x}+2\right)}\)
\(=\frac{\sqrt{x}+1}{\sqrt{x}-1}\)