I would like to plot a linear function as y=40-0.2x and an hyperbola as y=5/x. How could I make it? I've tried, a code from this document in p. 160, but the curve wasn't in the same page with the axes.

**EDIT:** Having used the Tikz method mentionned below, I would like to make a graph for y=5/(x-1)+1.

The result as it is shown in Microsoft Mathematics is:

However, using LaTeX, I don't have the same result. My code is:

```
\documentclass[tikz,border=3mm]{standalone}
\usepackage[english,greek]{babel}
\usepackage{ucs}
\usepackage[utf8x]{inputenc}
\begin{document}
\begin{tikzpicture}[xscale=0.08,yscale=0.09,domain=0.140:60,samples=800]
\draw[->] (0,0) -- (65,0) node[below] {$x$};
\draw[->] (0,0) -- (0,35) node[left] {$y$};
\foreach \i in {10,20,...,50} {
\draw (\i,1) -- (\i,-1) node[below] {$\i$};
}
\foreach \i in {5,10,...,30} {
\draw (1,\i) -- (-1,\i) node[left] {$\i$};
}
\draw[green] plot (\x,{5/(\x-1)+1});
\end{tikzpicture}
\end{document}
```

Where is my fault?

## Best Answer

## Remarks

Keep in mind for both methods, that 5/x has a singularity at 0. At this point the function value will be infinity, which is kind of hard to draw for PGF and will therefore throw an error:

`! Package PGF Math Error: You've asked me to divide `5' by `0', but I cannot divide any number by `0' (in '{5/0}').`

`? Dimensions too large`

## Method 1: Using Ti

kZThe advantage of using Ti

kZ here is, that you can easily place nodes on the plot. The disadvantage is, that you have to scale x and y dimension, because else the drawing will be 220cm wide.## Implementation

## Output

## Method 2: Using PGFPlots

This is much more elegant and the code is much shorter.

## Implementation

## Output

## Method 3: PSTricks (Just for fun)

Using the package

`pst-plot`

you get access to advanced plotting features. Also PSTricks is much faster than TikZ for plotting, because it makes use of the Postscript language.## Implementation

Compile with

`xelatex`

or`latex -> dvips -> ps2pdf`

.