图形帮助

图形帮助

在此处输入图片描述我使用 tikz 来创建数学图形。我希望在此处输入图片描述o 做这个,但我来的时间不长。你能帮我做一下吗?它不需要完全相同,但 xh、x、x+h 在 x 轴上相同,并且任何曲线都相似,不一定相同。

需要用这些词来代替:

后向差异 = bakover 前向差异 = framover 中心差异 = sentral

在此先感谢,真诚的 Tikz 爱好者


 \begin{tikzpicture} [>=stealth,
    declare function={f(\x)=-0.35+5*exp(\x/2)/exp(3);
        fprime(\x)=2.5*exp(\x/2)/exp(3);},
    dot/.style={circle,fill,inner sep=1pt},
    every pin edge/.style={thin}, scale=0.8]
  \path (0,0) coordinate[label=below left:{$O$}] (O)
     (0,5) coordinate (y) (6,0) coordinate (x);
  \draw[->,name path=x-axis] (-0.5,0) --  (x) node[below] {$x$};
  \draw[->] (0,-0.5) --  (y) node[left] {$y$};
  \draw[semithick,cyan,name path=curve] plot[variable=\x,domain=0.1:6,smooth]
   (\x,{f(\x)}) (5.8,{f(6)})node[black,left]{$y=f(x)$};
  \draw[red,dashed] (5.5,0) coordinate(x0) -- (5.5,{f(5.5)}) coordinate(p0)
  ($(p0)+(-1,{-1*fprime(5.5)})$) coordinate(p0');
  \draw[red,dashed] (intersection of p0--p0' and O--x) coordinate (x1)
  let \p1=(x1) in \pgfextra{\pgfmathsetmacro{\myx}{\x1/1cm}}
  (x1) -- (\myx,{f(\myx)}) coordinate(p1)
  ($(p1)+(-1,{-1*fprime(\myx)})$) coordinate(p1');
  \draw[red,dashed] (intersection of p1--p1' and O--x) coordinate (x2)
  let \p1=(x2) in \pgfextra{\pgfmathsetmacro{\myx}{\x1/1cm}}
  (x2) -- (\myx,{f(\myx)}) coordinate(p2)
  ($(p2)+(-1,{-1*fprime(\myx)})$) coordinate(p2');
  \path (intersection of p2--p2' and O--x) coordinate (x3)
    (x3) node[draw,label=below:{$x-h$}] {}
  foreach \X [count=\Y] in {0,...,2}
   {(x\X) node[draw,label=below:{$x_{\X}$}] {}
    (x\Y) edge[red,shorten >=-1em,shorten <=-1ex] (p\X)
   \ifnum\X=0   
   (p\X) node[dot,cyan,label={[black]left:{$(x+h,f(x+h)$}}] {}
   \else
   (p\X) node[dot,cyan,pin={[black]90:{$(x-h,f(x-h))$}}] {}
   \fi 
   };
  \path[name intersections={of=curve and x-axis,by=i}]
   (i) node[green,draw,fill,
   ,pin={[black,align=center]89:}](in){};  
 \end{tikzpicture}

答案1

像这样:

在此处输入图片描述

使用以下代码:

\documentclass[tikz, border=1cm]{standalone}

\begin{document}
    \begin{tikzpicture}[domain=0:2*pi]
        \draw[->] (-0.2,0) -- (6.7,0) node[right] {$x$};
        \draw[->] (0,-1.2) -- (0,6.7) node[above] {$y$};

        \draw[cyan,line width=3pt] plot[domain=1:6] (\x,-.25*\x*\x+1.5*\x+2.25);
        \draw[,dashed,latex-latex] (1.7,0)--(1.7,4.08) node[pos=.5,fill=white,rotate=90] () {\small $f(x-h)$};
        \draw[dashed,latex-latex] (3.2,0)--(3.2,4.49) node[pos=.5,fill=white,rotate=90] () {\small $f(x)$};
        \draw[dashed,latex-latex] (4.7,0)--(4.7,3.78) node[pos=.5,fill=white,rotate=90] () {\small $f(x+h)$};
        \node at (1.7,-.15) {\small $x-h$ };
        \node at (3.2,-.15) {\small $x$ };
        \node at (4.7,-.15) {\small $x+h$ };
        \draw[green] (1,3.89)--(4.5,4.85) node[above] () {\small bakover};
        \draw[red] (1,5.53)--(6,3.16) node[] () {\small fremover};
        \draw[brown] (1,4.15)--(6,3.65) node[above] () {\small central};
    \end{tikzpicture}
    
\end{document}

抱歉!我开始使用我的代码了……

相关内容