We are given the equation
\[
x + \frac{1}{x} = 3, \quad x \neq 0.
\]
Multiply both sides by \( x \) (since \( x \neq 0 \)) to eliminate the fraction:
\[
x^2 + 1 = 3x.
\]
Now, rearrange the terms to form a quadratic equation:
\[
x^2 - 3x + 1 = 0.
\]
We can solve this quadratic equation using the quadratic formula:
\[
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a},
\]
where \( a = 1 \), \( b = -3 \), and \( c = 1 \).
Substitute the values of \( a \), \( b \), and \( c \) into the quadratic formula:
\[
x = \frac{-(-3) \pm \sqrt{(-3)^2 - 4(1)(1)}}{2(1)} = \frac{3 \pm \sqrt{9 - 4}}{2} = \frac{3 \pm \sqrt{5}}{2}.
\]
Thus, the roots of the equation are
\[
x = \frac{3 + \sqrt{5}}{2} \quad \text{and} \quad x = \frac{3 - \sqrt{5}}{2}.
\]
Conclusion:
The roots of the equation are \( x = \frac{3 + \sqrt{5}}{2} \) and \( x = \frac{3 - \sqrt{5}}{2} \).