我怎样才能绘制近似导数图?

我怎样才能绘制近似导数图?

在此处输入图片描述

\usepackage{tikz}
\usetikzlibrary{arrows}

\begin{frame}{Forward-Difference Formula to Approximate $f'(x_0)$}
        \begin{block}{} 
        \begin{tikzpicture}
            \draw[->, thick] (-1,0) -- (10,0) node(xline)[right] {$x$};
            \draw[->, thick] (0,-1) -- (0,6)  node(yline)[above] {$y$};  
        \end{tikzpicture}
        \end{block}
    \end{frame} 

答案1

所以,如果你从零开始,独自完成这件事可能会有点困难。我会给你一份我在衍生课程中给我的学生的资料。

它使用tikz-euclide包来方便我个人使用,但您可以使用普通的 TikZ 代码来完成。

当然,只要稍加理解,您就可以轻松地根据自己的意愿调整此代码。

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}

\begin{document}
    
    \begin{tikzpicture}[scale=2]
    
        \draw (-1,0) -- (7.5,0) (0,-.5) -- (0,4.5); % Axis
        \node[below left=2pt and 2pt] at (0,0) {$O$}; % Origin
        
        % Function curve        
        \begin{scope}       
            \clip (-1,0) rectangle (7.5,4.5);
            \draw[line width=1.2pt,color=blue,smooth,samples=100,domain=-2.5:7.5] plot(\x,{0.3*((\x)-3.5)*((\x)-3.5)+0.5}); 
        \end{scope}
        
        \def\xA{2.5} \def\yA{0.8}
        \coordinate (A) at (\xA,\yA);
        \draw[dashed] (\xA,0) node[below=2pt] {$a$} -- (A) -- (0,\yA) node[left] {$f(a)$};
                
        \def\xM{6.5} \def\yM{3.2}
        \coordinate (M) at (\xM,\yM);
        \draw[dashed] (\xM,0) node[below] {$a+h$} -- (M) -- (0,\yM) node[left] {$f(a+h)$};
        \begin{scope}       
            \clip (0.5,-0.5) rectangle (7.5,4.5);

            % Series of lines all through point A
            \foreach \xN/\yN in {6.5/3.2,6/2.38,5.5/1.7,5/1.18,4.5/0.8,4/0.58,3.5/0.5}
                {
                \coordinate (N) at (\xN,\yN);
                \tkzDrawPoint[size=8](N)
                \tkzDrawLine[add=2 and 3,color=red](A,N)
                }   
        \end{scope}
        
        \draw[line width=1.2pt,color=green!50!black,smooth,samples=100,domain=0.5:5] plot(\x,{-0.6*(\x)+2.3}) node[above] {$T$};            
        
        \tkzDrawPoints[size=8](A,M)
        \tkzLabelPoint[above=3pt](A){$A$}
        \tkzLabelPoint[above left](M){$M$}
        
        %%%%Arrows alongside the curve
        \foreach \a/\b in {6.55/6.9, 6/6.35, 5.5/5.85, 4.9/5.35, 4.35/4.75}
            {
            \draw[<-,>=stealth,line width=1pt,color=orange,smooth,samples=100,domain=\a:\b] plot(\x,{0.32*((\x)-3.95)*((\x)-3.95)+0.55});
            }
        
    \end{tikzpicture}
\end{document}

衍生物

相关内容