MA0001/Exercise 5/figures/1b.tex

38 lines
774 B
TeX

\begin{tikzpicture} [
% declare function={
% func(\x)= (\x >= -3) * (\x^2) +
% and(\x < -3) * (-\x);
% }
]
\begin{axis}[
xlabel = $x$, ylabel = $y$,
width = 10cm, height=10cm,
axis lines = middle,
grid,
xmin=-9, xmax=5,
ymin=-7, ymax=7,
legend pos=outer north east,
legend style={cells={align=left}}
]
\addplot [
blue,
no marks,
domain= -3:100
]{2*x};
\addplot [
blue,
no marks,
domain= -100:-3
]{-x};
\addplot+[blue,mark=*,mark options={fill=white}] (-3,3);
\addplot+[blue,mark=*] (-3,-6);
\addlegendentry{$g(x) = \begin{cases}
2x\text{, hvis } x \geq -3 \\
-x \text{, hvis } x < -3
\end{cases}$ \\}
\end{axis}
\end{tikzpicture}