texlive[67725] Master: luanumint (24jul23)
commits+karl at tug.org
commits+karl at tug.org
Mon Jul 24 22:23:44 CEST 2023
Revision: 67725
http://tug.org/svn/texlive?view=revision&revision=67725
Author: karl
Date: 2023-07-24 22:23:44 +0200 (Mon, 24 Jul 2023)
Log Message:
-----------
luanumint (24jul23)
Modified Paths:
--------------
trunk/Master/tlpkg/bin/tlpkg-ctan-check
trunk/Master/tlpkg/tlpsrc/collection-mathscience.tlpsrc
Added Paths:
-----------
trunk/Master/texmf-dist/doc/lualatex/luanumint/
trunk/Master/texmf-dist/doc/lualatex/luanumint/README.txt
trunk/Master/texmf-dist/doc/lualatex/luanumint/luanumint.pdf
trunk/Master/texmf-dist/doc/lualatex/luanumint/luanumint.tex
trunk/Master/texmf-dist/tex/lualatex/luanumint/
trunk/Master/texmf-dist/tex/lualatex/luanumint/luanumint.sty
trunk/Master/tlpkg/tlpsrc/luanumint.tlpsrc
Added: trunk/Master/texmf-dist/doc/lualatex/luanumint/README.txt
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/luanumint/README.txt (rev 0)
+++ trunk/Master/texmf-dist/doc/lualatex/luanumint/README.txt 2023-07-24 20:23:44 UTC (rev 67725)
@@ -0,0 +1,14 @@
+# Introduction
+The 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 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 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.
+
+# License
+The luanumint package is released under the LaTeX Project Public License v1.3c or later.
+The complete license text is available at 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.
+
+#Installation and Inclusion
+The installation of luanumint package is similar to plain latex package, where the .sty file is in LaTeX directory of texmf tree.
+The package can be included with \usepackage{luanumint} command in the preamble of the LaTeX document.
+The TeX file is to be compiled using the LuaLaTeX engine.
\ No newline at end of file
Property changes on: trunk/Master/texmf-dist/doc/lualatex/luanumint/README.txt
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/lualatex/luanumint/luanumint.pdf
===================================================================
(Binary files differ)
Index: trunk/Master/texmf-dist/doc/lualatex/luanumint/luanumint.pdf
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/luanumint/luanumint.pdf 2023-07-24 20:22:31 UTC (rev 67724)
+++ trunk/Master/texmf-dist/doc/lualatex/luanumint/luanumint.pdf 2023-07-24 20:23:44 UTC (rev 67725)
Property changes on: trunk/Master/texmf-dist/doc/lualatex/luanumint/luanumint.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/lualatex/luanumint/luanumint.tex
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/luanumint/luanumint.tex (rev 0)
+++ trunk/Master/texmf-dist/doc/lualatex/luanumint/luanumint.tex 2023-07-24 20:23:44 UTC (rev 67725)
@@ -0,0 +1,241 @@
+\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 at 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}
Property changes on: trunk/Master/texmf-dist/doc/lualatex/luanumint/luanumint.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/lualatex/luanumint/luanumint.sty
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/luanumint/luanumint.sty (rev 0)
+++ trunk/Master/texmf-dist/tex/lualatex/luanumint/luanumint.sty 2023-07-24 20:23:44 UTC (rev 67725)
@@ -0,0 +1,301 @@
+% The luanumint package
+% version 1.0
+% Licensed under LaTeX Project Public License v1.3c or later. The complete license text is available at http://www.latex-project.org/lppl.txt.
+%Authors: Chetan Shirore and Ajit Kumar
+
+\ProvidesPackage{luanumint}[1.0]
+\RequirePackage{luacode,breqn,xkeyval}
+\begin{luacode*}
+function checksign(x)
+ if x >=0 then
+ return ' + '
+ else
+ return ''
+ end
+end
+
+function mathrnd(num, numDecimalPlaces)
+ local mult = 10^(numDecimalPlaces or 0)
+ return math.floor(num * mult + 0.5) / mult
+end
+
+function luamidpt (f,a,b,n,trun)
+ local trun = trun or 4
+ local h = (b - a) / n
+ local sum = 0
+ local var = a + h/2
+ for i = 1, n do
+ sum = sum + f(var)
+ var = var + h
+ end
+ return mathrnd(sum*h,trun)
+end
+
+function luamidptSteps (f,a,b,n,nm,trun)
+ local trun = trun or 4
+ local nm = nm or "f"
+ local h = (b - a) / n
+ local sum = 0
+ local var = a + (h/2)
+ local str = " = "..mathrnd(h,trun)..'\\left['
+ local otstr = mathrnd(h,trun)..'\\left('
+ for i = 1, n do
+ if i>=1 and i<=n-1 then
+ sum = sum + mathrnd(f(var),trun)
+ str = str ..nm.."("..mathrnd(var,trun)..") + "
+ otstr = otstr ..mathrnd(f(var),trun)..checksign(f(var+h),trun)
+ end
+ if i== n then
+ sum = sum + mathrnd(f(var),trun)
+ str = str ..nm.."("..var..")"
+ otstr = otstr ..mathrnd(f(var),trun)
+ end
+ var = var + h
+ end
+ return str .."\\right] \\\\ = "..otstr.."\\right) \\\\ = "..mathrnd(sum*mathrnd(h,trun),trun)
+end
+
+function luatrapz (f,a,b,n,trun)
+ local trun = trun or 4
+ local h = (b - a) / n
+ local sum = 0
+ local var = a
+ for i = 1, n+1 do
+ if i== 1 or i == n+1 then
+ sum = sum + f(var)
+ else
+ sum = sum + 2*f(var)
+ end
+ var = var + h
+ end
+ return mathrnd(sum*h/2,trun)
+end
+
+function luatrapzsteps (f,a,b,n,nm,trun)
+ local trun = trun or 4
+ local nm = nm or "f"
+ local h = (b - a) / n
+ local sum = 0
+ local var = a
+ local str = " = "..mathrnd(h/2,trun)..'\\left['
+ local otstr = mathrnd(h/2,trun)..'\\left('
+ for i = 0, n do
+ if i== 0 then
+ sum = sum + mathrnd(f(var),trun)
+ str = str ..nm.."("..var..") +"
+ otstr = otstr ..mathrnd(f(var),trun)..checksign(f(var+h),trun)
+ end
+ if i>=1 and i<=n-1 then
+ sum = sum + mathrnd(2*f(var),trun)
+ str = str .."2"..nm.."("..mathrnd(var,trun)..") + "
+ otstr = otstr ..mathrnd(2*f(var),trun)..checksign(f(var+h),trun)
+ end
+ if i== n then
+ sum = sum + mathrnd(f(var),trun)
+ str = str ..nm.."("..var..")"
+ otstr = otstr ..mathrnd(f(var),trun)
+ end
+ var = var + h
+ end
+ return str .."\\right] \\\\ = "..otstr.."\\right) \\\\ = "..mathrnd(sum*mathrnd(h/2,trun),trun)
+end
+
+function luasimpsononethird (f,a,b,n,trun)
+ if (not(n % 2 == 0)) then error("Number of subintervals should be even.") end
+ local trun = trun or 4
+ local h = (b - a) / n
+ local sum = 0
+ local var = a
+ for i = 0, n do
+ if i== 0 or i ==n then
+ sum = sum + f(var)
+ end
+ if i>=1 and i<=n-1 and (i % 2 == 0) then
+ sum = sum + 2*f(var)
+ end
+ if i>=1 and i<=n-1 and (not(i % 2 == 0)) then
+ sum = sum + 4*f(var)
+ end
+ var = var + h
+ end
+ return mathrnd(sum*h/3,trun)
+end
+
+function luasimpsononethirdsteps (f,a,b,n,nm,trun)
+ if (not(n % 2 == 0)) then error("Number of subintervals should be even.") end
+ local trun = trun or 4
+ local nm = nm or "f"
+ local h = (b - a) / n
+ local sum = 0
+ local var = a
+ local str = " = "..mathrnd(h/3,trun)..'\\left['
+ local otstr = mathrnd(h/3,trun)..'\\left('
+ for i = 0, n do
+ if i== 0 then
+ sum = sum + mathrnd(f(var),trun)
+ str = str ..nm.."("..var..") +"
+ otstr = otstr ..mathrnd(f(var),trun)..checksign(f(var+h),trun)
+ end
+ if i>=1 and i<=n-1 and (i % 2 == 0) then
+ sum = sum + mathrnd(2*f(var),trun)
+ str = str .."2"..nm.."("..mathrnd(var,trun)..") + "
+ otstr = otstr ..mathrnd(2*f(var),trun)..checksign(f(var+h),trun)
+ end
+ if i>=1 and i<=n-1 and (not(i % 2 == 0)) then
+ sum = sum + mathrnd(4*f(var),trun)
+ str = str.."4"..nm.."("..mathrnd(var,trun)..") + "
+ otstr = otstr ..mathrnd(4*f(var),trun)..checksign(f(var+h),trun)
+ end
+ if i== n then
+ sum = sum + mathrnd(f(var),trun)
+ str = str ..nm.."("..var..")"
+ otstr = otstr ..mathrnd(f(var),trun)
+ end
+ var = var + h
+ end
+ return str .."\\right] \\\\ = "..otstr.."\\right) \\\\ = "..mathrnd(sum*mathrnd(h/3,trun),trun)
+end
+
+function luasimpsonthreight (f,a,b,n,trun)
+ if (not(n % 3 == 0)) then error("No. of sub-intervals should be multiple of 3.") end
+ local trun = trun or 4
+ local h = (b - a) / n
+ local sum = 0
+ local var = a
+
+ for i = 0, n do
+ if i== 0 or i ==n then
+ sum = sum + f(var)
+ end
+ if i>=1 and i<=n-1 and (i % 3 == 0) then
+ sum = sum + 2*f(var)
+ end
+ if i>=1 and i<=n-1 and (not(i % 3 == 0)) then
+ sum = sum + 3*f(var)
+ end
+ var = var + h
+ end
+ return mathrnd(sum*3*h/8,trun)
+end
+
+function luasimpsonthreightsteps (f,a,b,n,nm,trun)
+ if (not(n % 3 == 0)) then error("No. of sub-intervals should be multip.") end
+ local trun = trun or 4
+ local nm = nm or "f"
+ local h = (b - a) / n
+ local sum = 0
+ local var = a
+ local str = " = "..mathrnd(3*h/8,trun)..'\\left['
+ local otstr = mathrnd(3*h/8,trun)..'\\left('
+ for i = 0, n do
+ if i== 0 then
+ sum = sum + mathrnd(f(var),trun)
+ str = str ..nm.."("..var..") +"
+ otstr = otstr ..mathrnd(f(var),trun)..checksign(f(var+h),trun)
+ end
+ if i>=1 and i<=n-1 and (i % 3 == 0) then
+ sum = sum + mathrnd(2*f(var),trun)
+ str = str .."2"..nm.."("..mathrnd(var,trun)..") + "
+ otstr = otstr ..mathrnd(2*f(var),trun)..checksign(f(var+h),trun)
+ end
+ if i>=1 and i<=n-1 and (not(i % 3 == 0)) then
+ sum = sum + mathrnd(3*f(var),trun)
+ str = str.."3"..nm.."("..mathrnd(var,trun)..") + "
+ otstr = otstr ..mathrnd(3*f(var),trun)..checksign(f(var+h),trun)
+ end
+ if i== n then
+ sum = sum + mathrnd(f(var),trun)
+ str = str ..nm.."("..var..")"
+ otstr = otstr ..mathrnd(f(var),trun)
+ end
+ var = var + h
+ end
+ return str .."\\right] \\\\ = "..otstr.."\\right) \\\\ = "..mathrnd(sum*mathrnd(3*h/8,trun),trun)
+end
+\end{luacode*}
+
+% ========= KEY DEFINITIONS =========
+\define at key{someop}{a}{\def\mop at one{#1}}%
+\define at key{someop}{b}{\def\mop at two{#1}}%
+\define at key{someop}{n}{\def\mop at three{#1}}%
+\define at key{someop}{func}{\def\mop at four{#1}}%
+\define at key{someop}{trun}{\def\mop at five{#1}}%
+% ========= KEY DEFAULTS =========
+\setkeys{someop}{a=0}%
+\setkeys{someop}{b=1}%
+\setkeys{someop}{n=6}%
+\setkeys{someop}{func=f}%
+\setkeys{someop}{trun=4}%
+% ========= Defining Command =========
+\newcommand{\luaMidpt}[2][]{{%
+\setkeys{someop}{#1}%
+\directlua{%
+tempsubexp = "("..\luastring{#2}..")"
+local f = load("return function(x) return " ..tempsubexp.. "end",nil,"t",math)()
+tex.print(luamidpt(f,\mop at one,\mop at two,\mop at three,\mop at five))
+}%
+}%
+}%
+
+\newcommand{\luaMidptSteps}[2][]{\begingroup%
+\setkeys{someop}{#1}%
+\directlua{%
+
+tempsubexp = "("..\luastring{#2}..")"
+local f = load("return function(x) return " ..tempsubexp.. "end",nil,"t",math)() tex.sprint(luamidptSteps(f,\mop at one,\mop at two,\mop at three,'\mop at four',\mop at five))
+}%
+\endgroup}%
+
+\newcommand{\luaTrapz}[2][]{{%
+\setkeys{someop}{#1}%
+\directlua{%
+tempsubexp = "("..\luastring{#2}..")"
+local f = load("return function(x) return " ..tempsubexp.. "end",nil,"t",math)()
+tex.print(luatrapz(f,\mop at one,\mop at two,\mop at three,\mop at five))
+}%
+}%
+}%
+
+\newcommand{\luaTrapzSteps}[2][]{\begingroup%
+\setkeys{someop}{#1}%
+\directlua{%
+tempsubexp = "("..\luastring{#2}..")"
+local f = load("return function(x) return " ..tempsubexp.. "end",nil,"t",math)() tex.sprint(luatrapzsteps(f,\mop at one,\mop at two,\mop at three,'\mop at four',\mop at five))
+}%
+\endgroup}%
+
+\newcommand{\luaSimpsonOneThird}[2][]{{%
+\setkeys{someop}{#1}%
+\directlua{%
+tempsubexp = "("..\luastring{#2}..")"
+local f = load("return function(x) return " ..tempsubexp.. "end",nil,"t",math)() tex.print(luasimpsononethird(f,\mop at one,\mop at two,\mop at three,\mop at five))
+}%
+}%
+}%
+
+\newcommand{\luaSimpsonOneThirdSteps}[2][]{\begingroup%
+\setkeys{someop}{#1}%
+\directlua{%
+tempsubexp = "("..\luastring{#2}..")"
+local f = load("return function(x) return " ..tempsubexp.. "end",nil,"t",math)() tex.sprint(luasimpsononethirdsteps(f,\mop at one,\mop at two,\mop at three,'\mop at four',\mop at five))
+}%
+\endgroup}%
+
+
+\newcommand{\luaSimpsonThreeEighth}[2][]{{%
+\setkeys{someop}{#1}%
+\directlua{%
+tempsubexp = "("..\luastring{#2}..")"
+local f = load("return function(x) return " ..tempsubexp.. "end",nil,"t",math)() tex.print(luasimpsonthreight(f,\mop at one,\mop at two,\mop at three,\mop at five))
+}%
+}%
+}%
+
+\newcommand{\luaSimpsonThreeEighthSteps}[2][]{\begingroup%
+\setkeys{someop}{#1}%
+\directlua{%
+tempsubexp = "("..\luastring{#2}..")"
+local f = load("return function(x) return " ..tempsubexp.. "end",nil,"t",math)() tex.sprint(luasimpsonthreightsteps(f,\mop at one,\mop at two,\mop at three,'\mop at four',\mop at five))
+}%
+\endgroup}%
+\endinput
\ No newline at end of file
Property changes on: trunk/Master/texmf-dist/tex/lualatex/luanumint/luanumint.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/tlpkg/bin/tlpkg-ctan-check
===================================================================
--- trunk/Master/tlpkg/bin/tlpkg-ctan-check 2023-07-24 20:22:31 UTC (rev 67724)
+++ trunk/Master/tlpkg/bin/tlpkg-ctan-check 2023-07-24 20:23:44 UTC (rev 67725)
@@ -520,7 +520,7 @@
luaimageembed luaindex luainputenc luaintro luakeys
lualatex-doc lualatex-doc-de
lualatex-math lualatex-truncate lualibs lualinalg luamathalign luamaths
- luamesh luamodulartables luamplib luaoptions luaotfload
+ luamesh luamodulartables luamplib luanumint luaoptions luaotfload
luapackageloader luaplot luaprogtable luapstricks
luaquotes luarandom
luaset luasseq luatex85 luatexbase luatexja luatexko luatextra
Modified: trunk/Master/tlpkg/tlpsrc/collection-mathscience.tlpsrc
===================================================================
--- trunk/Master/tlpkg/tlpsrc/collection-mathscience.tlpsrc 2023-07-24 20:22:31 UTC (rev 67724)
+++ trunk/Master/tlpkg/tlpsrc/collection-mathscience.tlpsrc 2023-07-24 20:23:44 UTC (rev 67725)
@@ -134,6 +134,7 @@
depend lpform
depend lplfitch
depend lstbayes
+depend luanumint
depend mathcommand
depend mathcomp
depend mathfixs
Added: trunk/Master/tlpkg/tlpsrc/luanumint.tlpsrc
===================================================================
More information about the tex-live-commits
mailing list.