I draw the graph of 1/|x| with the code:
\begin{tikzpicture}[>=latex, scale=0.3]
\draw[->] (-5,0)--(5,0)node[right]{$x$};
\draw[->] (0,-1)--(0,9)node[right]{$y$};
\draw [domain=-5:-1/8, samples=500, thick]
plot (\x, {-1/(\x)});
\draw [domain=1/8:5, samples=500, thick]
plot (\x, {1/(\x)});
\fill[black] (0,3) circle (4pt);
\end{tikzpicture}
But the resulting picture looks like this:
As you can see, it is not symmetric at the highest point. I wonder what causes this happen? And how can we fix this?
A similar problem also happens when I draw the graph of sin(1/x):
\begin{tikzpicture}[>=latex, scale=1.5]
\draw[->] (-2,0)--(2,0)node[right]{$x$};
\draw[->] (0,-2)--(0,2)node[right]{$y$};
\draw [domain=-1:-0.03, samples=1000, thick]
plot (\x, {sin(1/(\x) r)});
\draw [domain=0.03:1, samples=1000, thick]
plot (\x, {sin(1/(\x) r)});
\end{tikzpicture}
The resulting picture is:
The problem is that it doesn't look "soomth" when getting close to x=0. Is there a way to fix this?
\draw [domain=0.03:100, samples=1000, ultra thin] plot (1/\x, {sin(deg(\x))});
.