# graph of arctan and arccot with tikz?

Please how to draw the graph of the inverse function of tangent and cotangent functions with TikZ:

$arctan: \mathbb{R}\to ]-\pi/2,\pi/2[$ and $arccot :\mathbb{R}\to ]0,\pi[$


with TikZ.

i want to obtain something like this for arctan • arctan is defined by atan. Using the property of complementary angles, you can graph arccot also.
– user193767
Apr 9, 2020 at 21:18
• what is "complementary angles" ? @JairoAraujo Apr 9, 2020 at 21:21
• please an example of one of them @JairoAraujo Apr 9, 2020 at 21:24
• Unrelated to this question: I have a solution for the question you've recently deleted (layout of polynomial division in the French style, if I'm not mistaken). If you're interested, you can undelete or re-post it. Apr 24, 2020 at 12:03

You do not need anything special in order to plot the inverse function of a known function f(x). To see this, recall that the plot of f(x) can be seen as a parametric plot of

 (x,f(x))


Call now x=f^{-1}(t). Then this plot will be

 (f^{-1}(t),t) .


From this it follows that a plot

 (f(t),t)


is the same as

 (t,f^{-1}(t))


where we have, of course, to adjust the domains appropriately. So in order to plot arctan(x) (the pgf name of the function is atan, see JairoAraujo' comment, or atan2, which takes care of the quadrant), we can just plot

 (tan(t),t)


and for arccot

 (cot(t),t) .


This is is illustrated in this MWE

\documentclass[tikz,border=3mm]{standalone}
\usepackage{amsmath}
\DeclareMathOperator{\arccot}{arccot}
\begin{document}
\draw[blue,thick] plot[variable=\t,domain=-pi/2+0.1:pi/2-0.1] ({tan(\t)},\t);
\draw[red,dashed,thick] plot[variable=\t,domain=-10:10] (\t,{atan(\t)});
\path (8,pi/2) node[above]{$y=\arctan(x)$};
\draw plot[variable=\t,domain=-pi/2+0.1:-0.1] ({cot(\t)},\t);
\draw plot[variable=\t,domain=0.1:pi/2-0.1] ({cot(\t)},\t);
\path (8,0) node[below]{$y=\arccot(x)$};
\end{tikzpicture}
\end{document} The dashed red curve is just to show that "it works".

Of course, it makes a lot of sense to plot this with pgfplots.

\documentclass[tikz,border=3mm]{standalone}
\usepackage{amsmath}
\DeclareMathOperator{\arccot}{arccot}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
samples=101,
unbounded coords=jump,
xmin=-10,xmax=10,ymax=pi/2+0.5
]
\path (10,pi/2) node[above left]{$y=\arctan(x)$};
\draw[green!60!black,dashed] (0,-2) -- (0,2);
\path (10,0) node[below left]{$y=\arccot(x)$};
\end{axis}
\end{tikzpicture}
\end{document}


Or, per request without box and with a grid.

\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator{\arccot}{arccot}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[axis lines=middle,xlabel={$x$},ylabel={$y$},
width=0.9\textwidth,
samples=101,
unbounded coords=jump,
xmin=-pi,xmax=pi,
ymin=-pi/2-0.2,ymax=pi/2+0.5,
xtick={-pi/2,pi/2},xticklabels={$-\frac{\pi}{2}$,$\frac{\pi}{2}$},
ytick={-pi/2,pi/2},yticklabels={$-\frac{\pi}{2}$,$\frac{\pi}{2}$},
grid=major,grid style={densely dashed},
legend style={at={(0.01,0.99)},anchor=north west}
]
\addlegendentry{$y=\arctan(x)$}
\draw[green!60!black,dashed] (0,-2) -- (0,2);
\addlegendentry{$y=\arccot(x)$}
\end{axis}
\end{tikzpicture}
\caption{Standard'' branches of the multivalued functions $\arctan$ and $\arccot$.}
\end{figure}
\end{document}

• can I draw tan with arctan ? Apr 9, 2020 at 21:48
• @lindaOiladali Sorry, so far you have not posted any explicit code, and I always have to guess what you are doing. This isn't very efficient. I do not know what a "cadre" is . The y axis can be obtained by adding \draw[-stealth] (0,-2) -- (0,2) node[below left]{$y$};. If you post a minimal working example those who answer it can provide you with a solution that is tailor-made for your document, otherwise one has to guess, and then getting told that it does not fit in an unknown document setting is not that entertaining. The pgfplots solution is more versatile IMHO.