\documentclass{article} \usepackage{float,listings,color,parskip,booktabs,longtable,array,hyperref,luanumint,amsmath,amssymb} \usepackage[top=1in, bottom=1in, 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{microtype,graphicx,amsmath,amssymb,float} \begin{document} \title{The luanumint package in LaTeX} \author{Chetan Shirore\thanks{Email id: mathsbeauty@gmail.com} \space and Ajit Kumar} \maketitle \section{Introduction} The \verb|luanumint| package is developed using Lua to find the numerical integration of real-valued functions of a real variable over closed and bounded intervals. The package provides commands to find numerical integration using the mid-point, trapezoidal, and Simpson's one-third and three-eighth rules. The \verb|loadstring| command is used to load and evaluate functions at different points in the mathematics environment of Lua. The package also provides commands to find numerical integration with step-by-step calculations. The package's commands have an optional argument to round off the numbers to the desired number of decimal places. The \verb|breqn| package is loaded to display and align step-by-step calculations properly. Advanced users can customize the code to achieve the desired formatting of step-by-step computations. The package can assist in creating various problems on numerical integration with their solutions. The results obtained using different methods of numerical integration can be compared. It can save users' efforts of doing computations involving numerical integration in external software and copying them inside LaTeX documents. \section{Installation and License} The installation of \verb|luanumint| 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{luanumint}| command in the preamble of the LaTeX document. A TeX file is to be compiled using the LuaLaTeX engine. The \verb|luanumint| 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{Rules for numerical integration} Let \(f\) be a real-valued function of a real variable which is Riemann-integrable over the closed and bounded interval \([a,b]\). The rules of numerical integration are used to calculate an approximate value of the integral \(\int\limits_{a}^{b}f(x)dx\). Let \(n\) denote a number of subintervals of equal length of the closed and bounded interval \([a,b]\) corresponding to a partition \( P=\{a=x_0,x_1,x_2…,x_n=b\} \) of \([a,b]\). The points of a partition \(P\) are equally spaced with distance \(h = \frac{b-a}{n}\). The following are some commonly used rules for numerical integration. \begin{itemize} \item \textbf{The Mid-point rule:} \[\int\limits_{a}^{b}f(x)dx \approx h \big[ f(m_1)+ f(m_2)+\cdots+ f(m_{n-1})+f(m_n)\big]\] where \(m_i = \frac{x_{i-1}+x_i}{2}\) for \(i=1, 2,\ldots,n\). \item \textbf{The Trapezoidal rule:} \[\int\limits_{a}^{b}f(x)dx \approx \frac{h}{2}\big[f(x_0)+2\, f(x_1)+2\, f(x_2)+\cdots+2\, f(x_{n-1})+f(x_n)\big] \] \item \textbf{The Simpson's one-third rule:} \[\int\limits_{a}^{b}f(x)dx \approx \frac{h}{3}\big[f(x_0)+4\,f(x_1)+2\,f(x_2)+4\,f(x_3)+2\,f(x_4)+\cdots+2\,f(x_{n-2})+4\,f(x_{n-1})+f(x_n)\big] \] The number of subintervals \(n\) should be an even number. \item \textbf{The Simpson's three-eighth rule:} \begin{dmath*}\int\limits_{a}^{b}f(x)dx \approx \frac{3h}{8} \big[f(x_0)+3\,f(x_1)+3\,f(x_2)+2\,f(x_3)+3\,f(x_4)+3\,f(x_5)+2\,f(x_6)+\cdots+2\,f(x_{n-3})+3\,f(x_{n-2})+3\,f(x_{n-1})+f(x_n)\big] \end{dmath*} The number of subintervals \(n\) should be a multiple of \(3\). \end{itemize} \section{Commands in the luanumint package} Table \ref{tbl:cmdluanum} lists commands in the \verb|luanumint| package with their description. \begin{center} \begin{longtable}{lm{10cm}} \toprule \multicolumn{1}{l}{\textcolor{blue}{Command}} & \multicolumn{1}{c}{\textcolor{blue}{Description}} \\ \toprule \begin{lstlisting}[caption={[]}] \luaMidpt \end{lstlisting} & Evaluates the integral using the Mid-point rule. \\ \midrule \begin{lstlisting}[caption={[]}] \luaMidptSteps \end{lstlisting} & Evaluates the integral using the Mid-point rule and provides steps involved in calculations. \\ \midrule \begin{lstlisting}[caption={[]}] \luaTrapz \end{lstlisting} & Evaluates the integral using the Trapezoidal rule. \\ \midrule \begin{lstlisting}[caption={[]}] \luaTrapzSteps \end{lstlisting} & Evaluates the integral using the Trapezoidal rule and provides steps involved in calculations. \\ \midrule \begin{lstlisting}[caption={[]}] \luaSimpsonOneThird \end{lstlisting} & Evaluates the integral using the Simpson's one-third rule. \\ \midrule \begin{lstlisting}[caption={[]}] \luaSimpsonOneThirdSteps \end{lstlisting} & Evaluates the integral using the Simpson's rule and provides steps involved in calculations. \\ \midrule \begin{lstlisting}[caption={[]}] \luaSimpsonThreeEighth \end{lstlisting} & Evaluates the integral using the Simpson's three-eighth rule. \\ \midrule \begin{lstlisting}[caption={[]}] \luaSimpsonThreeEighthSteps \end{lstlisting} & Evaluates the integral using the Simpson's three-eighth rule and provides steps involved in calculations. \\ \bottomrule \\ \caption{Commands in the luanumint package} \label{tbl:cmdluanum} \end{longtable} \end{center} Each command has one compulsory argument: a function which is to be integrated. Also, each command has a common set of optional parameters. Table \ref{tbl:optluanum} lists these optional parameters with their description. \begin{center} \begin{longtable}{lm{11.3cm}} \toprule \multicolumn{1}{l}{\textcolor{blue}{Optional Parameter}} & \multicolumn{1}{c}{\textcolor{blue}{Description}} \\ \toprule \begin{lstlisting}[caption={[]}] a \end{lstlisting} & Specifies the left end-point of the interval over which the integration is performed. The default value of \verb|a| is \(0 \). \\ \midrule \begin{lstlisting}[caption={[]}] b \end{lstlisting} & Specifies the right-point of the interval over which the integration is performed. The default value of \verb|b| is \(1 \).\\ \midrule \begin{lstlisting}[caption={[]}] n \end{lstlisting} & Specifies the number of subintervals used in calculating sums using different rules of numerical integration. The default value of \verb|n| is \(6 \).\\ \midrule \begin{lstlisting}[caption={[]}] func \end{lstlisting} & Specifies the label for a function which is to be integrated. The default value of \verb|func| is \(f \). \\ \midrule \begin{lstlisting}[caption={[]}] trun \end{lstlisting} & Specifies the number of decimal places to which the computations are to be truncated. The default value of \verb|trun| is \(4 \). \\ \bottomrule \\ \caption{Optional parameters in commands of the package} \label{tbl:optluanum} \end{longtable} \end{center} \section{Illustrations of commands in the luanumint package} Table \ref{tbl:illluanumint} illustrates some commands in the \verb|luanumint| package. \begin{center} \begin{longtable}{m{10.8cm}l} \toprule \multicolumn{1}{l}{\textcolor{blue}{LaTeX input}} & \multicolumn{1}{c}{\textcolor{blue}{Result}} \\ \toprule \begin{lstlisting}[caption={[]}] $\int_{1}^{3}\sqrt{9+sin(x)} dx=\luaMidpt[a=1,b=3,n=4]{sqrt(9+sin(x))}$ \end{lstlisting} & $\int_{1}^{3}\sqrt{9+\sin(x)} dx=\luaMidpt[a=1,b=3,n=4]{sqrt(9+sin(x))}$ \\ \midrule \begin{lstlisting}[caption={[]}] $\int_{1}^{2}\cos(x)dx=\luaTrapz[a=1,b=2,n=5]{cos(x)}$ \end{lstlisting} & $\int_{1}^{2}\cos(x) dx=\luaTrapz[a=1,b=2,n=5]{cos(x)}$ \\ \midrule \begin{lstlisting}[caption={[]}] $\int_{0}^{1}\sin(x+1) dx=\luaSimpsonOneThird[a=0,b=1,n=4,trun=6]{sin(x+1)}$ \end{lstlisting} & $\int_{0}^{1}\sin(x+1) dx=\luaSimpsonOneThird[a=0,b=1,n=4,trun=6]{sin(x+1)}$\\ \midrule \begin{lstlisting}[caption={[]}] $\int_{0}^{3}\sin(x) dx=\luaSimpsonThreeEighth[a=0,b=3,trun=6]{sin(x)}$ \end{lstlisting} & $\int_{0}^{3}\sin(x) dx=\luaSimpsonThreeEighth[a=0,b=3,trun=6]{sqrt(x^3+1)}$\\ \bottomrule \\ \caption{Illustrations of commands in the luanumint package} \label{tbl:illluanumint} \end{longtable} \end{center} Listing \ref{code:luamidpt} generates the output shown in Table \ref{tbl:luamidpt}. \begin{lstlisting}[label={code:luamidpt}, caption={The luaMidptSteps command}] \begin{dmath*} \int_{1}^{3}\sqrt{9+sin(x)} dx \luaMidptSteps[a=1,b=3,n=4,trun=6]{sqrt(9+sin(x))} \end{dmath*} \end{lstlisting} \begin{table}[H] \centering \begin{dmath*} \int_{1}^{3}\sqrt{9+sin(x)} dx \luaMidptSteps[a=1,b=3,n=4,trun=6]{sqrt(9+sin(x))} \end{dmath*} \caption{The luaMidptSteps command} \label{tbl:luamidpt} \end{table} Listing \ref{code:luatrapz} generates the output shown in Table \ref{tbl:luatrapz}. \begin{lstlisting}[label={code:luatrapz}, caption={The luaTrapzSteps command}] \begin{dmath*} \int_{0}^{1}\sqrt{1+\sin^4(x)}dx \luaTrapzSteps[a=0,b=1,n=5,trun=6]{sqrt(1+(sin(x))^4)} \end{dmath*} \end{lstlisting} \begin{table}[H] \centering \begin{dmath*} \int_{0}^{1}\sqrt{1+\sin^4(x)}dx \luaTrapzSteps[a=0,b=1,n=5,trun=6]{sqrt(1+(sin(x))^4)} \end{dmath*} \caption{The luaTrapzSteps command} \label{tbl:luatrapz} \end{table} Listing \ref{code:luasimpone} generates the output shown in Table \ref{tbl:luasimpone}. \begin{lstlisting}[label={code:luasimpone}, caption={The luaSimpsonOnethirdSteps command}] \begin{dmath*} \int_{0}^{1}\sin(x+1) dx \luaSimpsonOneThirdSteps[a=0,b=1,n=4,trun=6]{sin(x+1)} \end{dmath*} \end{lstlisting} \begin{table}[H] \centering \begin{dmath*} \int_{0}^{1}\sin(x+1) dx \luaSimpsonOneThirdSteps[a=0,b=1,n=4,trun=6]{sin(x+1)} \end{dmath*} \caption{The luaSimpsonOnethirdSteps command} \label{tbl:luasimpone} \end{table} Listing \ref{code:luasimpthree} generates the output shown in Table \ref{tbl:luasimpthree}. \begin{lstlisting}[label={code:luasimpthree}, caption={The luaSimpsonThreeEightSteps command}] \begin{dmath*} \int_{0}^{3}\sqrt{x^3+1} dx \luaSimpsonThreeEighthSteps[a=0,b=3,n=9,trun=6,func=h]{sqrt(x^3+1)} \end{dmath*} \end{lstlisting} \begin{table}[H] \centering \begin{dmath*} \int_{0}^{3}\sqrt{x^3+1} dx \luaSimpsonThreeEighthSteps[a=0,b=3,n=9,trun=6,func=h]{sqrt(x^3+1)} \end{dmath*} \caption{The luaSimpsonThreeEightSteps command} \label{tbl:luasimpthree} \end{table} \section{Known issues and limitations} The package uses no external library supporting arbitrary precision arithmetic. The \verb|luanumint| package can handle big and small numbers within the range of Lua that it supports. Lua does not have an inbuilt function to round off numbers to the desired number of decimal places. The package uses some user-defined function to round off calculations in commands that facilitate step-by-step calculations. The round-off error may occur while dealing with big and small numbers, and it may cause slight deviations in the results. \end{document}