I've seen in `TikZ`

and `pgf`

Manual for version 1.18 a code for graphing some functions but it does not provide an example for a rational function.

Can someone help me graph `$x+\frac{1}{x}$`

?

Skip to content
# [Tex/LaTex] latex code for graphing rational function

###### Related Question

graphicspgfplotsplottikz-pgf

I've seen in `TikZ`

and `pgf`

Manual for version 1.18 a code for graphing some functions but it does not provide an example for a rational function.

Can someone help me graph `$x+\frac{1}{x}$`

?

- [Tex/LaTex] pgfplots “Dimension too large” returned when plotting rational function
- [Tex/LaTex] Graphing trigonometric functions, axes labeled with tick marks
- [Tex/LaTex] Plotting f(x) = sin x and f(x) = cos x on pgf/tikz
- [Tex/LaTex] How to plot max/min function in LaTeX
- Smooth the graph $\chi(t)=\sen(\pi t)\exp\left(\dfrac{-1}{\sen^2(\pi t)}\right)$

## Best Answer

Here is a quick adaptation from example from p. 225 (section 19.5) of

`pgfmanual`

(for version 2.10). Notice that due to a singularity at zero I gave the formula twice; I do not know whether this can be avoided. (Well, itcan, by giving the domain and the number of samples so that no sample is taken at zero, but this would befarfrom elegant!)