使用 TikZ 获取平方根函数的图形

使用 TikZ 获取平方根函数的图形

我希望平方根函数的图形增加得“更慢”——也许是“速度”的一半。

\documentclass{amsart}
\usepackage{mathtools,systeme,array}

\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes}


\usepackage{pgfplots}
\pgfplotsset{compat=1.11}


\begin{document}

If $f(x) = \sqrt{x}$ and $g(x) = \sqrt{8 - 4x}$, express $g$ in terms of $f$. Sketch both functions.
\vskip0.2in

\noindent {{\textbf{Solution}}
\begin{equation*}
g(x) =  \sqrt{8 - 4x}
=  \sqrt{4(2 - x)}
=  2\sqrt{2 - x}
= 2 f(2 - x) .
\end{equation*}
(The graph of $f(2 - x)$ is the reflection of the graph of $f(x - 2)$ across the vertical line $x = 2$.) \rule{1.5ex}{1.5ex}
\vskip0.2in


\noindent \hspace*{\fill}
\begin{tikzpicture}
\begin{axis}[width=3in,grid=both,grid style={line width=.1pt, draw=gray!10},clip=false,
    axis lines=middle,
    xmin=-25,xmax=25,
    ymin=-1,ymax=10.5,
    restrict y to domain=-1:10.5,
    xtick={-25,-20,...,30},
    xticklabels={, , , , , , , , , ,},
    ytick={-1,0,...,10},
    yticklabels={, , , , , , , , , ,},
    extra x ticks={2},
    extra x tick style={xticklabel style={font=\tiny,fill=white, circle, inner sep=1.5pt}},
    extra x tick labels={2},
    axis line style={latex-latex},
    axis line style={shorten >=-7.5pt, shorten <=-7.5pt},
    xlabel=$x$,
    ylabel=$y$,
    xlabel style={at={(ticklabel* cs:1)},anchor=north west},
    ylabel style={at={(ticklabel* cs:1)},anchor=south west}
]

\addplot[samples=501,domain=0:25] {sqrt(x)} node[anchor=south east,pos=0.75,font=\footnotesize]{$y=f(x)$};

\addplot[samples=501, line width=0.1pt, dashed, domain=2:27, blue] {sqrt(x - 2)} node[anchor=north west,pos=0.75,font=\footnotesize]{$y=f(x-2)$};

\addplot[samples=501, line width=0.1pt, loosely dashed, domain=-23:2, green] {sqrt(2 - x)} node[anchor=north east,pos=0,font=\footnotesize]{$y=f(2 - x)$};

\addplot[samples=501, domain=-23:2, green] {2 * sqrt(2 - x)} node[anchor=north east,pos=0,font=\footnotesize]{$y=g(x)$};


\end{axis}
\end{tikzpicture}

\end{document}

答案1

\documentclass{amsart}
\usepackage{mathtools}

\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes}


\usepackage{pgfplots}
\pgfplotsset{compat=1.11}


\begin{document}

\noindent {\textbf{40.) }}If $f(x) = \sqrt{x}$ and $g(x) = \sqrt{8 - 4x}$, express $g$ in terms of $f$. Sketch both functions.
\vskip0.2in

\noindent {{\textbf{Solution}}
\begin{equation*}
g(x) =  \sqrt{8 - 4x}
=  \sqrt{4(2 - x)}
=  2\sqrt{2 - x}
= 2 f(2 - x) .
\end{equation*}
(The graph of $f(2 - x)$ is the reflection of the graph of $f(x - 2)$ across the vertical line $x = 2$.) \rule{1.5ex}{1.5ex}
\vskip0.2in

\noindent \hspace*{\fill}
\begin{tikzpicture}
\begin{axis}[width=3in,grid=both,grid style={line width=.1pt, draw=gray!10},clip=false,
    x=0.15cm, y=0.2cm,
    axis lines=middle,
    xmin=-28,xmax=28,
    ymin=-2.5,ymax=10,
    restrict y to domain=-2.5:10,
    xtick={-25,-20,...,30},
    xticklabels={, , , , , , , , , ,},
    ytick={-2,-1,...,10},
    yticklabels={, , , , , , , , , ,},
    extra x ticks={2},
    extra x tick style={xticklabel style={font=\tiny,fill=white, circle, inner sep=1.5pt}},
    extra x tick labels={2},
    axis line style={latex-latex},
    axis line style={shorten >=-7.5pt, shorten <=-7.5pt},
    xlabel=$x$,
    ylabel=$y$,
    xlabel style={at={(ticklabel* cs:1)},anchor=north west},
    ylabel style={at={(ticklabel* cs:1)},anchor=south west}
]

\addplot[samples=501,domain=0:25] {sqrt(x)} node[anchor=south east,pos=0.75,font=\footnotesize]{$y=f(x)$};

\addplot[samples=501, line width=0.1pt, dashed, domain=2:27, blue] {sqrt(x - 2)} node[anchor=north west,pos=0.75,font=\footnotesize]{$y=f(x-2)$};

\addplot[samples=501, line width=0.1pt, loosely dashed, domain=-23:2, green] {sqrt(2 - x)} node[anchor=north east,pos=0,font=\footnotesize]{$y=f(2 - x)$};

\addplot[samples=501, domain=-23:2, green] {2 * sqrt(2 - x)} node[anchor=north east,pos=0,font=\footnotesize]{$y=g(x)$};


\end{axis}
\end{tikzpicture}
\hspace{\fill}

\end{document}

相关内容