我如何在 LaTeX 中绘制这两个相交函数的图?

我如何在 LaTeX 中绘制这两个相交函数的图?

在图形上,两个相交函数看起来是指数函数,其中三个点用虚线标记

\documentclass{article}
\usepackage{tikz}
\usepackage{geometry}
\usepackage{pgfplots}
\begin{document}
    \begin{tikzpicture} 
        \draw[thick,->] (0,0) -- (8.5,0) node[anchor=north west] {x};
        \draw[thick,->] (0,0) -- (0,8.5) node[anchor=south east] {y};
        \draw (1,5) arc (85:5:5cm);
        
    \end{tikzpicture}
\end{document}

答案1

欢迎来到 TeX.SE!!!

例如,声明一个指数函数(看起来像你的),并使用几个\foreach以避免重复代码。

像这样:

\documentclass[tikz,border=2mm]{standalone}
\tikzset{declare function={myexp(\u,\v)=0.5+0.5*exp(\u*\v);}}

\begin{document}
\begin{tikzpicture}[line cap=round,line join=round]
% axes
\draw[latex-latex,thick] (-2,4) node[below left]
   {$\begin{array}{c}D(p)\\C(p)\end{array}$}|- node[below] {\strut$0$} (2,0) node[below] {\strut$p$};
% functions and labels
\foreach[count=\j]\i in {C,D}
{
  \pgfmathsetmacro\k{2*\j-3}
  \draw[thick] plot[domain=-1.8:1.8] (\x,{myexp(\x,\k)});
  \draw[-latex] (1.5,{myexp(1.5,\k)}) --++ (0.5,0.5) node[right] {$\i(p)$};
}
% points
\foreach[count=\j from -1]\i in {1,0,2}
  \draw[dashed] (\j,0) node[below] {\strut$p_\i$} -- (\j,{max(myexp(\j,-1),myexp(\j,1))});
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

欢迎来到 TeX:SE!

看看以下解决方案是否是您想要的:

%\documentclass{article}
\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}

\begin{document}
    \begin{tikzpicture}[
       arl/.style = {-{Straight Barb[angle=60:2pt 3]}},
       arr/.style = {{Straight Barb[angle=60:2pt 3]}-, shorten <=2pt},
every node/.append style = {align=center}
                        ]
\draw[arl] (0,0) node[below left] {$0$} 
                 -- (9,0) node[below left] {$p$};
\draw[arl] (0,0) -- (0,6) node[below left] {$D(p)$\\$C(p)$};
% curves
\draw[thick] plot[domain=1:7] (\x, 0.1*\x*\x);
\draw[thick] plot[domain=7:1] (8-\x, 0.1*\x*\x);
    \draw[arr]  (6.6,0.1*6.6*6.6) -- ++ (1,-0.5) node[right] {$D(p)$};
    \draw[arr]  (6.6,0.1*1.4*1.4) -- ++ (1,+0.5) node[right] {$C(p)$};
\coordinate (p1) at (2,0.1*2*2);
\coordinate (p0) at (4,0.1*4*4);
\coordinate (p2) at (6,0.1*2*2);
\draw[densely dashed]   
    (p1) -- (p1 |- 0,0) node[below] {$p_1$}
    (p0) -- (p0 |- 0,0) node[below] {$p_0$}
    (p2) -- (p2 |- 0,0) node[below] {$p_2$};
    \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容