首页 > 代码库 > lua
lua
\documentclass[border=5]{standalone}
\usepackage{tikz}
\directlua{ function coth (i)%定义双曲正切
return math.cosh(i) / math.sinh(i) endfunction brillouin (J, x) if x == 0 then return 0 else return (2*J+1)/(2*J)*coth((2*J+1)/(2*J)*x) - 1/(2*J)*coth(1/(2*J)*x) end end } \pgfmathdeclarefunction{Brillouin}{2}{% \edef\pgfmathresult{% \directlua{tex.print("" .. brillouin(#1,#2))}% }% } \begin{document} \begin{tikzpicture}[x=2cm/10] \draw [help lines] (-5,0) -- (10,0); \draw [help lines, -stealth] (0,-1) -- (0,1.5); \draw [densely dotted] (0,{ Brillouin(1, 100)} ) -- ++(10,0); \draw [red] plot [domain=-5:10, samples=100] (\x, { Brillouin(1, \x)}); \draw [green] plot [domain=-5:10, samples=100] (\x, { Brillouin(5, \x)}); \draw [blue] plot [domain=-5:10, samples=100] (\x, { Brillouin(50, \x)}); \end{tikzpicture} \end{document}
lua
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。