# how to plot complicated function

i know how to draw axis and everything else except the function here , please give me hint to plot this function

Thanks for the help

• Could you please add a minimal example of what you managed to do? – CarLaTeX Jun 19 at 5:03

Is this what you want?

\documentclass[tikz,border=1mm]{standalone}
\usepackage{amsmath,amssymb}
\begin{document}
\begin{tikzpicture}[x=4cm,y=5cm]
\begin{scope}
\clip (-.2,-.2) rectangle (1.6,1.2);
\draw[dashed,magenta]
(0,0) .. controls +(0:.3) and +(181:1.75) .. (1.5,.97);
\draw[blue] (0,0) .. controls +(0:.25) and +(180:1.8) ..
(1.5,.97);
\end{scope}

\foreach \i in {.1,.2,...,1.5}
\draw (\i,0)--+(90:1mm);
\foreach \i in {0.3,0.6,0.9,1.2,1.5}
\draw (\i,0) node[below]{$\i$}--+(90:2mm);

\foreach \j in {.1,.2,...,1.1}
\draw (0,\j)--+(0:1mm);
\foreach \j in {0.2,0.4,0.6,0.8,1}
\draw (0,\j) node[left]{$\j$}--+(0:2mm);

\draw (0,1.1)--(0,0)--(1.5,0);
\draw[red,dotted,thick] (0,1)--+(0:1.5);
\path (0,0) node[below]{$0$} node[left]{$0$};

\draw[blue] (.7,.7)--++(0:.4) node[right]{Debye};
\draw[magenta,dashed]
(.7,.6)--++(0:.4) node[right]{Einstein};

\path
(current bounding box.west) coordinate (W)
(current bounding box.south) coordinate (S);
\path
(W)++(90:.1) node[left=5mm,rotate=90]{$\dfrac{C_V}{3NK}$}
(S) node[below=-4mm]{$T/\theta$};

\end{tikzpicture}
\end{document}

• thanks a lot , i just needed to see how to plot these functions – Quintis Jun 19 at 15:19
• btw how did u exactly draw this picture without using the function ? – Quintis Jun 19 at 15:24
• I simply looked at you figure and use '\draw controls', controlling curve until getting similar to your figure – Black Mild Jun 19 at 16:00
• One should mention that this function is known, see e.g. en.wikipedia.org/wiki/Debye_model. In the case when the function is known I personally prefer to plot it and not to reconstruct it with curves, which is fine for unknown functions. – user121799 Jun 19 at 16:19

You could declare a function and plot it. The relevant function is well known, see e.g. this Wikipedia article.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}[
declare function={
cV(\T,\TD,\a,\b) =
(\a/(\T/\TD))^2 * exp(\b/(\T/\TD)) / (exp(\b/(\T/\TD))-1)^2;
},
]
\begin{axis}[
xlabel={$T/T_\mathrm{D}$},
ylabel={$c_V/(3Nk_\mathrm{B})$},
legend style={at={(0.9,0.6)}},
domain=0.001:1.5,
samples=101,
smooth,
]

\legend{
Debye,
Einstein,
}
\end{axis}
\end{tikzpicture}
\end{document}


• Oh i see so declaring function would solve everything huh ? , i appreciate a lot – Quintis Jun 19 at 5:22
• @Quintis You do not have to declare it. But in this case it is worthwhile because you plot the same function twice with slightly different parameters. – user121799 Jun 19 at 5:25
• Woow, thanks marmot! Is \legend a new command of the version 1.16? Because I've never heard about it (I always use \addlegendentry, pros, cons?). – manooooh Jun 19 at 16:36
• @manooooh \legend is slightly shorter. (Actually this was added by Stefan Pinnow, whom I thank for all edits except for the removal of tikz in \documentclass[tikz,border=3.14mm]{standalone} since this does not only load tikz but also declares tikz to be a standalone environment, which is important when doing e.g. animations). – user121799 Jun 19 at 16:41
• @BlackMild No, pgfplots uses the fpu library, which allows you to deal with large and small numbers. You can also load and use the fpu library with TikZ. However, pgfplots does this automatically and many things behind the scenes, so it is arguably more convenient to use. – user121799 Jun 28 at 18:23