I think a similar question has been asked already, but I do not understand the answer(s). Given the graph of a function, I would like to draw the graph of the inverse function, that is I would like to be able to reflect for example a parabola with respect to the line y=x. Is there any way to achieve this in tikzpicture that is not too complicated? Thanks!
Marmot, given what you wrote below I thought this should be completely straightforward. (Thanks a lot, your answer was crystal clear!) All I did was to (1) copy your code twice and use mini pages (2) change the domain to be (-pi/2,pi/2) for the sine and (-1,1) for the arcsine (3) comment out the arcsine and the sine each in one fo the minipages so as not to have both graphs together.
Why is this not working???
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{backgrounds}
\begin{document}
\begin{minipage}{.5\textwidth}
\begin{tikzpicture}[
declare function={ f(\x) = sin(\x*180/pi); %<- enter your function right here
a=1;
b=1;
reflectedx(\x) = -\x+2*a*(\x*a+f(\x)*b)/(pow(a,2)+pow(b,2));
reflectedy(\x) = -f(\x)+2*b*(\x*a+f(\x)*b)/(pow(a,2)+pow(b,2));
},
]
\begin{scope}[local bounding box=plots]
\draw [blue,thick] plot [domain=-pi/2:pi/2,samples=100,smooth] ({\x}, {f(\x)});
%\draw [red,thick] plot [domain=-4:4,samples=100,smooth] ({reflectedx(\x)},{reflectedy(\x)});
\end{scope}
\begin{scope}[on background layer]
\draw[thick,-latex] ([xshift=-2mm]plots.west |-0,0) -- ([xshift=4mm]plots.east
|-0,0) node[below left]{$x$};
\draw[thick,-latex] ([yshift=-2mm]plots.south -|0,0) -- ([yshift=4mm]plots.north
-|0,0) node[below left]{$y$};
\end{scope}
\end{tikzpicture}
\end{minipage}
\begin{minipage}{.5\textwidth}
\begin{tikzpicture}[
declare function={ f(\x) = sin(\x*180/pi); %<- enter your function right here
a=1;
b=1;
reflectedx(\x) = -\x+2*a*(\x*a+f(\x)*b)/(pow(a,2)+pow(b,2));
reflectedy(\x) = -f(\x)+2*b*(\x*a+f(\x)*b)/(pow(a,2)+pow(b,2));
},
]
\begin{scope}[local bounding box=plots]
%\draw [blue,thick] plot [domain=-4:4,samples=100,smooth] ({\x}, {f(\x)});
\draw [red,thick] plot [domain=-1:1,samples=100,smooth] ({reflectedx(\x)},{reflectedy(\x)});
\end{scope}
\begin{scope}[on background layer]
\draw[thick,-latex] ([xshift=-2mm]plots.west |-0,0) -- ([xshift=4mm]plots.east
|-0,0) node[below left]{$x$};
\draw[thick,-latex] ([yshift=-2mm]plots.south -|0,0) -- ([yshift=4mm]plots.north
-|0,0) node[below left]{$y$};
\end{scope}
\end{tikzpicture}
\end{minipage}
\end{document}



\parametricplotcommand from thepst-plotmodule ofpstricks. – Bernard Sep 05 '18 at 21:36