# Importing luaqd library in LuaTeX

I am looking for easy way to importing lqd or some other similar library in LuaTeX so that It can used in LaTeX. The lmapm library is wriiten by Luiz Figueiredo, one of the authors of the Lua language. It helps a lot in lua. It uses quad-double precision with 212 mantissa bits and gives about 64 decimals. For example, qd.pi gives value of pi to higher precision in lua after including it in lua.

That's what you can do in Linux. In other operative systems it shouldn't be too different.

Newer versions of LuaTeX allow you to do it. First, supposing you have installed Lua 5.x already, make the .so files and installing them (optional, but preferred):

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


Then load your libraries in your .tex files using require. Here's a nice example from the test included with the libraries, the calculus of the Ramanujan's constant:

%!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}


• How to do it on Windows operating system? – user61681 Apr 24 at 9:03