I wish to draw a function graph,
The analytical formula of the function is:
I can use the following code to draw an image of a specific function
But I want to be concise, how to define a letter n,
Draw the corresponding function image with the change of n
I think it should be realized by loop, but I don’t know how to do it
What needs to be done?
\documentclass{book}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[->,>=stealth] (-4,0) -- (4,0) node[below] {$ x $};
\draw[->,>=stealth] (0,-0.5) -- (0,4) node[right] {$ y $};
\fill (0,0) circle ( 0 ) node[ below left ] { $ O $ } ;
\draw[ domain= -3 : 3 ,samples= 300 ] plot ( \x, {
abs(\x)
});
\draw[ domain= -3 : 3 ,samples= 300 ] plot ( \x, {
abs(\x) + abs((\x) + 1)
});
\draw[ domain= -3 : 3 ,samples= 300 ] plot ( \x, {
abs(\x) + abs((\x) + 1) + abs((\x) + 2)
});
\end{tikzpicture}
\end{document}