
Eu tenho o código para uma função linear por partes f
definida no intervalo fechado [-4, 12].
pelo qual dimensionei a imagem 2/5
.
No mesmo gráfico, quero traçar outra função por partes g
representando $\int_{2}^{x} f(t) \, dt$
qualquer número $-4 \leq x \leq 12$
. Envolve traçar parábolas em seis "peças" diferentes do domínio de f
. Eu tenho os comandos para estes no código, precedidos por um %
. Recebo uma mensagem de erro ao implementar qualquer um desses comandos.
Eu sei disso f
e g
posso facilmente ser plotado usando pgfplots
. Eu gostaria de poder plotá-los usando apenas TikZ
, no entanto.
\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}
Responder1
Não tenho certeza se isso é o que você esperava, mas corrigindo o x
problema\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}