使用 gnuplot/tikz 繪圖給出了 0.5 的奇怪偏移量

使用 gnuplot/tikz 繪圖給出了 0.5 的奇怪偏移量

我正在以普通格式繪製一些基本的高對稱性能帶結構tikz。正如您所看到的,每個函數的下限應為:

http://imgur.com/vf7r4rs

相反,繪製的函數顯示了不同的下限(見下圖),其差異恰好為.5。這是從哪裡來的?我在程式碼中找不到任何可能導致這種差異的錯誤。

http://imgur.com/yP8cwBN

\documentclass{article}

\usepackage{tikz,pgffor}
\usepackage{amsmath,mathtools}

\begin{document}
\begin{tikzpicture}
    \draw[->] (0,1) -- (3.25*pi,1);
    \draw[->] (0,1) -- (0,6.7);
    \node[below] at (0,1) {$\Gamma$};
    \node[above] at (0,6.7) {$E_k$ (eV)};
    \draw[-] (pi,6.7) -- (pi,1) node[below] {$\mathrm{X}$};
    \draw[-] (2*pi,6.7) -- (2*pi,1) node[below] {$\mathrm{M}$};
    \draw[-] (3*pi,6.7) -- (3*pi,1) node[below] {$\Gamma$};
    \foreach \i in {1,...,6}{
    \node at (-.3,\i) {$\mathllap{\i}$};
    \draw[-] (-.15,\i) -- (0,\i);
    }
    \draw[domain=0:pi] plot function{((2)+(-1))/2+.5*sqrt(((2)-(-1))*((2)-(-1))+16*1.5*((sin(x/2))*(sin(x/2))))};
    \draw[domain=pi:2*pi] plot function{((2)+(-1))/2+.5*sqrt(((2)-(-1))*((2)-(-1))+16*1.5*((sin(pi/2))*(sin(pi/2))+((sin((x-pi)/2))*(sin((x-pi)/2)))))};
    \draw[domain=2*pi:3*pi] plot[id=sin] function{((2)+(-1))/2+.5*sqrt(((2)-(-1))*((2)-(-1))+16*1.5*((sin(pi/2))*(sin(pi/2))+((sin((x-pi)/2))*(sin((x-pi)/2)))-((sin((x)/2))*(sin((x)/2)))))};
\end{tikzpicture}
\end{document}

答案1

如 Jake 指出的,gnuplot使用整數除法導致表達式((2)+(1))/2不等於((2.)+(1.))/2.,兩個表達式之間存在差異0.5

相關內容