# Drawing a graph with tikz

How would one draw a f(x)=1/x graph in tikz?

Any help would be really appreciated, thank you!

• Welcome to TeX.SX! Have a look at pgfplots and the countless examples out there. – TeXnician Mar 19 '17 at 15:33
• If my solution solved your problem (and I think so according to your newer question), consider accepting my answer. – TeXnician Mar 19 '17 at 17:05

## 2 Answers \documentclass[a4paper]{article}
\usepackage{pgfplots}
\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{axis}%
[
grid=major,
x=5mm,
y=5mm,
xtick={-5,-4,...,5},
xmin=-5,
xmax=5,
xlabel={\tiny $x$},
axis x line=middle,
ytick={-5,-4,...,5},
tick label style={font=\tiny},
ymin=-5,
ymax=5,
ylabel={\scriptsize $f(x)=1/x$},
axis y line=middle,
no markers,
samples=100,
domain=-5:5,
restrict y to domain=-5:5
]
\addplot[thick,samples=400] (x,{1/x});
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}


You could try this (just adjust the domain to your needs). For further customizations look for pgfplots. \documentclass{article}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}
\addplot[smooth,domain=0:1] {1/x};
\end{axis}
\end{tikzpicture}

\end{document}