Example 2. Let $x$ be a positive real number, then the minimum value of the function $y=x^{2}-x+\frac{1}{x}$ is $\qquad$ - (1995, National Junior High School Competition)
- $y=x^{2}-x+\frac{1}{x}$ $=(x-1)^{2}+\left(\sqrt{x}-\frac{1}{\sqrt{x}}\right)^{2}+1$.

From the above equation, it is known that when $x-1=0$ and $\sqrt{x}-\frac{1}{\sqrt{x}}$ $=0$, i.e., $x=1$, $y$ takes the minimum value of 1.