\documentclass{article}
\usepackage{listings,color,booktabs,longtable,array,hyperref,multicol}
\usepackage[ left=1in, right=1in]{geometry}
\hypersetup{colorlinks,urlcolor=blue}
\lstset{frame=none,
	language=[LaTeX]{TeX},
  aboveskip=3mm,
  belowskip=3mm,
  showstringspaces=false,
  columns=flexible,
  basicstyle={\ttfamily},
  numbers=none,
  numberstyle=\tiny\color{gray},
  stringstyle=\color{mauve},
  breaklines=true,
  breakatwhitespace=true,
  tabsize=1
}
\usepackage[backend=bibtex]{biblatex}
\addbibresource{luamaths}
\begin{document}
\title{The luamaths Package in LaTeX}
\author{Chetan Shirore and Dr. Ajit Kumar}
\maketitle
\section{Introduction}\label{section:introduction}
The \verb|luamaths| package is developed to perform standard mathematical operations inside LaTeX documents using Lua. It provides an easy way to perform standard mathematical operations. There is no particular environment in the package for performing mathematical operations. The package commands can be used in any environment (including the mathematics environment). It is written in Lua, and tex file is to be compiled with LuaLatex engine. The time required for operations is not an issue while compiling with LuaLaTeX. There is no need to install Lua on the users system as tex distributions (TeXLive or MikTeX) come bundled with LuaLaTeX. It is useful to perform standard operations (addition, subtraction, multiplication, division, powers, roots etc.) in tex file itself. The package supports the nesting of commands for multiple operations. It can be modified or extended by writing custom Lua programs.

The Lua \cite{online.luaorg} programming language is a scripting language that can be embedded across platforms. With\verb|LuaTeX| \cite{online.luatex}  and\verb|luacode| \cite{online.luacode} packages, it is possible to use Lua in LaTeX. The TeX  \cite{online.tex} or LaTeX has scope for programming \cite{online.texscript}. However, with the weird internals of TeX, there are several limitations, especially for performing calculations on numbers in LaTeX documents. There are packages like \emph{pgf} \cite{online.pgf} and  \emph{xparse}  \cite{online.xparse} in LaTeX which provides some programming capabilities inside LaTeX documents. However, such packages do not provide the complete programming structure that Lua programming languages provide. The \verb|luacode| \cite{online.luacode}  package is used in its development apart from the \verb|luacode| package. There is no need to install Lua on users system as TeX distributions (TeXLive or MikTeX) come bundled with LuaLaTeX. The package can be modified or extended by writing custom Lua programs.


\section{Installation and License}

The installation of \verb|luamaths| package is similar to plain latex package, where the \texttt{.sty} file is in \LaTeX directory of texmf tree. The package can be included with \verb|\usepackage{luamaths}| command in the preamble of the LaTeX document. The TeX file is to be compiled using the LuaLaTeX engine.


