0

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

enter image description here

4
  • arctan is defined by atan. Using the property of complementary angles, you can graph arccot also.
    – user193767
    Commented Apr 9, 2020 at 21:18
  • what is "complementary angles" ? @JairoAraujo Commented Apr 9, 2020 at 21:21
  • please an example of one of them @JairoAraujo Commented 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.
    – Bernard
    Commented Apr 24, 2020 at 12:03

1 Answer 1

3

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}
\begin{tikzpicture}[trig format=rad,samples=101]
\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}

enter image description here

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}
\begin{axis}[trig format plots=rad,
    samples=101,
    unbounded coords=jump,
    xmin=-10,xmax=10,ymax=pi/2+0.5
    ]
\addplot[blue,thick,variable=\t,domain=-pi/2+0.1:pi/2-0.1] ({tan(\t)},\t);
\path (10,pi/2) node[above left]{$y=\arctan(x)$};
\addplot[red,dashed,thick,variable=\t,domain=-10:10] (\t,{atan(\t)});
\addplot[green!60!black,variable=\t,domain=-pi/2+0.1:pi/2-0.1] ({cot(\t)},\t);
\draw[green!60!black,dashed] (0,-2) -- (0,2);
\path (10,0) node[below left]{$y=\arccot(x)$};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

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,
    trig format plots=rad,
    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}
    ]
\addplot[blue,thick,variable=\t,domain=-pi/2+0.1:pi/2-0.1] ({tan(\t)},\t);
\addlegendentry{$y=\arctan(x)$}
%\addplot[red,dashed,thick,variable=\t,domain=-10:10] (\t,{atan(\t)});
\addplot[green!60!black,variable=\t,domain=-pi/2+0.1:pi/2-0.1] ({cot(\t)},\t);
\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}

enter image description here

12
  • can I draw tan with arctan ? Commented Apr 9, 2020 at 21:48
  • @lindaOiladali In principle, yes.
    – user194703
    Commented Apr 9, 2020 at 21:48
  • I added this: \addplot[blue,thick,variable=\t,domain=-pi/2+0.1:pi/2-0.1] (\t,{tan(\t)}); Commented Apr 9, 2020 at 21:51
  • 1
    @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.
    – user194703
    Commented Apr 9, 2020 at 22:06
  • 1
    @lindaOiladali I added a pgfplots version without box. This is the third question you are asking. The first one has gotten an excellent answer. The second one has gotten three answers, most of which are good and original. In the second question you were also able to add some code. None of the answers you have received so far have been accepted. I think you should at least consider accepting daleif's answer to the first question by clicking on the check mark on its left.
    – user194703
    Commented Apr 9, 2020 at 22:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .