<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">\documentclass{article}
\usepackage{listings,color,booktabs,longtable,array,hyperref,multicol,framed,luacomplex}
\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,
 upquote=true
}
\usepackage[backend=bibtex]{biblatex}
\begin{document}
\title{The luacomplex Package in LaTeX}
\author{Chetan Shirore\thanks{Email id: mathsbeauty@gmail.com} \space and  Ajit Kumar}
\maketitle
\section{Introduction}\label{section:introduction}
The  \verb|luacomplex| package is developed to define complex numbers and perform basic arithmetic on complex numbers in LaTeX. It also loads the \texttt{luamaths} package. It provides an easy way to define complex numbers and perform operations on complex numbers. The package has no particular environment for performing operations on complex numbers. The package commands can be used in any environment (including the mathematics environment). It is written in Lua, and the tex file is to be compiled with the LuaLatex engine. The time required for operations on complex numbers 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 may also save users' efforts to copy complex numbers from other software (which may not be in latex-compatible format) and to use them in a tex file. 

\section{Installation and License}

The installation of \verb|luacomplex| 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{luacomplex}| command in the preamble of the LaTeX document. The TeX file is to be compiled using the LuaLaTeX engine.

The \verb|luacomplex| 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.

\subsection{Defining and Printing Complex Numbers}
A complex number can be defined by using the \verb|\cpxNew| command. It has the following syntax.
\begin{lstlisting}
\cpxNew{a}{x,y}
\end{lstlisting}
\(x\) and \(y\) are  real and imaginary parts of   complex number \(a\).
The following commands define complex numbers \( a \) and \(b\).
\begin{lstlisting}
\cpxNew{a}{3,4}
\cpxNew{b}{1,3}
\end{lstlisting}
A complex number can be printed by using the \verb|\cpxPrint| command. For example, the commands
 \begin{lstlisting}
\(a=\cpxPrint{a}\) \\
\(b=\cpxPrint{b}\) }
\end{lstlisting}
output to \\
\(a = 3 + 4i\)\\
\(b = 1 + 3i\)

\section{Commands in the luacomplex package}
Table \ref{tbl:luacomplex} lists operations in the \verb|luacomplex| package.
\begin{longtable}{llm{6cm}}
\toprule
\multicolumn{1}{c}{\textcolor{blue}{Function}} &amp; \multicolumn{1}{c}{\textcolor{blue}{Command Format}} &amp; \multicolumn{1}{c}{\textcolor{blue}{Description}}\\
\toprule
\begin{lstlisting}
\cpxNew
\end{lstlisting} &amp;
\begin{lstlisting}
\cpxNew{c}{r}{i}
\end{lstlisting} &amp; Defines complex number \(c\) with real part \(r\) and imaginary part \(i\). \\
\midrule
\begin{lstlisting}
\cpxPrint
\end{lstlisting} &amp;
\begin{lstlisting}
\cpxPrint{a}
\end{lstlisting} &amp; Prints complex number \(a\). \\
\midrule
\begin{lstlisting}
\cpxAdd
\end{lstlisting} &amp;
\begin{lstlisting}
\cpxAdd{c}{a}{b}
\end{lstlisting} &amp; Defines complex number \(c\) obtained by adding complex numbers \(a\) and \(b\). \\
\midrule
\begin{lstlisting}
\cpxSub
\end{lstlisting} &amp;
\begin{lstlisting}
\cpxSub{d}{a}{b}
\end{lstlisting} &amp; Defines complex number \(d\) obtained by subtracting complex number \(b\) from  \(a\). \\
\midrule
\begin{lstlisting}
\cpxMul
\end{lstlisting} &amp;
\begin{lstlisting}
\cpxMul{e}{a}{b}
\end{lstlisting} &amp; Defines complex number \(e\) obtained by multiplying complex number \(a\) by \(b\). \\
\midrule
\begin{lstlisting}
\cpxDiv
\end{lstlisting} &amp;
\begin{lstlisting}
\cpxDiv{f}{a}{b}
\end{lstlisting} &amp; Defines complex number \(f\) obtained by dividing complex number \(a\) by \(b\). \\
\midrule
\begin{lstlisting}
\cpxInv
\end{lstlisting} &amp;
\begin{lstlisting}
\cpxInv{g}{a}
\end{lstlisting} &amp; Defines complex number \(g\) obtained by taking inverse of complex number \(a\). \\
\midrule
\begin{lstlisting}
\cpxRe
\end{lstlisting} &amp;
\begin{lstlisting}
\cpxRe{h}{a}
\end{lstlisting} &amp; Defines  \(h\) as a real part of complex number \(a\). \\
\midrule
\begin{lstlisting}
\cpxIm
\end{lstlisting} &amp;
\begin{lstlisting}
\cpxIm{j}{a}
\end{lstlisting} &amp; Defines  \(j\) as an imaginary part of complex number \(a\). \\
\midrule
\begin{lstlisting}
\cpxMod
\end{lstlisting} &amp;
\begin{lstlisting}
\cpxMod{m}{a}
\end{lstlisting} &amp; Defines  \(m\) as modulus of complex number \(a\). \\
\midrule
\begin{lstlisting}
\cpxPrinArg
\end{lstlisting} &amp;
\begin{lstlisting}
\cpxPrinArg{p}{a}
\end{lstlisting} &amp; Defines  \(p\) as the principal argument of complex number \(a\). \\
\midrule
\begin{lstlisting}
\cpxOp
\end{lstlisting} &amp;
\begin{lstlisting}
\cpxOp{n}{some operations}
\end{lstlisting} &amp; Defines \(n\) as a resulting complex number by performing some operations on complex numbers. It supports all standard operations such as \(+,-,*, /, \)   \^{}.\\
\bottomrule
\caption{Commands in the luacomplex package}
\label{tbl:luacomplex}
\end{longtable}

The package has a command \verb|\imgUnit| which provides typesetting for the imaginary unit. Its default value is \(i\). It can be redefined. For example, one can redefine it as  \verb|\renewcommand{\imgUnit}{\mathrm{i}}| or as \verb|\renewcommand{\imgUnit}{j}}|.


\section{Examples and Usage}
The latex document (Listing: \ref{code:illluacomplex}) makes use of  various commands in \verb|luacomplex| package. 
\begin{lstlisting}[label={code:illluacomplex}, caption={LaTeX document with luacomplex package}]
\documentclass{article}
\usepackage{luacomplex}
\begin{document}
\renewcommand{\imgUnit}{\mathrm{i}}
\cpxNew{a}{3,4}
\cpxNew{b}{1,3}
\(a=\cpxPrint{a}\) \\
\(b=\cpxPrint{b}\) \\
\cpxAdd{c}{a}{b}
\(c=a+b=\cpxPrint{c}\) \\
\cpxSub{d}{a}{b}
\(d=a-b=\cpxPrint{d}\) \\
\cpxMul{e}{a}{b}
\(e=a.b=\cpxPrint{e}\) \\
\cpxDiv{f}{a}{b}
\(f=\frac{a}{b}=\cpxPrint{f}\) \\
\cpxInv{g}{a}
\(g=\frac{1}{a}=\cpxPrint{g}\) \\
\cpxRe{h}{a}
\(h=Re(a)=\cpxPrint{h}\) \\
\cpxIm{j}{a}
\(j=Im(a)=\cpxPrint{j}\) \\
\cpxMod{m}{a}
\(m=|a|=\cpxPrint{m}\) \\
\cpxOp{n}{a+b*c-d}
\(n=a+bc-d=\cpxPrint{n}\) \\
\cpxPrinArg{p}{a}
\(p = prinArg(a) =\mathRound{\cpxPrint{p}}{4}\) 
\end{document}
\end{lstlisting}

This latex document (listing: \ref{code:illluacomplex}) outputs  the following on compiling with the LuaLaTeX engine. \\
\cpxNew{a}{3,4}
\cpxNew{b}{1,3}

 \begin{minipage}{0.4\textwidth}
\begin{framed}
\noindent\(a=\cpxPrint{a}\) \\
\(b=\cpxPrint{b}\) \\
\cpxAdd{c}{a}{b}
\(c=a+b=\cpxPrint{c}\) \\
\cpxSub{d}{a}{b}
\(d=a-b=\cpxPrint{d}\) \\
\cpxMul{e}{a}{b}
\(e=a.b=\cpxPrint{e}\) \\
\cpxDiv{f}{a}{b}
\(f=\frac{a}{b}=\cpxPrint{f}\)
\end{framed}
\end{minipage}
\begin{minipage}{0.4\textwidth}
\begin{framed}
\cpxInv{g}{a}
\(g=\frac{1}{a}=\cpxPrint{g}\) \\
\cpxRe{h}{a}
\(h=Re(a)=\cpxPrint{h}\) \\
\cpxIm{j}{a}
\(j=Im(a)=\cpxPrint{j}\) \\
\cpxMod{m}{a}
\(m=|a|=\cpxPrint{m}\) \\
\cpxOp{n}{a+b*c-d}
\(n=a+bc-d=\cpxPrint{n}\) \\
\cpxPrinArg{p}{a}
\(p = prinArg(a) =\mathRound{\cpxPrint{p}}{4}\)
\end{framed}
\end{minipage} \\

The package can be modified or extended by adding custom Lua programs.

\printbibliography
\end{document}
</pre></body></html>