Seite 1 von 1

Tikz > \addplot > Umkehrfunktion/swap axis

Verfasst: So 2. Sep 2018, 19:07
von MasterWizz
Hey Leute,

ich würde gern eine Funktion und ihre Inverse mit Tikz in einem Koordinatensystem ausgeben. Da sich die Inverse aber nicht geschlossen darstellen lässt, hab ich mir überlegt dafür einfach ausgehend vom Original die Achsen zu tauschen oder eine Spiegelung an y=x durchzuführen. Habt ihr eine Idee, wie sich das in tikz umsetzen lässt?

Vielen Dank schon mal!

Re: Tikz > \addplot > Umkehrfunktion/swap axis

Verfasst: Mo 3. Aug 2020, 10:22
von cis

Das ist ohne Weiteres möglich, wenn eine Funktion y=f(x) als Parameterfunktion aufgefasst wird, was immer in der Form (t, f(t)) möglich ist. Dann liefert der Tausch (f(t), t) die Umkehrfunktion.

5555555.png
\documentclass[margin=5pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}

\begin{document}
\begin{tikzpicture}[font=\footnotesize]
\begin{axis}[
axis equal,
axis lines = middle,
axis line style = {-latex},
enlarge x limits={abs=0.5},
enlarge y limits={abs=2, upper},
xlabel={$x$},
xlabel style={anchor=north west, inner sep=1pt},
ylabel={$y$},
ylabel style={anchor=east, inner sep=1pt},
minor xtick={-10,...,15},
minor ytick={-5,...,16},
xmin=-10, xmax=15.5,
ymin=-5.5, ymax=15.5,
samples=222,
]
\addplot[densely dashed, domain=-10:15]{x}; 

%\addplot[ultra thick]{x^2+exp(x)};
\addplot[variable=\t, red]({t},{t^2+exp(t)}) node[pos=0.19, anchor=west]{$f(x)=x^2+e^x$}; 
\addplot[variable=\t, blue]({t^2+exp(t)},{t}) node[pos=0.18, anchor=south]{$f^{-1}(x)$}; 
\end{axis}
\end{tikzpicture}
\end{document}