答案1
第一部分:正方形里面的圆
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\node(square) [minimum size=6cm, draw=lightgray, fill=gray!25!white] at (0,0) {} node[above right=60pt] {$\Omega^+$};
\node(circle) [circle, inner sep=1.5cm, draw=blue!50!black, fill=white] at (0,0) {$\Omega^-$};
\draw[-latex] ($ (square.west) + (-1,1) $) node[anchor=east] {$\partial \Omega$} -- ($ (square.west) + (0,1) $);
\draw[-latex] ($ (square.west) + (-1,0) $) node[anchor=east] {$\Gamma$} -- (circle.west);
\end{tikzpicture}
\end{document}
第二部分:插值
对于插值,使用这个在线工具为了得到点的坐标,进行了拟合并计算了intersections
垂直线和函数。
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,intersections}
\tikzset{every node/.style={font=\strut}}
\begin{document}
\begin{tikzpicture}
% lines and labels
\foreach \x/\labb [count=\i from 1] in {0/$\tilde{u}(-2\Delta x)$, 3/$\tilde{u}(-\Delta x)$, 6/$\tilde{u}(0)$, 8/$\tilde{u}(x_i-x_l)$, 9/, 12/}{
\draw[name path=p-\i, draw=lightgray] (\x,1) node (la-\i) {} -- (\x,5) node (lb-\i) {};
\node[above=5pt] at (lb-\i) {\labb};
}
\foreach \y in {1,...,5}{
\draw[draw=lightgray] (0,\y) node (lc-\y) {} -- (12,\y);
}
\draw[draw=blue, fill=cyan] (la-1) circle[radius=2.5pt] node[below=5pt] {$u_{i-2}$};
\draw[draw=blue, fill=cyan] (la-2) circle[radius=2.5pt] node[below=5pt] {$u_{i-1}$};
\filldraw[blue] (la-3) circle[radius=2.5pt] node[below=5pt] {$u_i$};
\filldraw[red] (la-4) circle[radius=2.5pt] node[below=5pt] {$u_l$};
\draw[draw=gray, fill=lightgray] (la-5) circle[radius=2.5pt] node[below=5pt] {$u_{i+1}^G$};
\draw[draw=gray, fill=lightgray] (la-6) circle[radius=2.5pt] node[below=5pt] {$u_{i+2}^G$};
\draw[blue] (la-1) -- (la-2) -- (la-3);
\draw[blue] (la-4) -- (la-5) -- (la-6);
\draw[red] (la-3) -- (la-4);
\node[anchor=east] at ($ (lc-1)!0.5!(lc-2) $) {Constant};
\node[anchor=east] at ($ (lc-2)!0.5!(lc-3) $) {Linear};
\node[anchor=east] at ($ (lc-3)!0.5!(lc-4) $) {Quadratic};
\node[anchor=east] at ($ (lc-4)!0.5!(lc-5) $) {Cubic};
% functions and dots
\draw[name path=f-1, domain=0:12, smooth, variable=\x, green!50!black] plot ({\x}, {-0.002*\x^3 + 0.0268*\x^2 - 0.082*\x + 4.7259});
\draw[name path=f-2, domain=2.999:12.001, smooth, variable=\x, green!50!black] plot ({\x}, {-0.022*\x^2 + 0.2694*\x + 2.9558
});
\filldraw[lightgray] (0,3.691) circle [radius=2.5pt];
\draw[name path=f-3, domain=5.999:12.001, smooth, variable=\x, green!50!black] plot ({\x}, {-0.0391*\x + 2.763});
\filldraw[lightgray] (0,2.412) circle [radius=2.5pt];
\filldraw[lightgray] (3,2.301) circle [radius=2.5pt];
\draw[name path=f-4, domain=7.999:12.001, smooth, variable=\x, green!50!black] plot ({\x}, {1.75});
\filldraw[lightgray] (0,1.728) circle [radius=2.5pt];
\filldraw[lightgray] (3,1.603) circle [radius=2.5pt];
\filldraw[lightgray] (6,1.824) circle [radius=2.5pt];
% intersections
\foreach \i in {1,...,6}{
\path[name intersections={of=f-1 and p-\i,by=P-\i}];
\filldraw[green!50!black] (P-\i) circle[radius=2.5pt];
}
\foreach \i in {2,...,6}{
\path[name intersections={of=f-2 and p-\i,by=P-\i}];
\filldraw[green!50!black] (P-\i) circle[radius=2.5pt];
}
\foreach \i in {3,...,6}{
\path[name intersections={of=f-3 and p-\i,by=P-\i}];
\filldraw[green!50!black] (P-\i) circle[radius=2.5pt];
}
\foreach \i in {4,...,6}{
\path[name intersections={of=f-4 and p-\i,by=P-\i}];
\filldraw[green!50!black] (P-\i) circle[radius=2.5pt];
}
\end{tikzpicture}
\end{document}