[Tex/LaTex] Plotting an atan function in TikZ

pgfplots

I have to plot the function f(x) = atan(x)-x/(1+x^2), but it won't come out right. By looking at previous questions, I have the code:

\documentclass[a4paper, norsk, 11pt]{article}
\usepackage{pgfplots}

\begin{tikzpicture}
\begin{axis}[
    domain=-10:10,
    xscale=1.5,yscale=1,
    xmin=-3, xmax=3,
    ymin=-100, ymax= 100,
    samples=1000,
    axis lines=center,
]
    \addplot+[mark=none] {atan(x) - x/(1+x^2)};
\end{axis}
\end{tikzpicture}  
\end{document}

The code generates this graph:

enter image description here

but it should look like this:

enter image description here

Anybody knows how to fix this?

Best Answer

The atan function returns the value in degrees. You need to convert it into radians:

\documentclass[a4paper,11pt]{article}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
    domain=-10:10,
    xscale=1.5,yscale=1,
    xmin=-6, xmax=6,
    ymin=-2, ymax= 2,
    samples=1000,
    axis lines=center,
]
    \addplot+[mark=none] {rad(atan(x)) - x/(1+x^2)};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here