首页 > 其他 > 详细

lua

时间:2014-12-01 00:41:51      阅读:284      评论:0      收藏:0      [点我收藏+]
\documentclass[border=5]{standalone} 
\usepackage{tikz}
\directlua{ function coth (i)%定义双曲正切
return math.cosh(i) / math.sinh(i) end function 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

原文:http://www.cnblogs.com/wangshixi12/p/4134021.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!