Finding the range of $f(x)=x+\frac{1}{x}$. How to take into account the discontinuity at $x=0$? The task is: Determine the range of values ​​of the function
$$f(x)=x+\frac{1}{x}$$
I did this:
$   y=f(x)=x+\frac{1}{x}\\y=\frac{x^2+1}{x}\;/\cdot x\\x^2-xy+1=0\\D=b^2-4ac\ge0\\y^2-4\ge0\Longrightarrow y\le -2\; \vee \; y\ge 2
   $
Question :

It is not clear to me how nowhere did we take into account that for $x = 0$ the function is not defined, ie. how are we sure that the codomain of a given function will be equal to those values ​​of $y$− a for which the solutions of the quadratic equation $x^2−xy+1 = 0 $ are real? Is there any reason why this is so?

No other approach to the task (other than this template) is known to me. I would really like to know another way (which is not based on a template) of approaching this type of task.
Thanks in advance !
 A: We have that for $x>0$
$$\lim_{x\to 0^+ }f(x)=\infty\quad\lim_{x\to \infty }f(x)=\infty$$
moreover by rearrangement inequality (or by AM-GM) we can see that
$$f(x)=x+\frac1x=1\cdot x+1\cdot \frac1x \ge x\cdot \frac1x+1\cdot 1=2$$
with equality for $x=1$.
Therefore for $x>0$, $f(x)$ has a positive minimum equal to $2$ and its range is $[2,\infty)$.
Finally, since the function is odd and not defined at $x=0$, we can conclude that its range is
$$(-\infty,-2]\cup[2,\infty)$$
A: Your approach can be justified:

*

*You have already shown that if $f(x) = y$ then necessarily $x^2-xy+1 = 0$ and therefore $y^2 \ge 4$.


*On the other hand, if $y^2 \ge 4$ then $x^2-xy+1 = 0$ has a solution $x$, and that solution cannot be zero. Therefore $f(x) = y$ for some $x$ in the domain of $f$.
Putting it together, the range of $f$ is the set of all $y$ with $y^2 \ge 4$, that is $(-\infty, -2] \cup [2, \infty)$.
A: The function rule is not well defined when $x=0$.
Hence we let our domain be $\mathbb{R} \setminus \{0\}$. We can define our codomain to be $\mathbb{R}$, we just need our codomain to be a superset of the range.
Let $y$ be an element of the range, hence we must be able to find some real $x$ such that.
$$y=x+\frac1x$$
$$x^2-xy+1=0$$
For $x$ to be real, the discriminant is nonnegative, That is why we get the condition that we must have $y^2-4 \ge 0$ which is equivalent to $|y| \ge 2$.
For alternative, you can use AM-GM or calculus.
Notice that $f$ is an odd function, hence we can first study the restriction on the set of positive number.
Also, we have $f(x)=f(\frac1x)$, it suffices to study the behavior on $[1, \infty)$.
$$f'(x) = 1-\frac1{x^2} \ge 0 \text{ if } x \ge 1.$$
and $$\lim_{x \to \infty}f(x) = \infty$$
We know that $f(1)=2$, hence the range is $(-\infty, -2] \cup [2, \infty)$.
