在 LuaTeX 中導入 luaqd 庫

在 LuaTeX 中導入 luaqd 庫

我正在尋找簡單的導入方法勒克德或 LuaTeX 中的其他類似函式庫,以便它可以在 LaTeX 中使用。這左圖該庫由 Lua 語言的作者之一 Luiz Figueiredo 編寫。對lua有很大幫助。它使用具有 212 個尾數位的四雙精度,並提供大約 64 位小數。例如,qd.pi將 pi 值包含在 lua 中後,在 lua 中將其賦予更高的精度。

答案1

這就是您可以在 Linux 中執行的操作。在其他作業系統中,它不應該有太大的不同。

較新版本的 LuaTeX 允許您做到這一點。首先,假設您已經安裝了 Lua 5.x,請建立檔案.so並安裝它們(可選,但首選):

cd /path/to/qd/or/mapm
make
sudo make install

然後使用 載入您的庫到您的.tex文件中require。這是庫中包含的測試的一個很好的例子,拉馬努金常數:

%!TEX program = lualatex
\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage{luacode}
\begin{document}
\begin{luacode*}
--The same in case you use lmapm
qd = require "qd"
tex.print([==[Is $\exp(\pi\sqrt{163})$ an integer?]==])
tex.print("")
a=math.exp(math.pi*math.sqrt(163))
tex.print("fp",string.format("%.64e",a),"\nfrac",a-math.floor(a))
tex.print("")
a=qd.exp(qd.pi*qd.sqrt(163))
tex.print("qd",tostring(a),"\nfrac",tostring(a-qd.floor(a)))
tex.print("")
R=qd.new"2.625374126407687439999999999992500725971981856888793538563373369908627075374103782106479101186073129511813461e17"
tex.print("exact",tostring(R))
\end{luacode*}
\end{document}

在此輸入影像描述

相關內容