
画像をスケーリングしたf
閉区間上で定義された区分線形関数のコードがあります。[-4, 12].
2/5
同じグラフに、任意の数 をg
表す別の区分関数をプロットします。 の領域の 6 つの異なる「部分」に放物線をプロットします。 コードには、 の前に が付いたこれらのコマンドがあります。 これらのコマンドのいずれかを実行すると、エラー メッセージが表示されます。$\int_{2}^{x} f(t) \, dt$
$-4 \leq x \leq 12$
f
%
f
と はg
を使用して簡単にプロットできることは知っています。ただし、pgfplots
だけを使用してプロットできるようにしたいと思います。TikZ
\documentclass{amsart}
\usepackage{amsmath}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
%A piecewise linear function is drawn over the interval [-4, 12]. (The figure is magnified by 2/5.)
\draw ({-4*(2/5)},{-4*(2/5)}) -- (0,{4*(2/5)}) -- ({2*(2/5)},0) -- ({4*(2/5)},{4*(2/5)}) -- ({8*(2/5)},{-4*(2/5)})
-- ({10*(2/5)},0) -- ({12*(2/5)},{-4*(2/5)});
%Two points on the graph are drawn.
\coordinate (left_endpoint) at ({-4*(2/5)},{-4*(2/5)});
\draw[fill] (left_endpoint) circle [radius=1.5pt];
\coordinate (right_endpoint) at ({12*(2/5)},{-4*(2/5)});
\draw[fill] (right_endpoint) circle [radius=1.5pt];
%The graph for the area function "starting at 2" is drawn. It is defined on 6 "pieces" of the
%domain of f.
%\draw[color=blue] plot [domain=-4:0] ({(2/5)*(\x)}, {(2/5)*((\x)^2 + 4*x - 4)});
%\draw[color=blue] plot [domain=0:2] ({(2/5)*(\x)}, {(2/5)*(-(\x)^2 + 4*x - 4)});
%\draw[color=blue] plot [domain=2:4] ({(2/5)*(\x)}, {(2/5)*((\x)^2 - 4*x + 4)});
%\draw[color=blue] plot [domain=4:8] ({(2/5)*(\x)}, {(2/5)*(-(\x)^2 + 12*x - 28)});
%\draw[color=blue] plot [domain=8:10] ({(2/5)*(\x)}, {(2/5)*((\x)^2 - 20*x + 100)});
%\draw[color=blue] plot [domain=10:12] ({(2/5)*(\x)}, {(2/5)*(-(\x)^2 + 20*x - 100)});
%Tick marks are drawn along the y-axis.
\draw ($(0,{-4*(2/5)}) +(-2pt,0)$) -- ($(0,{-4*(2/5)}) +(2pt,0)$);
\path node[anchor=east, inner sep=0, font=\footnotesize] at ($(0,{-4*(2/5)}) +(-2pt,0) +(-0.15,0)$){$-4$};
\draw ($(0,{4*(2/5)}) +(-2pt,0)$) -- ($(0,{4*(2/5)}) +(2pt,0)$);
\path node[anchor=east, inner sep=0, font=\footnotesize] at ($(0,{4*(2/5)}) +(-2pt,0) +(-0.15,0)$){4};
%The axes are drawn.
\draw[latex-latex] ($(0,{-4*(2/5)}) +(0pt,-12.5pt)$) -- ($(0,{4*(2/5)}) +(0pt,12.5pt)$) node[above right]{$y$};
\draw[latex-latex] ($({-4*(2/5)},0) +(-12.5pt,0pt)$) -- ($({12*(2/5)},0) +(12.5pt,0pt)$) node[below right]{$x$};
\end{tikzpicture}
\end{document}
答え1
これが期待通りかどうかは分かりませんがx
、\x
\documentclass{amsart}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
%A piecewise linear function is drawn over the interval [-4, 12]. (The figure is magnified by 2/5.)
\draw ({-4*(2/5)},{-4*(2/5)}) -- (0,{4*(2/5)}) -- ({2*(2/5)},0) -- ({4*(2/5)},{4*(2/5)}) -- ({8*(2/5)},{-4*(2/5)})
-- ({10*(2/5)},0) -- ({12*(2/5)},{-4*(2/5)});
%Two points on the graph are drawn.
\coordinate (left_endpoint) at ({-4*(2/5)},{-4*(2/5)});
\draw[fill] (left_endpoint) circle [radius=1.5pt];
\coordinate (right_endpoint) at ({12*(2/5)},{-4*(2/5)});
\draw[fill] (right_endpoint) circle [radius=1.5pt];
%The graph for the area function "starting at 2" is drawn. It is defined on 6 "pieces" of the
%domain of f.
\draw[color=blue] plot [domain=-4:0] ({(2/5)*(\x)}, {(2/5)*((\x)^2 + 4*\x - 4)});
\draw[color=blue] plot [domain=0:2] ({(2/5)*(\x)}, {(2/5)*(-(\x)^2 + 4*\x - 4)});
\draw[color=blue] plot [domain=2:4] ({(2/5)*(\x)}, {(2/5)*((\x)^2 - 4*\x + 4)});
\draw[color=blue] plot [domain=4:8] ({(2/5)*(\x)}, {(2/5)*(-(\x)^2 + 12*\x - 28)});
\draw[color=blue] plot [domain=8:10] ({(2/5)*(\x)}, {(2/5)*((\x)^2 - 20*\x + 100)});
\draw[color=blue] plot [domain=10:12] ({(2/5)*(\x)}, {(2/5)*(-(\x)^2 + 20*\x - 100)});
%Tick marks are drawn along the y-axis.
\draw ($(0,{-4*(2/5)}) +(-2pt,0)$) -- ($(0,{-4*(2/5)}) +(2pt,0)$);
\path node[anchor=east, inner sep=0, font=\footnotesize] at ($(0,{-4*(2/5)}) +(-2pt,0) +(-0.15,0)$){$-4$};
\draw ($(0,{4*(2/5)}) +(-2pt,0)$) -- ($(0,{4*(2/5)}) +(2pt,0)$);
\path node[anchor=east, inner sep=0, font=\footnotesize] at ($(0,{4*(2/5)}) +(-2pt,0) +(-0.15,0)$){4};
%The axes are drawn.
\draw[latex-latex] ($(0,{-4*(2/5)}) +(0pt,-12.5pt)$) -- ($(0,{4*(2/5)}) +(0pt,12.5pt)$) node[above right]{$y$};
\draw[latex-latex] ($({-4*(2/5)},0) +(-12.5pt,0pt)$) -- ($({12*(2/5)},0) +(12.5pt,0pt)$) node[below right]{$x$};
\end{tikzpicture}
\end{document}