答案1
这是给你一个开始。x
间隔边界的位置存储在列表中。
\documentclass[tikz,border=3mm]{standalone}
\begin{document}
\begin{tikzpicture}[declare function={f(\x)=0.4+0.2*sin(\x*120)+0.05*\x;}]
\def\mylist{0,3,4.5,5.75,7.5}
\draw[dashed]foreach \X in \mylist { (\X,-0.2) -- (\X,2)};
\draw plot[domain={{\mylist}[0]}:{{\mylist}[1]},smooth]
(\x,{f(\x)});
\draw plot[domain={{\mylist}[1]}:{{\mylist}[2]},smooth]
(\x,{0.7-1/(\x-{\mylist}[3])});
\draw plot[domain={{\mylist}[2]}:{{\mylist}[3]},smooth]
(\x,{0.6*(\x-{\mylist}[2])+0.6});
\draw plot[domain={{\mylist}[3]}:{{\mylist}[4]},smooth]
(\x,{-0.2*pow(\x-({\mylist}[3]+{\mylist}[4])/2,2)+0.5});
\draw plot[domain={{\mylist}[0]-1}:{{\mylist}[0]},smooth]
(\x,{-0.2*pow(\x-(2*{\mylist}[0]-1)/2,2)+1});
\draw ({min(\mylist)-2},0) -- ({max(\mylist)+1},0);
\draw[red,stealth-] ({{\mylist}[0]},{f({\mylist}[0])}) -- ++ (-1,0.25)
node[left]{$v^+_{j-\frac{1}{2}}$};
\draw[red,stealth-] ({{\mylist}[1]},{f({\mylist}[1])}) -- ++ (-1,1)
node[above left]{$v^-_{j+\frac{1}{2}}$};
\path ({{\mylist}[0]},-0.2) node[below]{$x_{j-\frac{1}{2}}$}
({{\mylist}[1]},-0.2) node[below]{$x_{j+\frac{1}{2}}$};
\end{tikzpicture}
\end{document}