The \verb|luamaths| package is released under the LaTeX Project Public License v1.3c or later. The complete license text is available at \url{http://www.latex-project.org/lppl.txt}. It is developed in Lua.  Lua is available as a certified open-source software. Its license is simple and liberal, which is compatible with GPL.

\section{Commands in the luamaths package}
Table \ref{tbl:opluamaths} lists operations in the \verb|luamaths| package.
\begin{center}
\begin{longtable}{llm{6cm}}
\toprule
\multicolumn{1}{c}{\textcolor{blue}{Function}} & \multicolumn{1}{l}{\textcolor{blue}{Command Format}} & \multicolumn{1}{c}{\textcolor{blue}{Description}}  \\
\toprule
\begin{lstlisting}
\mathOp
\end{lstlisting} &
\begin{lstlisting}
\mathOp{expression}
\end{lstlisting} & Evaluates mathematical expression. For example, \lstinline|\mathop{2+3}| will evaluate to 5. It supports usual operations like\lstinline| -, *,  \, ^ | etcetera, apart from the standard functions. \\
\midrule
\begin{lstlisting}
\mathAbs
\end{lstlisting} &
\begin{lstlisting}
\mathAbs{number}
\end{lstlisting} & Gives the absolute value of a real number.\\
\midrule
\begin{lstlisting}
\mathAcos
\end{lstlisting} &
\begin{lstlisting}
\mathAcos{number}
\end{lstlisting} & Gives the arc cosine of a real number in radians.\\
\midrule
\begin{lstlisting}
\mathAsin
\end{lstlisting} &
\begin{lstlisting}
\mathAsin{number}
\end{lstlisting} & Gives the arc sine of a real number in radians.\\
\midrule
\begin{lstlisting}
\mathAtan
\end{lstlisting} &
\begin{lstlisting}
\mathAtan{number}
\end{lstlisting} & Gives the arc tangent of a real number in radians.\\
\midrule
\begin{lstlisting}
\mathCeil
\end{lstlisting} &
\begin{lstlisting}
\mathCeil{number}
\end{lstlisting} & Gives the smallest integer greater than or equal to a real number.\\
\midrule
\begin{lstlisting}
\mathCos
\end{lstlisting} &
\begin{lstlisting}
\mathCos{number}
\end{lstlisting} & Gives the cosine of a real number.Here the number is in radians.\\
\midrule
\begin{lstlisting}
\mathExp
\end{lstlisting} &
\begin{lstlisting}
\mathExp{x}
\end{lstlisting} & Calculates \(\mathrm{e}^x \). Here \(\mathrm{e} \) is the Euler number.\\
\midrule
\begin{lstlisting}
\mathFloor
\end{lstlisting} &
\begin{lstlisting}
\mathFloor{number}
\end{lstlisting} & Gives the smallest integer less than or equal to a real number.\\
\midrule
\begin{lstlisting}
\mathInf
\end{lstlisting} & \begin{lstlisting}
\mathInf
\end{lstlisting} & The infinity.\\
\midrule
\begin{lstlisting}
\mathLog
\end{lstlisting} &
\begin{lstlisting}
\mathLog{x}
\end{lstlisting} & Calculates \(\log x \). Here the logarithm is to the natural base \(\mathrm{e} \).\\
\midrule
\begin{lstlisting}
\mathMax
\end{lstlisting} &
\begin{lstlisting}
\mathMax\end{lstlisting}\{\(x_1,x_2,\ldots,x_n\)\}
 & Gives the maximum of numbers \(x_1,x_2,\ldots,x_n\).\\
\midrule
\begin{lstlisting}
\mathMin
\end{lstlisting} &
\begin{lstlisting}
\mathMin\end{lstlisting}\{\(x_1,x_2,\ldots,x_n\)\}
 & Gives the minimum of numbers \(x_1,x_2,\ldots,x_n\).\\
\midrule
\begin{lstlisting}
\mathPi
\end{lstlisting} &
\begin{lstlisting}
\mathPi
\end{lstlisting} & Gives the numeric value of the constant \(\pi \). \\
\midrule
\begin{lstlisting}
\mathRad
\end{lstlisting} &
\begin{lstlisting}
\mathRad{degree}
\end{lstlisting} & Converts degrees into radians. \\
\midrule
\begin{lstlisting}
\mathRandom
\end{lstlisting} & \begin{lstlisting}
\mathRandom
\end{lstlisting} & Generates a random number between \(0 \) and \(1 \). \\
\midrule
\begin{lstlisting}
\mathRound
\end{lstlisting} &
\begin{lstlisting}
\mathRound{number}{digits}
\end{lstlisting} & It rounds off a real number to a specified number of digits. \\
\midrule
\begin{lstlisting}
\mathSin
\end{lstlisting} &
\begin{lstlisting}
\mathSin{number}
\end{lstlisting} & Gives the sine of a real number. Here the number is in radians.\\
\midrule
\begin{lstlisting}
\mathSqrt
\end{lstlisting} &
\begin{lstlisting}
\mathSqrt{number}
\end{lstlisting} & Gives the non-negative square root of a non-negative real number.\\
\midrule
\begin{lstlisting}
\mathTan
\end{lstlisting} &
\begin{lstlisting}
\mathTan{number}
\end{lstlisting} & Gives the tangent of a real number. Here the number is in radians.\\
\bottomrule
\caption{Operations in the luamaths package}
\label{tbl:opluamaths}
\end{longtable}
\end{center}
Numbers can also be entered in scientific notation. For example, the number \(1860000\) can be entered as \(1.86e6\), and the number \(0.000186\) can be entered as \(1.86e-4\).
\subsection{Illustrations of commands in the luamaths package}
Table \ref{tbl:illluamaths} illustrates operations in the \verb|luamaths| package with examples.
\begin{center}
\begin{longtable}{lc}
\toprule
\multicolumn{1}{c}{\textcolor{blue}{LaTeX input}} &\multicolumn{1}{c}{\textcolor{blue}{Output}}  \\
\toprule
\begin{lstlisting}
\mathOp{(3+3)^4-4}
\end{lstlisting} & \(1292.0\)\\
\midrule
\begin{lstlisting}
\mathAbs{-6.96}
\end{lstlisting} & \(6.96\)\\
\midrule


\begin{lstlisting}
\mathFloor{-6.9}
\end{lstlisting} & \(-7\) \\
\midrule

\begin{lstlisting}
\mathFloor{9.9}
\end{lstlisting} & \(9\)\\
\midrule


\begin{lstlisting}
\mathCeil{-9.9}
\end{lstlisting} &  \(-9\) \\
\midrule

\begin{lstlisting}
\mathCeil{6.3}
\end{lstlisting} &\(7\)\\
\midrule

\begin{lstlisting}
\mathRound{9.678884}{3}
\end{lstlisting} & \(9.679\)\\
\midrule

\begin{lstlisting}
\mathMax{20,30,100}
\end{lstlisting} &\(100\) \\
\midrule

\begin{lstlisting}
\mathMin{20,30,100}
\end{lstlisting} &\(20\)\\
\midrule


\begin{lstlisting}
\mathPi
\end{lstlisting} & \(3.1415926535898\)\\
\midrule


\begin{lstlisting}
\mathRound{\mathPi}{6}
\end{lstlisting} & \(3.141593\)\\
\midrule

\begin{lstlisting}
\mathInf
\end{lstlisting} & \(Inf\)\\
\midrule

\begin{lstlisting}
\mathOp{\mathInf/2}
\end{lstlisting} &\(Inf\) \\
\midrule

\begin{lstlisting}
\mathSqrt{9}
\end{lstlisting} & \(3.0\)\\
\midrule

\begin{lstlisting}
\mathLog{2}
\end{lstlisting} & \(0.69314718055995\)\\
\midrule

\begin{lstlisting}
\mathExp{3}
\end{lstlisting} & \(20.085536923188\) \\
\midrule

\begin{lstlisting}
\mathRad{1800}
\end{lstlisting} & \(31.415926535898\)\\
\midrule


\begin{lstlisting}
\mathSin{0}
\end{lstlisting} &\(0.0\)\\
\midrule

\begin{lstlisting}
\mathCos{0}
\end{lstlisting} & \(1.0\)\\
\midrule


\begin{lstlisting}
\mathTan{0}
\end{lstlisting} & \(0.0\)\\
\midrule

\begin{lstlisting}
\mathAsin{0}
\end{lstlisting} & \(0.0\)\\
\midrule

\begin{lstlisting}
\mathAcos{0}
\end{lstlisting} & \(1.5707963267949\)\\
\midrule

\begin{lstlisting}
\mathAtan{0}
\end{lstlisting} & \(0.0\)\\
\midrule

\begin{lstlisting}
\mathRound{\mathOp{9+\mathSin{4}}}{6}
\end{lstlisting} & \(8.243198\)\\
\midrule
\caption{Illustrations of commands in the luamaths package}
\label{tbl:illluamaths}
\end{longtable}
\end{center}

\printbibliography
\end{document}
