| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (C) 2012, 2014, 2022 by Robert Fuster <[email protected]> |
| 4 |
% |
| 5 |
% This work may be distributed and/or modified under the conditions of |
| 6 |
% the LaTeX Project Public License, either version 1.3 of this license |
| 7 |
% or (at your option) any later version. The latest version of this |
| 8 |
% license is in: |
| 9 |
% |
| 10 |
% http://www.latex-project.org/lppl.txt |
| 11 |
% |
| 12 |
% and version 1.3 or later is part of all distributions of LaTeX |
| 13 |
% version 2005/12/01 or later. |
| 14 |
%% |
| 15 |
% This work has the LPPL maintenance status `maintained'. |
| 16 |
% |
| 17 |
% The Current Maintainer of this work is Robert Fuster |
| 18 |
% |
| 19 |
% This work consists of the files calculator.dtx and calculator.ins |
| 20 |
% and the derived files calculator.sty, calculus.ins, and several |
| 21 |
% calculator<nn>.tex derived files. |
| 22 |
% |
| 23 |
% \fi |
| 24 |
% |
| 25 |
% \iffalse |
| 26 |
% |
| 27 |
%<*driver> |
| 28 |
\documentclass{ltxdoc} |
| 29 |
\ProvidesFile{calculator.dtx} |
| 30 |
[2022/09/15 v.2.1 documented calculator package] |
| 31 |
|
| 32 |
\usepackage{calculus} |
| 33 |
\usepackage{amsmath} |
| 34 |
\usepackage[lmargin=1.75in,rmargin=1in]{geometry} |
| 35 |
\usepackage{fancyvrb} |
| 36 |
|
| 37 |
\usepackage[colorlinks]{hyperref} |
| 38 |
\def\fileversion{2.1} |
| 39 |
\def\filedate{2022/09/15} |
| 40 |
|
| 41 |
\GetFileInfo{calculator.dtx} |
| 42 |
|
| 43 |
\title{The \textsf{calculator} and \textsf{calculus} packages% |
| 44 |
\thanks{This document corresponds to |
| 45 |
\textsf{calculator}~\fileversion{} and |
| 46 |
\textsf{calculus}~\fileversion, dated \filedate.}\\ |
| 47 |
Scientific calculations with \LaTeX} |
| 48 |
\author{Robert Fuster\\ |
| 49 |
Universitat Polit\`ecnica de Val\`encia \\ |
| 50 |
\texttt{[email protected]}} |
| 51 |
\date{\filedate} |
| 52 |
\EnableCrossrefs |
| 53 |
\CodelineIndex |
| 54 |
\RecordChanges |
| 55 |
|
| 56 |
\def\partname{Part} |
| 57 |
|
| 58 |
\newcommand{\TBS}{\textbackslash} |
| 59 |
\newcommand{\Marg}[1]{\textnormal{\marg{#1}}} |
| 60 |
|
| 61 |
\newcommand{\newinversion}[1]{\textnormal{\textit{(new in version~#1)}}} |
| 62 |
\newcommand{\renewinversion}[2][]{\textnormal{\footnote{code modified in version~#2\ifx"#1"\else\space (#1)\fi.}}} |
| 63 |
|
| 64 |
\newcommand{\arccot}{\operatorname{arccot}} |
| 65 |
\newcommand{\arsinh}{\operatorname{arsinh}} |
| 66 |
\newcommand{\arcosh}{\operatorname{arcosh}} |
| 67 |
\newcommand{\artanh}{\operatorname{artanh}} |
| 68 |
\newcommand{\arcoth}{\operatorname{arcoth}} |
| 69 |
|
| 70 |
\newcounter{exem}\stepcounter{exem} |
| 71 |
\newenvironment{exemple}{% |
| 72 |
\VerbatimEnvironment\begin{VerbatimOut}[gobble=2]{./calculator\theexem.tex}}{% |
| 73 |
\end{VerbatimOut} |
| 74 |
\par\medskip\noindent |
| 75 |
\begin{minipage}{\linewidth} |
| 76 |
\begin{minipage}[t]{0.45\linewidth} |
| 77 |
\setlength{\parindent}{2ex} |
| 78 |
\noindent\textsf{\fbox{Ex. \theexem}} |
| 79 |
\bigskip\par |
| 80 |
\catcode`\%=14 |
| 81 |
\input{./calculator\theexem} |
| 82 |
\end{minipage}\hfill |
| 83 |
\begin{minipage}[t]{0.45\linewidth} |
| 84 |
\small |
| 85 |
\VerbatimInput{./calculator\theexem.tex} |
| 86 |
\end{minipage} |
| 87 |
\end{minipage} |
| 88 |
\stepcounter{exem}\par\bigskip\noindent} |
| 89 |
|
| 90 |
\newcommand{\textttit}[1]{\texttt{\textit{#1}}} |
| 91 |
%\OnlyDescription |
| 92 |
\begin{document} |
| 93 |
\maketitle |
| 94 |
\DocInput{calculator.dtx} |
| 95 |
\PrintChanges |
| 96 |
\PrintIndex |
| 97 |
\end{document} |
| 98 |
%</driver> |
| 99 |
% |
| 100 |
% \fi |
| 101 |
% |
| 102 |
% \CheckSum{3913} |
| 103 |
% \changes{v1.0}{2012/04/25}{First public version} |
| 104 |
% \changes{v1.0a}{2012/06/10}{calculator.dtx modified to make it autoinstallable. |
| 105 |
% calculus.dtx embedded in calculus.dtx} |
| 106 |
% \changes{v2.0}{2014/02/20}{new calculator.dtx and calculator.ins files} |
| 107 |
% \changes{v2.1}{2022/09/15}{Some bugs fixed} |
| 108 |
%% \CharacterTable |
| 109 |
%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z |
| 110 |
%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z |
| 111 |
%% Digits \0\1\2\3\4\5\6\7\8\9 |
| 112 |
%% Exclamation \! Double quote \" Hash (number) \# |
| 113 |
%% Dollar \$ Percent \% Ampersand \& |
| 114 |
%% Acute accent \' Left paren \( Right paren \) |
| 115 |
%% Asterisk \* Plus \+ Comma \, |
| 116 |
%% Minus \- Point \. Solidus \/ |
| 117 |
%% Colon \: Semicolon \; Less than \< |
| 118 |
%% Equals \= Greater than \> Question mark \? |
| 119 |
%% Commercial at \@ Left bracket \[ Backslash \\ |
| 120 |
%% Right bracket \] Circumflex \^ Underscore \_ |
| 121 |
%% Grave accent \` Left brace \{ Vertical bar \| |
| 122 |
%% Right brace \} Tilde \~} |
| 123 |
% |
| 124 |
|
| 125 |
% \DoNotIndex{\newcommand,\newenvironment,\RequirePackage,\begin,\end} |
| 126 |
% \DoNotIndex{\begingroup,\endgroup,\expandafter,\undefined,\@ifnextchar} |
| 127 |
% \DoNotIndex{\def,\let,\edef,\xdef,\ifx,\ifdim,\ifnum,\else,\fi,\fi,\fi} |
| 128 |
% \DoNotIndex{\@whilenum,\advance,\divide,\do,\newdimen,\number} |
| 129 |
% \DoNotIndex{\noexpand,\ignorespaces,\p@,\z@,\strip@pt} |
| 130 |
% \DoNotIndex{\MessageBreak} |
| 131 |
% |
| 132 |
% \begin{abstract} |
| 133 |
% The \textsf{calculator} package allows us to use \LaTeX{} as a calculator, |
| 134 |
% with which we can perform many of the common scientific calculations |
| 135 |
% (with the limitation in accuracy imposed by the \TeX{} arithmetic). |
| 136 |
% |
| 137 |
% This package introduces several new instructions that allow you to do |
| 138 |
% several calculations with integer and decimal numbers using \LaTeX. |
| 139 |
% Apart from add, multiply or divide, we can calculate powers, square roots, |
| 140 |
% logarithms, trigonometric and hyperbolic functions \ldots |
| 141 |
|
| 142 |
% In addition, the \textsf{calculator} package supports some elementary calculations with |
| 143 |
% vectors |
| 144 |
% in two and three dimensions and square $2\times2$ and $3\times3$ matrices. |
| 145 |
% \smallskip |
| 146 |
|
| 147 |
% The |
| 148 |
% \textsf{calculus} package adds to the \textsf{calculator} package |
| 149 |
% several utilities to use and define various functions and their derivatives, |
| 150 |
% including elementary functions, operations with functions, |
| 151 |
% polar coordinates and vector-valued real functions. |
| 152 |
|
| 153 |
% Version 2.0 adds new capabilities to both packages. |
| 154 |
% Specifically, now, \textsf{calculator} and \textsf{calculus} |
| 155 |
% can evaluate the inverse trigonometric |
| 156 |
% and the inverse hyperbolic functions |
| 157 |
% (so that we can work with all the classic elementary functions), |
| 158 |
% and also can do some additional calculation with vectors |
| 159 |
% (such as the cross product and the angle between two vectors). |
| 160 |
|
| 161 |
% Version 2.1 fixes some bugs and calculation problems.\footnote{Thanks to |
| 162 |
% Schmitz Manuel, Thorsten Wolterin, Jim Cline, |
| 163 |
% Schremmer Alain and July Tikhonov.} |
| 164 |
% \end{abstract} |
| 165 |
% |
| 166 |
% \tableofcontents |
| 167 |
% |
| 168 |
% \section{Introduction} |
| 169 |
% The \textsf{calculator} package defines some instructions which allow |
| 170 |
% us to realize algebraic operations |
| 171 |
% (and to evaluate elementary functions) in our documents. |
| 172 |
% The operations implemented by the \textsf{calculator} package |
| 173 |
% include routines of assignment of variables, |
| 174 |
% arithmetical calculations with real and integer numbers, |
| 175 |
% two and three dimensional vector and matrix arithmetics |
| 176 |
% and the computation of square roots, |
| 177 |
% trigonometrical, exponential, logarithmic and hyperbolic functions. |
| 178 |
% In addition, some important numbers, such as $\sqrt2$, $\pi$ or $\mathrm e$, |
| 179 |
% are predefined. |
| 180 |
% |
| 181 |
% The name of all these commands is spelled in capital letters |
| 182 |
% (with very few exceptions: % the commands \cs{DEGtoRAD} and \cs{RADtoDEG} |
| 183 |
% and the control sequences that define special numbers, as |
| 184 |
% \cs{numberPI}) |
| 185 |
% and, in general, they all need one or more mandatory arguments, |
| 186 |
% the first one(s) of which is(are) number(s) and the last one(s) is(are) |
| 187 |
% the name(s) of the command(s) where |
| 188 |
% the results will be stored.\footnote{% |
| 189 |
% Logically, the control sequences that represent special numbers |
| 190 |
% (as \cs{numberPI}) does not need any argument.} |
| 191 |
% The new commands defined in this way work in any \LaTeX{} mode. |
| 192 |
% |
| 193 |
% |
| 194 |
% By example, this instruction |
| 195 |
% \begin{verbatim} |
| 196 |
% \MAX{3}{5}{\solution} |
| 197 |
% \end{verbatim} |
| 198 |
% stores |5| in the command \cs{solution}. In a similar way, |
| 199 |
% \begin{verbatim} |
| 200 |
% \FRACTIONSIMPLIFY{10}{12}{\numerator}{\denominator} |
| 201 |
% \end{verbatim} |
| 202 |
% defines \cs{numerator} and \cs{denominator} as |5| i |6|, respectively. |
| 203 |
% |
| 204 |
% The \emph{data} arguments should not be necessarily explicit numbers; |
| 205 |
% it may also consist in commands the value of which is a number. |
| 206 |
% This allows us to chain several calculations, since in the following |
| 207 |
% example: |
| 208 |
% \begin{exemple} |
| 209 |
% % \tempA=2,5^2 |
| 210 |
% \SQUARE{2.5}{\tempA} |
| 211 |
% % \tempB=sqrt(12) |
| 212 |
% \SQUAREROOT{12}{\tempB} |
| 213 |
% % \tempC=exp(3,4) |
| 214 |
% \EXP{3.4}{\tempC} |
| 215 |
% % \divisio=\tempA/tempB |
| 216 |
% \DIVIDE{\tempA}{\tempB}{\divisio} |
| 217 |
% % \sol=\divisio+\tempC |
| 218 |
% \ADD{\divisio}{\tempC}{\sol} |
| 219 |
% \begin{align*} |
| 220 |
% \frac{2.5^2}{\sqrt{12}}+\mathrm{e}^{3.4} |
| 221 |
% &= \frac{\tempA}{\tempB}+\tempC \\ |
| 222 |
% &= \divisio+\tempC \\ |
| 223 |
% &=\sol |
| 224 |
% \end{align*} |
| 225 |
% \end{exemple} |
| 226 |
% Observe that, in this example, we have followed exactly the same steps |
| 227 |
% that we would do to calculate |
| 228 |
% $\frac{2.5^2}{\sqrt{12}}+\mathrm{e}^{3.4}$ with a standard calculator: |
| 229 |
% We would calculate the square, the root and the exponential and, |
| 230 |
% finally, we would divide and add the results. |
| 231 |
% |
| 232 |
% It does not matter if the arguments \emph{results} are or not predefined. |
| 233 |
% But these commands act as declarations, so that its scope is local |
| 234 |
% in environments and groups. |
| 235 |
% \begin{exemple} |
| 236 |
% \SQUARE{5}\sol |
| 237 |
% The \texttt{\textbackslash sol} |
| 238 |
% command contains the square of $5$: |
| 239 |
% \[5^2=\sol\] |
| 240 |
% \begin{center} |
| 241 |
% \SQUAREROOT{5}\sol |
| 242 |
% Now, the \texttt{\textbackslash sol} |
| 243 |
% command is the square root of $5$: |
| 244 |
% \[\sqrt{5}=\sol\] |
| 245 |
% \end{center} |
| 246 |
% On having gone out of the \texttt{center} |
| 247 |
% environment, |
| 248 |
% the command recovers its previous value: |
| 249 |
% \sol |
| 250 |
% \end{exemple} |
| 251 |
% |
| 252 |
% The \textsf{calculus} package |
| 253 |
% goes a step further and allows us to define and use in a user-friendly |
| 254 |
% manner various functions and their derivatives. |
| 255 |
% |
| 256 |
% For exemple, using the |
| 257 |
% \textsf{calculus} package, you can define the $f(t)=t^2e^t-\cos 2t$ function |
| 258 |
% as follows: |
| 259 |
% \begin{Verbatim} |
| 260 |
% \PRODUCTfunction{\SQUAREfunction}{\EXPfunction}{\tempfunctionA} |
| 261 |
% \SCALEVARIABLEfunction{2}{\COSfunction}{\tempfunctionB} |
| 262 |
% \SUBTRACTfunction{\tempfunctionA}{\tempfunctionB}{\Ffunction} |
| 263 |
% \end{Verbatim} |
| 264 |
% |
| 265 |
% Then you cau compute any value of the new function |\Ffunction| |
| 266 |
% and its derivative: typing |
| 267 |
% \begin{quote} |
| 268 |
% |\Ffunction|\marg{num}\marg{\cs{sol}}\marg{\cs{Dsol}} |
| 269 |
% \end{quote} |
| 270 |
% the values of $f(\textit{num})$ and $f'(\textit{num})$ will be stored in |
| 271 |
% \textttit{\cs{sol}} and \textttit{\cs{Dsol}}. |
| 272 |
% |
| 273 |
% \part{The \textsf{calculator} package} |
| 274 |
% \section{Predefined numbers} |
| 275 |
% The \textsf{calculator} package predefines the following numbers: |
| 276 |
% \SpecialUsageIndex{\numberPI} |
| 277 |
% \SpecialUsageIndex{\numberHALFPI} |
| 278 |
% \SpecialUsageIndex{\numberTHREEHALFPI} |
| 279 |
% \SpecialUsageIndex{\numberTHIRDPI} |
| 280 |
% \SpecialUsageIndex{\numberQUARTERPI} |
| 281 |
% \SpecialUsageIndex{\numberFIFTHPI} |
| 282 |
% \SpecialUsageIndex{\numberSIXTHPI} |
| 283 |
% \SpecialUsageIndex{\numberTWOPI} |
| 284 |
% \SpecialUsageIndex{\numberE} |
| 285 |
% \SpecialUsageIndex{\numberINVE} |
| 286 |
% \SpecialUsageIndex{\numberETWO} |
| 287 |
% \SpecialUsageIndex{\numberINVETWO} |
| 288 |
% \SpecialUsageIndex{\numberLOGTEN} |
| 289 |
% \SpecialUsageIndex{\numberGOLD} |
| 290 |
% \SpecialUsageIndex{\numberINVGOLD} |
| 291 |
% \SpecialUsageIndex{\numberSQRTTWO} |
| 292 |
% \SpecialUsageIndex{\numberSQRTTHREE} |
| 293 |
% \SpecialUsageIndex{\numberSQRTFIVE} |
| 294 |
% \SpecialUsageIndex{\numberCOSXXX} |
| 295 |
% \SpecialUsageIndex{\numberCOSXLV} |
| 296 |
% \begin{center} |
| 297 |
% \begin{tabular}{llll} |
| 298 |
% \ttfamily \cs{numberPI} & $\numberPI\approx\pi$ & |
| 299 |
% \ttfamily \cs{numberHALFPI} & $\numberHALFPI\approx\pi/2$ \\ |
| 300 |
% \ttfamily \cs{numberTHREEHALFPI} & $\numberTHREEHALFPI\approx3\pi/2$ & |
| 301 |
% \ttfamily \cs{numberTHIRDPI} & $\numberTHIRDPI\approx\pi/3$ \\ |
| 302 |
% \ttfamily \cs{numberQUARTERPI} & $\numberQUARTERPI\approx\pi/4$ & |
| 303 |
% \ttfamily \cs{numberFIFTHPI} & $\numberFIFTHPI\approx\pi/5$ \\ |
| 304 |
% \ttfamily \cs{numberSIXTHPI} & $\numberSIXTHPI\approx\pi/6$ & |
| 305 |
% \ttfamily \cs{numberTWOPI} & $\numberTWOPI\approx2\pi$ \\ |
| 306 |
% \hline |
| 307 |
% \ttfamily \cs{numberE} & $\numberE\approx\mathrm e$ & |
| 308 |
% \ttfamily \cs{numberINVE} & $\numberINVE\approx1/\mathrm e$ \\ |
| 309 |
% \ttfamily \cs{numberETWO} & $\numberETWO\approx\mathrm e^2$ & |
| 310 |
% \ttfamily \cs{numberINVETWO} & $\numberINVETWO\approx1/\mathrm e^2$ \\ |
| 311 |
% \hline |
| 312 |
% \ttfamily \cs{numberLOGTEN} & $\numberLOGTEN\approx\log 10$ |
| 313 |
% \\ |
| 314 |
% \hline |
| 315 |
% \ttfamily \cs{numberGOLD} & $\numberGOLD\approx\phi$ & |
| 316 |
% \ttfamily \cs{numberINVGOLD} & $\numberINVGOLD\approx1/\phi$ \\ |
| 317 |
% \hline |
| 318 |
% \ttfamily \cs{numberSQRTTWO} & $\numberSQRTTWO\approx\sqrt2$ & |
| 319 |
% \ttfamily \cs{numberSQRTTHREE} & $\numberSQRTTHREE\approx\sqrt3$ \\ |
| 320 |
% \ttfamily \cs{numberSQRTFIVE} & $\numberSQRTFIVE\approx\sqrt5$ \\ |
| 321 |
% \hline |
| 322 |
% \ttfamily \cs{numberCOSXXX} & $\numberCOSXXX\approx\cos{\pi/6}$ & |
| 323 |
% \ttfamily \cs{numberCOSXLV} & $\numberCOSXLV\approx\cos{\pi/4}$ |
| 324 |
% \end{tabular} |
| 325 |
% \end{center} |
| 326 |
% \section{Operations with numbers} |
| 327 |
% \subsection{Assignments and comparisons} |
| 328 |
% The first command we describe here is used to store a number |
| 329 |
% in a control sequence. |
| 330 |
% The other two commands in this section determine the maximum and minimum |
| 331 |
% of a pair of numbers. |
| 332 |
% \begin{description} |
| 333 |
% \item[\cs{COPY}\marg{num}\marg{\cs{cmd}}]\SpecialUsageIndex{\COPY}% |
| 334 |
% stores the number \textttit{num} to the command \textttit{\TBS cmd}. |
| 335 |
% \begin{exemple} |
| 336 |
% \COPY{-1.256}{\sol} |
| 337 |
% \sol |
| 338 |
% \end{exemple} |
| 339 |
% \item[\cs{MAX}\marg{num1}\marg{num2}\marg{\cs{cmd}}]% |
| 340 |
% \SpecialUsageIndex{\MAX}% |
| 341 |
% stores in \textttit{\TBS cmd} the maximum of the numbers \textttit{num1} |
| 342 |
% and \textttit{num2}. |
| 343 |
% \begin{exemple} |
| 344 |
% \MAX{1.256}{3.214}{\sol} |
| 345 |
% \[\max(1.256,3.214)=\sol\] |
| 346 |
% \end{exemple} |
| 347 |
% \item[\cs{MIN}\marg{num1}\marg{num2}\marg{\cs{cmd}}]% |
| 348 |
% \SpecialUsageIndex{\MIN}% |
| 349 |
% stores in \textttit{\TBS cmd} the minimum of \textttit{num1} and |
| 350 |
% \textttit{num2}. |
| 351 |
% \begin{exemple} |
| 352 |
% \MIN{1.256}{3.214}{\sol} |
| 353 |
% \sol |
| 354 |
% \end{exemple} |
| 355 |
% \end{description} |
| 356 |
% \subsection{Real arithmetic} |
| 357 |
% \subsubsection{The four basic operations} |
| 358 |
% The following commands calculate the four arithmetical basic operations. |
| 359 |
% \begin{description} |
| 360 |
% \item[\cs{ADD}\marg{num1}\marg{num2}\marg{\cs{cmd}}]% |
| 361 |
% \SpecialUsageIndex{\ADD}% |
| 362 |
% Sum of numbers \textttit{num1} and \textttit{num2}. |
| 363 |
% \begin{exemple} |
| 364 |
% \ADD{1.256}{3.214}{\sol} |
| 365 |
% $1.256+3.214=\sol$ |
| 366 |
% \end{exemple} |
| 367 |
% |
| 368 |
% \item[\cs{SUBTRACT}\marg{num1}\marg{num2}\marg{\cs{cmd}}]% |
| 369 |
% \SpecialUsageIndex{\SUBTRACT}% |
| 370 |
% Difference \textttit{num1}-\textttit{num2}. |
| 371 |
% \begin{exemple} |
| 372 |
% \SUBTRACT{1.256}{3.214}{\sol} |
| 373 |
% $1.256-3.214=\sol$ |
| 374 |
% \end{exemple} |
| 375 |
% |
| 376 |
% \item[\cs{MULTIPLY}\marg{num1}\marg{num2}\marg{\cs{cmd}}]% |
| 377 |
% \SpecialUsageIndex{\MULTIPLY}% |
| 378 |
% Product \textttit{num1}$\times$\textttit{num2}. |
| 379 |
% \begin{exemple} |
| 380 |
% \MULTIPLY{1.256}{3.214}{\sol} |
| 381 |
% $1.256\times3.214=\sol$ |
| 382 |
% \end{exemple} |
| 383 |
% |
| 384 |
% \item[\cs{DIVIDE}\marg{num1}\marg{num2}\marg{\cs{cmd}}]% |
| 385 |
% \SpecialUsageIndex{\DIVIDE}% |
| 386 |
% Quotient |
| 387 |
% \textttit{num1}/\textttit{num2}.\footnote{This command uses a modified |
| 388 |
% version of the division algorithm of Claudio Beccari.} |
| 389 |
% \begin{exemple} |
| 390 |
% \DIVIDE{1.256}{3.214}{\sol} |
| 391 |
% $1.256/3.214=\sol$ |
| 392 |
% \end{exemple} |
| 393 |
% \end{description} |
| 394 |
% \subsubsection{Powers with integer exponent} |
| 395 |
% \begin{description} |
| 396 |
% \item[\cs{SQUARE}\marg{num}\marg{\cs{cmd}}]\SpecialUsageIndex{\SQUARE}% |
| 397 |
% Square of the number \textttit{num}. |
| 398 |
% \begin{exemple} |
| 399 |
% \SQUARE{-1.256}{\sol} |
| 400 |
% $(-1.256)^2=\sol$ |
| 401 |
% \end{exemple} |
| 402 |
% \item[\cs{CUBE}\marg{num}\marg{\cs{cmd}}]\SpecialUsageIndex{\CUBE}% |
| 403 |
% Cube of \textttit{num}. |
| 404 |
% \begin{exemple} |
| 405 |
% \CUBE{-1.256}{\sol} |
| 406 |
% $(-1.256)^3=\sol$ |
| 407 |
% \end{exemple} |
| 408 |
% \item[\cs{POWER}\marg{num}\marg{exp}\marg{\cs{cmd}}]% |
| 409 |
% \SpecialUsageIndex{\POWER}% |
| 410 |
% The \textttit{exp} power of \textttit{num}. |
| 411 |
% |
| 412 |
% The exponent, \textttit{exp}, must be an integer |
| 413 |
% (if you want to calculate powers |
| 414 |
% with non integer exponents, use the \cs{EXP} command). |
| 415 |
% \begin{exemple} |
| 416 |
% \POWER{-1.256}{-5}{\sola} |
| 417 |
% \POWER{-1.256}{5}{\solb} |
| 418 |
% \POWER{-1.256}{0}{\solc} |
| 419 |
% \[ |
| 420 |
% \begin{aligned} |
| 421 |
% (-1.256)^{-5}&=\sola |
| 422 |
% \\ |
| 423 |
% (-1.256)^{5}&=\solb |
| 424 |
% \\ |
| 425 |
% (-1.256)^{0}&=\solc |
| 426 |
% \end{aligned} |
| 427 |
% \] |
| 428 |
% \end{exemple} |
| 429 |
% \end{description} |
| 430 |
% |
| 431 |
% \subsubsection{Absolute value, integer part and fractional part} |
| 432 |
% \begin{description} |
| 433 |
% \item[\cs{ABSVALUE}\marg{num}\marg{\cs{cmd}}]\SpecialUsageIndex{\ABSVALUE}% |
| 434 |
% Absolute value of \textttit{num}. |
| 435 |
% \begin{exemple} |
| 436 |
% \ABSVALUE{-1.256}{\sol} |
| 437 |
% $\left\vert-1.256\right\vert=\sol$ |
| 438 |
% \end{exemple} |
| 439 |
% \item[\cs{INTEGERPART}\marg{num}\marg{\cs{cmd}}]% |
| 440 |
% \SpecialUsageIndex{\INTEGERPART}% |
| 441 |
% Integer part of \textttit{num}.\footnote{The integer part of $x$ |
| 442 |
% is the largest integer that is less than or equal to $x$.} |
| 443 |
% \begin{exemple} |
| 444 |
% \INTEGERPART{1.256}{\sola} |
| 445 |
% \INTEGERPART{-1.256}{\solb} |
| 446 |
% The integer part of $1.256$ is $\sola$, |
| 447 |
% but the integer part of $-1.256$ is $\solb$. |
| 448 |
% \end{exemple} |
| 449 |
% \item[\cs{FLOOR}]\SpecialUsageIndex{\FLOOR}% |
| 450 |
% is an alias of \cs{INTEGERPART}. |
| 451 |
% \begin{exemple} |
| 452 |
% \FLOOR{1.256}{\sol} |
| 453 |
% The integer part of $1.256$ is $\sol$. |
| 454 |
% \end{exemple} |
| 455 |
% \item[\cs{FRACTIONALPART}\marg{num}\marg{\cs{cmd}}]% |
| 456 |
% \SpecialUsageIndex{\FRACTIONALPART}% |
| 457 |
% Fractional part of \textttit{num}.\renewinversion[thanks to July Tikhonov |
| 458 |
% who reported a bug and suggested the solution]{2.1} |
| 459 |
% \begin{exemple} |
| 460 |
% \FRACTIONALPART{1.256}{\sol} |
| 461 |
% \sol |
| 462 |
% |
| 463 |
% \FRACTIONALPART{-1.256}{\sol} |
| 464 |
% \sol |
| 465 |
% \end{exemple} |
| 466 |
% \end{description} |
| 467 |
% \subsubsection{Truncation and rounding} |
| 468 |
% \begin{description} |
| 469 |
% \item[\cs{TRUNCATE}\oarg{n}\marg{num}\marg{\cs{cmd}}]% |
| 470 |
% \SpecialUsageIndex{\TRUNCATE}% |
| 471 |
% truncates the number \textttit{num} to \textttit{n} decimal places. |
| 472 |
% \item[\cs{ROUND}{[\textttit{n}]}\marg{num}\marg{\cs{cmd}}]% |
| 473 |
% \SpecialUsageIndex{\ROUND}% |
| 474 |
% rounds the number \textttit{num} to \textttit{n} decimal places.% |
| 475 |
% \renewinversion[thanks to Jim Cline and Schremmer Alain |
| 476 |
% who reported a bug]{2.1} |
| 477 |
% |
| 478 |
% The optional argument \textttit{n} may be \texttt{0}, \texttt{1}, |
| 479 |
% \texttt{2}, \texttt{3} or \texttt{4} (the default is \texttt{2}).\footnote{% |
| 480 |
% Note than \cs{TRUNCATE[0]} is equivalent to \cs{INTEGERPART} |
| 481 |
% only for non-negative numbers.} |
| 482 |
% \begin{exemple} |
| 483 |
% \TRUNCATE[0]{1.25688}{\sol} |
| 484 |
% \sol |
| 485 |
% |
| 486 |
% \TRUNCATE[2]{1.25688}{\sol} |
| 487 |
% \sol |
| 488 |
% |
| 489 |
% \TRUNCATE[4]{1.25688}{\sol} |
| 490 |
% \sol |
| 491 |
% \end{exemple} |
| 492 |
% \begin{exemple} |
| 493 |
% \ROUND[0]{1.25688}{\sol} |
| 494 |
% \sol |
| 495 |
% |
| 496 |
% \ROUND[2]{1.25688}{\sol} |
| 497 |
% \sol |
| 498 |
% |
| 499 |
% \ROUND[4]{1.25688}{\sol} |
| 500 |
% \sol |
| 501 |
% \end{exemple} |
| 502 |
% \end{description} |
| 503 |
% |
| 504 |
% \subsection{Integers} |
| 505 |
% The operations described here are subject |
| 506 |
% to the same restrictions as those referring to decimal numbers. |
| 507 |
% In particular, although \TeX{} does not have this restriction |
| 508 |
% in its integer arithmetic, |
| 509 |
% the largest integer that can be used is 16383. |
| 510 |
% \subsubsection{Integer division, quotient and remainder} |
| 511 |
% \begin{description} |
| 512 |
% \item |
| 513 |
% [\cs{INTEGERDIVISION}\marg{num1}\marg{num2}\marg{\cs{cmd1}}\marg{\cs{cmd2}}] |
| 514 |
% \SpecialUsageIndex{\INTEGERDIVISION}% |
| 515 |
% stores in the \textttit{\TBS cmd1} and |
| 516 |
% \textttit{\TBS cmd2} commands the quotient and the remainder of the |
| 517 |
% integer division of the two integers |
| 518 |
% \textttit{num1} and \textttit{num2}. |
| 519 |
% The remainder is a non-negative number smaller than the divisor.\footnote{% |
| 520 |
% The scientific computing systems (such as Matlab. Scilab or Mathematica) |
| 521 |
% do not always return a non-negative residue |
| 522 |
% ---especially when the divisor is negative---. |
| 523 |
% However, the most reasonable definition of integer quotient is this one: |
| 524 |
% \emph{the quotient of the division $D/d$ is the largest number $q$ |
| 525 |
% for which $dq \leq D$}. |
| 526 |
% With this definition, the remainder $r=D-qd$ is a non-negative number.} |
| 527 |
% \begin{exemple} |
| 528 |
% \INTEGERDIVISION{435}{27}{\sola}{\solb} |
| 529 |
% $435=27\times\sola+\solb$ |
| 530 |
% |
| 531 |
% \INTEGERDIVISION{27}{435}{\sola}{\solb} |
| 532 |
% $27=435\times\sola+\solb$ |
| 533 |
% |
| 534 |
% \INTEGERDIVISION{-435}{27}{\sola}{\solb} |
| 535 |
% $-435=27\times(\sola)+\solb$ |
| 536 |
% |
| 537 |
% \INTEGERDIVISION{435}{-27}{\sola}{\solb} |
| 538 |
% $435=-27\times(\sola)+\solb$ |
| 539 |
% |
| 540 |
% \INTEGERDIVISION{-435}{-27}{\sola}{\solb} |
| 541 |
% $-435=-27\times\sola+\solb$ |
| 542 |
% \end{exemple} |
| 543 |
% \item[\cs{INTEGERQUOTIENT}\marg{num1}\marg{num2}\marg{\cs{cmd}}] |
| 544 |
% \SpecialUsageIndex{\INTEGERQUOTIENT}% |
| 545 |
% Integer part of the quotient of |
| 546 |
% \textttit{num1} and \textttit{num2}. These two numbers are not necessarily |
| 547 |
% integers. |
| 548 |
% \begin{exemple} |
| 549 |
% \INTEGERQUOTIENT{435}{27}{\sol} |
| 550 |
% \sol |
| 551 |
% |
| 552 |
% \INTEGERQUOTIENT{27}{435}{\sol} |
| 553 |
% \sol |
| 554 |
% |
| 555 |
% \INTEGERQUOTIENT{-43.5}{2.7}{\sol} |
| 556 |
% \sol |
| 557 |
% \end{exemple} |
| 558 |
% \item[\cs{MODULO}\marg{num1}\marg{num2}\marg{\cs{cmd}}]% |
| 559 |
% \SpecialUsageIndex{\MODULO}% |
| 560 |
% Remainder of the integer division of |
| 561 |
% \textttit{num1} and \textttit{num2}. |
| 562 |
% \begin{exemple} |
| 563 |
% \MODULO{435}{27}{\sol} |
| 564 |
% \[ |
| 565 |
% 435 \equiv \sol \pmod{27} |
| 566 |
% \] |
| 567 |
% \MODULO{-435}{27}{\sol} |
| 568 |
% \[ |
| 569 |
% -435 \equiv \sol \pmod{27} |
| 570 |
% \] |
| 571 |
% \end{exemple} |
| 572 |
% \end{description} |
| 573 |
% \subsubsection{Greatest common divisor and least common multiple} |
| 574 |
% \begin{description} |
| 575 |
% \item |
| 576 |
% [\cs{GCD}\marg{num1}\marg{num2}\marg{\cs{cmd}}]\SpecialUsageIndex{\GCD}% |
| 577 |
% Greatest common divisor of the integers |
| 578 |
% \textttit{num1} and \textttit{num2}. |
| 579 |
% \begin{exemple} |
| 580 |
% \GCD{435}{27}{\sol} |
| 581 |
% $\gcd(435,27)=\sol$ |
| 582 |
% \end{exemple} |
| 583 |
% \item[\cs{LCM}\marg{num1}\marg{num2}\marg{\cs{cmd}}]% |
| 584 |
% \SpecialUsageIndex{\LCM}% |
| 585 |
% Least common multiple of \textttit{num1} and \textttit{num2}. |
| 586 |
% \begin{exemple} |
| 587 |
% \newcommand{\lcm}{\operatorname{lcm}} |
| 588 |
% \LCM{435}{27}{\sol} |
| 589 |
% $\lcm(435,27)=\sol$ |
| 590 |
% \end{exemple} |
| 591 |
% \end{description} |
| 592 |
% \subsubsection{Simplifying fractions} |
| 593 |
% \begin{description} |
| 594 |
% \item[\cs{FRACTIONSIMPLIFY}\marg{num1}\marg{num2}\marg{\cs{cmd1}}% |
| 595 |
% \marg{\cs{cmd2}}]\SpecialUsageIndex{\FRACTIONSIMPLIFY}% |
| 596 |
% stores in the \TBS\textttit{cmd1} and \textttit{\TBS cmd2} commands |
| 597 |
% the numerator and denominator of the irreducible fraction equivalent to |
| 598 |
% \textttit{num1}/\textttit{num2}. |
| 599 |
% \begin{exemple} |
| 600 |
% \FRACTIONSIMPLIFY{435}{27}{\sola}{\solb} |
| 601 |
% $435/27=\sola/\solb$ |
| 602 |
% \end{exemple} |
| 603 |
% \end{description} |
| 604 |
% \subsection{Elementary functions} |
| 605 |
% \subsubsection{Square roots} |
| 606 |
% \begin{description} |
| 607 |
% \item[\cs{SQUAREROOT}% |
| 608 |
% \marg{num}\marg{\cs{cmd}}]\SpecialUsageIndex{\SQUAREROOT}% |
| 609 |
% Square root of the number \textttit{num}. |
| 610 |
% \begin{exemple} |
| 611 |
% \SQUAREROOT{1.44}{\sol} |
| 612 |
% $\sqrt{1.44}=\sol$ |
| 613 |
% \end{exemple} |
| 614 |
% If the argument \textttit{num} is negative, the package returns |
| 615 |
% a warning message. |
| 616 |
% \end{description} |
| 617 |
% Instead of \cs{SQUAREROOT}, you can use the alias \cs{SQRT}.% |
| 618 |
% \SpecialUsageIndex{\SQRT} |
| 619 |
% |
| 620 |
% \subsubsection{Exponential and logarithm} |
| 621 |
% The \cs{EXP} and \cs{LOG} commands compute, by default, |
| 622 |
% exponentials and logarithms of the natural base $\mathrm{e}$. |
| 623 |
% They admit, however, an optional argument to choose another base. |
| 624 |
% \begin{description} |
| 625 |
% \item[\cs{EXP}% |
| 626 |
% \marg{num}\marg{\cs{cmd}}]\SpecialUsageIndex{\EXP}% |
| 627 |
% Exponential of the number \textttit{num}. |
| 628 |
% \begin{exemple} |
| 629 |
% \EXP{0.5}{\sol} |
| 630 |
% $\exp(0.5)=\sol$ |
| 631 |
% \end{exemple} |
| 632 |
% The argument \textttit{num} must be in the interval $[-9.704,9.704]$.% |
| 633 |
% \footnote{$9.704$ is the logarithm of $16383$, |
| 634 |
% the largest number that supports the \TeX's arithmetic.} |
| 635 |
% |
| 636 |
% Moreover, the \cs{EXP} command accepts an optional argument, |
| 637 |
% to compute expressions such as $a^x$: |
| 638 |
% \item[\cs{EXP}% |
| 639 |
% \oarg{num1}\marg{num2}\marg{\cs{cmd}}]\SpecialUsageIndex{\EXP}% |
| 640 |
% Exponential with base \textttit{num1} of \textttit{num2}. |
| 641 |
% \textttit{num1} must be a positive number. |
| 642 |
% \begin{exemple} |
| 643 |
% \EXP[10]{1.3}{\sol} |
| 644 |
% $10^{1.3}=\sol$ |
| 645 |
% |
| 646 |
% \EXP[2]{0.33333}{\sol} |
| 647 |
% $2^{1/3}=\sol$ |
| 648 |
% |
| 649 |
% \end{exemple} |
| 650 |
% \item[\cs{LOG}% |
| 651 |
% \marg{num}\marg{\cs{cmd}}]\SpecialUsageIndex{\LOG}% |
| 652 |
% logarithm of the number \textttit{num}. |
| 653 |
% \begin{exemple} |
| 654 |
% \LOG{0.5}{\sol} |
| 655 |
% $\log 0.5=\sol$ |
| 656 |
% \end{exemple} |
| 657 |
% \item[\cs{LOG}% |
| 658 |
% \oarg{num1}\marg{num2}\marg{\cs{cmd}}]\SpecialUsageIndex{\LOG}% |
| 659 |
% Logarithm in base \textttit{num1} of \textttit{num2}. |
| 660 |
% \begin{exemple} |
| 661 |
% \LOG[10]{0.5}{\sol} |
| 662 |
% $\log_{10} 0.5=\sol$ |
| 663 |
% \end{exemple} |
| 664 |
% \end{description} |
| 665 |
% \subsubsection{Trigonometric functions} |
| 666 |
% The arguments, in functions \cs{SIN}, \cs{COS}, \ldots, |
| 667 |
% are measured in radians. |
| 668 |
% If you measure angles in degrees (sexagesimal or not), use the |
| 669 |
% \cs{DEGREESSIN}, \cs{DEGREESCOS}, \dots\ commands. |
| 670 |
% \begin{description} |
| 671 |
% \item[\cs{SIN}% |
| 672 |
% \marg{num}\marg{\cs{cmd}}]\SpecialUsageIndex{\SIN}% |
| 673 |
% Sine of \textttit{num}. |
| 674 |
% |
| 675 |
% \item[\cs{COS}% |
| 676 |
% \marg{num}\marg{\cs{cmd}}]\SpecialUsageIndex{\COS}% |
| 677 |
% Cosine of \textttit{num}. |
| 678 |
% |
| 679 |
% \item[\cs{TAN}% |
| 680 |
% \marg{num}\marg{\cs{cmd}}]\SpecialUsageIndex{\TAN}% |
| 681 |
% Tangent of \textttit{num}. |
| 682 |
% |
| 683 |
% \item[\cs{COT}% |
| 684 |
% \marg{num}\marg{\cs{cmd}}]\SpecialUsageIndex{\COT}% |
| 685 |
% Cotangent of \textttit{num}. |
| 686 |
% \begin{exemple} |
| 687 |
% \SIN{\numberTHIRDPI}{\sol} |
| 688 |
% $\sin \pi/3=\sol$ |
| 689 |
% |
| 690 |
% \COS{\numberTHIRDPI}{\sol} |
| 691 |
% $\cos \pi/3=\sol$ |
| 692 |
% |
| 693 |
% \TAN{\numberTHIRDPI}{\sol} |
| 694 |
% $\tan \pi/3=\sol$ |
| 695 |
% |
| 696 |
% \COT{\numberTHIRDPI}{\sol} |
| 697 |
% $\cot \pi/3=\sol$ |
| 698 |
% \end{exemple} |
| 699 |
% |
| 700 |
% \item[\cs{DEGREESSIN}% |
| 701 |
% \marg{num}\marg{\cs{cmd}}]\SpecialUsageIndex{\DEGREESSIN}% |
| 702 |
% Sine of \textttit{num} sexagesimal degrees. |
| 703 |
% |
| 704 |
% \item[\cs{DEGREESCOS}% |
| 705 |
% \marg{num}\marg{\cs{cmd}}]\SpecialUsageIndex{\DEGREESCOS}% |
| 706 |
% Cosine of \textttit{num} sexagesimal degrees. |
| 707 |
% |
| 708 |
% \item[\cs{DEGREESTAN}% |
| 709 |
% \marg{num}\marg{\cs{cmd}}]\SpecialUsageIndex{\DEGREESTAN}% |
| 710 |
% Tangent of \textttit{num} sexagesimal degrees. |
| 711 |
% |
| 712 |
% \item[\cs{DEGREESCOT}% |
| 713 |
% \marg{num}\marg{\cs{cmd}}]\SpecialUsageIndex{\DEGREESCOT}% |
| 714 |
% Cotangent of \textttit{num} sexagesimal degrees. |
| 715 |
% |
| 716 |
% \begin{exemple} |
| 717 |
% \DEGREESSIN{60}{\sol} |
| 718 |
% $\sin 60^{\textrm o}=\sol$ |
| 719 |
% |
| 720 |
% \DEGREESCOS{60}{\sol} |
| 721 |
% $\cos 60^{\textrm o}=\sol$ |
| 722 |
% |
| 723 |
% \DEGREESTAN{60}{\sol} |
| 724 |
% $\tan 60^{\textrm o}=\sol$ |
| 725 |
% |
| 726 |
% \DEGREESCOT{60}{\sol} |
| 727 |
% $\cot 60^{\textrm o}=\sol$ |
| 728 |
% \end{exemple} |
| 729 |
% \end{description} |
| 730 |
% |
| 731 |
% The latter commands support an optional argument |
| 732 |
% that allows us to divide the circle |
| 733 |
% in an arbitrary number of \emph{degrees} (not necessarily $360$). |
| 734 |
% \begin{description} |
| 735 |
% \item[\cs{DEGREESSIN}% |
| 736 |
% \oarg{degrees}\marg{num}\marg{\cs{cmd}}] \mbox{} |
| 737 |
% \item[\cs{DEGREESCOS}% |
| 738 |
% \oarg{degrees}\marg{num}\marg{\cs{cmd}}] \mbox{} |
| 739 |
% \item[\cs{DEGREESTAN}% |
| 740 |
% \oarg{degrees}\marg{num}\marg{\cs{cmd}}] \mbox{} |
| 741 |
% \item[\cs{DEGREESCOT}% |
| 742 |
% \oarg{degrees}\marg{num}\marg{\cs{cmd}}] \mbox{} |
| 743 |
% \end{description} |
| 744 |
% |
| 745 |
% By example, |\DEGREESCOS[400]{50}| computes the cosine of 50 gradians |
| 746 |
% (a right angle has $100$ gradians, the whole circle has 400 gradians), |
| 747 |
% which are equivalent to 45 (sexagesimal) degrees or |
| 748 |
% $\pi/4$ radians. Or to 1 \emph{degree}, |
| 749 |
% if we divide the circle into 8 parts! |
| 750 |
% \begin{exemple} |
| 751 |
% \DEGREESCOS[400]{50}{\sol} |
| 752 |
% \sol |
| 753 |
% |
| 754 |
% \DEGREESCOS{45}{\sol} |
| 755 |
% \sol |
| 756 |
% |
| 757 |
% \COS{\numberQUARTERPI}{\sol} |
| 758 |
% \sol |
| 759 |
% |
| 760 |
% \DEGREESCOS[8]{1}{\sol} |
| 761 |
% \sol |
| 762 |
% \end{exemple} |
| 763 |
% |
| 764 |
% Moreover, we have a couple of commands |
| 765 |
% to convert between radians and degrees, |
| 766 |
% \begin{description} |
| 767 |
% \item[\cs{DEGtoRAD}% |
| 768 |
% \marg{num}\marg{\cs{cmd}}]\SpecialUsageIndex{\DEGtoRAD}% |
| 769 |
% Equivalence in radians |
| 770 |
% of \textttit{num} sexagesimal degrees. |
| 771 |
% \item[\cs{RADtoDEG}% |
| 772 |
% \marg{num}\marg{\cs{cmd}}]\SpecialUsageIndex{\RADtoDEG}% |
| 773 |
% Equivalence in sexagesimal degrees |
| 774 |
% of \textttit{num} radians. |
| 775 |
% \begin{exemple} |
| 776 |
% \DEGtoRAD{60}{\sol} |
| 777 |
% \sol |
| 778 |
% \end{exemple} |
| 779 |
% \end{description} |
| 780 |
% and two other commands to reduce arguments to basic intervals: |
| 781 |
% \begin{description} |
| 782 |
% \item[\cs{REDUCERADIANSANGLE}% |
| 783 |
% \marg{num}\marg{\cs{cmd}}]\SpecialUsageIndex{\REDUCERADIANSANGLE}% |
| 784 |
% Reduces the arc \textttit{num} to the interval $]-\pi,\pi]$. |
| 785 |
% |
| 786 |
% \item[\cs{REDUCEDEGREESANGLE}% |
| 787 |
% \marg{num}\marg{\cs{cmd}}]\SpecialUsageIndex{\REDUCEDEGREESANGLE}% |
| 788 |
% Reduces the angle \textttit{num} to the interval $]-180,180]$. |
| 789 |
% \begin{exemple} |
| 790 |
% \MULTIPLY{\numberTWOPI}{10}{\TWENTYPI} |
| 791 |
% \ADD{\numberPI}{\TWENTYPI}{\TWENTYONEPI} |
| 792 |
% \REDUCERADIANSANGLE{\TWENTYONEPI}{\sol} |
| 793 |
% \sol |
| 794 |
% |
| 795 |
% \REDUCEDEGREESANGLE{3690}{\sol} |
| 796 |
% \sol |
| 797 |
% \end{exemple} |
| 798 |
% |
| 799 |
% |
| 800 |
% \end{description} |
| 801 |
% |
| 802 |
% \subsubsection{Hyperbolic functions} |
| 803 |
% \begin{description} |
| 804 |
% \item[\cs{SINH}% |
| 805 |
% \marg{num}\marg{\cs{cmd}}]\SpecialUsageIndex{\SINH}% |
| 806 |
% stores in \textttit{\TBS cmd} |
| 807 |
% the hyperbolic sine of \textttit{num}. |
| 808 |
% |
| 809 |
% \item[\cs{COSH}% |
| 810 |
% \marg{num}\marg{\cs{cmd}}]\SpecialUsageIndex{\COSH}% |
| 811 |
% Hyperbolic cosine of \textttit{num}. |
| 812 |
% |
| 813 |
% \item[\cs{TANH}% |
| 814 |
% \marg{num}\marg{\cs{cmd}}]\SpecialUsageIndex{\TANH}% |
| 815 |
% Hyperbolic tangent of \textttit{num}. |
| 816 |
% |
| 817 |
% \item[\cs{COTH}% |
| 818 |
% \marg{num}\marg{\cs{cmd}}]\SpecialUsageIndex{\COTH}% |
| 819 |
% Hyperbolic cotangent of \textttit{num}. |
| 820 |
% |
| 821 |
% \begin{exemple} |
| 822 |
% \SINH{1.256}{\sol} |
| 823 |
% \sol |
| 824 |
% |
| 825 |
% \COSH{1.256}{\sol} |
| 826 |
% \sol |
| 827 |
% |
| 828 |
% \TANH{1.256}{\sol} |
| 829 |
% \sol |
| 830 |
% |
| 831 |
% \COTH{1.256}{\sol} |
| 832 |
% \sol |
| 833 |
% \end{exemple} |
| 834 |
% \end{description} |
| 835 |
% |
| 836 |
% \subsubsection{Inverse trigonometric functions\newinversion{2.0}} |
| 837 |
% \begin{description} |
| 838 |
% \item[\cs{ARCSIN}% |
| 839 |
% \marg{num}\marg{\cs{cmd}}]\SpecialUsageIndex{\ARCSIN}% |
| 840 |
% stores in \textttit{\TBS cmd} |
| 841 |
% the arcsin (inverse of sine) of \textttit{num}. |
| 842 |
% |
| 843 |
% \item[\cs{ARCCOS}% |
| 844 |
% \marg{num}\marg{\cs{cmd}}]\SpecialUsageIndex{\ARCCOS}% |
| 845 |
% arccos of \textttit{num}. |
| 846 |
% |
| 847 |
% \item[\cs{ARCTAN}% |
| 848 |
% \marg{num}\marg{\cs{cmd}}]\SpecialUsageIndex{\ARCTAN}% |
| 849 |
% arctan of \textttit{num}. |
| 850 |
% |
| 851 |
% \item[\cs{ARCCOT}% |
| 852 |
% \marg{num}\marg{\cs{cmd}}]\SpecialUsageIndex{\ARCCOT}% |
| 853 |
% arccot of \textttit{num}. |
| 854 |
% |
| 855 |
% \begin{exemple} |
| 856 |
% \ARCSIN{0.5}{\sol} |
| 857 |
% \sol |
| 858 |
% |
| 859 |
% \ARCCOS{0.5}{\sol} |
| 860 |
% \sol |
| 861 |
% |
| 862 |
% \ARCTAN{\numberSQRTTHREE}{\sol} |
| 863 |
% \sol |
| 864 |
% |
| 865 |
% \ARCCOT{-1}{\sol} |
| 866 |
% \sol |
| 867 |
% \end{exemple} |
| 868 |
% \end{description} |
| 869 |
% |
| 870 |
% \subsubsection{Inverse hyperbolic functions\newinversion{2.0}} |
| 871 |
% \begin{description} |
| 872 |
% \item[\cs{ARSINH}% |
| 873 |
% \marg{num}\marg{\cs{cmd}}]\SpecialUsageIndex{\ARSINH}% |
| 874 |
% stores in \textttit{\TBS cmd} |
| 875 |
% the arsinh (inverse of hyperbolic sine) of \textttit{num}. |
| 876 |
% |
| 877 |
% \item[\cs{ARCOSH}% |
| 878 |
% \marg{num}\marg{\cs{cmd}}]\SpecialUsageIndex{\ARCOSH}% |
| 879 |
% arcosh of \textttit{num}. |
| 880 |
% |
| 881 |
% \item[\cs{ARTANH}% |
| 882 |
% \marg{num}\marg{\cs{cmd}}]\SpecialUsageIndex{\ARTANH}% |
| 883 |
% artanh of \textttit{num}. |
| 884 |
% |
| 885 |
% \item[\cs{ARCOTH}% |
| 886 |
% \marg{num}\marg{\cs{cmd}}]\SpecialUsageIndex{\ARCOTH}% |
| 887 |
% arcoth of \textttit{num}. |
| 888 |
% |
| 889 |
% \begin{exemple} |
| 890 |
% \ARSINH{1}{\sol} |
| 891 |
% \sol |
| 892 |
% |
| 893 |
% \ARCOSH{1}{\sol} |
| 894 |
% \sol |
| 895 |
% |
| 896 |
% \ARTANH{0.5}{\sol} |
| 897 |
% \sol |
| 898 |
% |
| 899 |
% \ARCOTH{2}{\sol} |
| 900 |
% \sol |
| 901 |
% \end{exemple} |
| 902 |
% \end{description} |
| 903 |
% |
| 904 |
% \section{Operations with lengths} |
| 905 |
% \begin{description} |
| 906 |
% \item[\cs{LENGTHDIVIDE}\marg{length1}\marg{length2}\marg{\cs{cmd}}]% |
| 907 |
% \SpecialUsageIndex{\LENGTHDIVIDE}\mbox{} |
| 908 |
% |
| 909 |
% This command divides two lengths |
| 910 |
% and returns a number. |
| 911 |
% \begin{exemple} |
| 912 |
% \LENGTHDIVIDE{1in}{1cm}{\sol} |
| 913 |
% One inch equals $\sol$ centimeters. |
| 914 |
% \end{exemple} |
| 915 |
% |
| 916 |
% Commands \cs{LENGTHADD} and \cs{LENGTHSUBTRACT} return the sum and |
| 917 |
% the difference of two lengths \newinversion{2.0}. |
| 918 |
% |
| 919 |
% \item[\cs{LENGTHADD}\marg{length1}\marg{length2}\marg{\cs{cmd}}]% |
| 920 |
% \SpecialUsageIndex{\LENGTHADD}\mbox{} |
| 921 |
% \item[\cs{LENGTHSUBTRACT}\marg{length1}\marg{length2}\marg{\cs{cmd}}]% |
| 922 |
% \SpecialUsageIndex{\LENGTHSUBTRACT}\mbox{} |
| 923 |
% |
| 924 |
% (\cs{cmd} must be a predefined length). |
| 925 |
% \begin{exemple} |
| 926 |
% \newlength{\mylength} |
| 927 |
% \LENGTHADD{1in}{1cm}{\mylength} |
| 928 |
% $1in+1cm=\the\mylength$. |
| 929 |
% |
| 930 |
% \LENGTHSUBTRACT{1in}{1cm}{\mylength} |
| 931 |
% $1in-1cm=\the\mylength$. |
| 932 |
% \end{exemple} |
| 933 |
% \end{description} |
| 934 |
% |
| 935 |
% \section{Matrix arithmetic} |
| 936 |
% The \textsf{calculator} package defines the commands described below |
| 937 |
% to operate on vectors and matrices. |
| 938 |
% We only work with two or three-dimensional vectors and |
| 939 |
% $2\times2$ and $3\times3$ matrices. |
| 940 |
% Vectors are represented in the form |
| 941 |
% |(a1,a2)| or |(a1,a2,a3);|\footnote{But they are \emph{column} vectors.} |
| 942 |
% and, in the case of matrices, columns are separated \emph{\`a la matlab} |
| 943 |
% by semicolons: |(a11,a12;a21,a22)| |
| 944 |
% or |(a11,a12,a13;a21,a22,a23;a31,a32,a33)|. |
| 945 |
% \subsection{Vector operations} |
| 946 |
% \subsubsection{Assignments} |
| 947 |
% \begin{description} |
| 948 |
% \item[\cs{VECTORCOPY}\parg{x,y}\parg{\TBS cmd1,\TBS cmd2}]% |
| 949 |
% \SpecialUsageIndex{\VECTORCOPY}% |
| 950 |
% copy the entries of vector \parg{x,y} to the |
| 951 |
% \textttit{\TBS cmd1} and \textttit{\TBS cmd2} commands. |
| 952 |
% \item[\cs{VECTORCOPY}\parg{x,y,z}\parg{\TBS cmd1,\TBS cmd2,\TBS cmd3}] |
| 953 |
% copy the entries of vector (\textttit{x},\textttit{y},\textttit{z}) to the |
| 954 |
% \textttit{\TBS cmd1}, \textttit{\TBS cmd2} and |
| 955 |
% \textttit{\TBS cmd3} commands. |
| 956 |
% \begin{exemple} |
| 957 |
% \VECTORCOPY(1,-1)(\sola,\solb) |
| 958 |
% $(\sola,\solb)$ |
| 959 |
% |
| 960 |
% \VECTORCOPY(1,-1,2)(\sola,\solb,\solc) |
| 961 |
% $(\sola,\solb,\solc)$ |
| 962 |
% \end{exemple} |
| 963 |
% \end{description} |
| 964 |
% |
| 965 |
% \subsubsection{Vector addition and subtraction} |
| 966 |
% \begin{description} |
| 967 |
% \item[\cs{VECTORADD}\parg{x1,y1}\parg{x2,y2}\parg{\TBS cmd1,\TBS cmd2}] |
| 968 |
% \SpecialUsageIndex{\VECTORADD} |
| 969 |
% |
| 970 |
% \item[\cs{VECTORADD}\parg{x1,y1,z1}\parg{x2,y2,z2}% |
| 971 |
% \parg{\TBS cmd1,\TBS cmd2,\TBS cmd3}] |
| 972 |
% \SpecialUsageIndex{\VECTORADD} |
| 973 |
% |
| 974 |
% \item[\cs{VECTORSUB}\parg{x1,y1}\parg{x2,y2}\parg{\TBS cmd1,\TBS cmd2}] |
| 975 |
% \SpecialUsageIndex{\VECTORSUB} |
| 976 |
% |
| 977 |
% \item[\cs{VECTORSUB}\parg{x1,y1,z1}\parg{x2,y2,z2}% |
| 978 |
% \parg{\TBS cmd1,\TBS cmd2,\TBS cmd3}]\mbox{} |
| 979 |
% \SpecialUsageIndex{\VECTORSUB} |
| 980 |
% |
| 981 |
% \begin{exemple} |
| 982 |
% \VECTORADD(1,-1,2)(3,5,-1)(\sola,\solb,\solc) |
| 983 |
% $(1,-1,2)+(3,5,-1)=(\sola,\solb,\solc)$ |
| 984 |
% |
| 985 |
% \VECTORSUB(1,-1,2)(3,5,-1)(\sola,\solb,\solc) |
| 986 |
% $(1,-1,2)-(3,5,-1)=(\sola,\solb,\solc)$ |
| 987 |
% \end{exemple} |
| 988 |
% \end{description} |
| 989 |
% \subsubsection{Scalar-vector product} |
| 990 |
% \begin{description} |
| 991 |
% \item[\cs{SCALARVECTORPRODUCT}\marg{num}\parg{x,y}% |
| 992 |
% \parg{\cs{cmd1},\cs{cmd2}}]\mbox{} |
| 993 |
% \SpecialUsageIndex{\SCALARVECTORPRODUCT} |
| 994 |
% |
| 995 |
% \item[\cs{SCALARVECTORPRODUCT}\marg{num}\parg{x,y,z}% |
| 996 |
% \parg{\cs{cmd1},\cs{cmd2},\cs{cmd3}}]\mbox{} |
| 997 |
% \SpecialUsageIndex{\SCALARVECTORPRODUCT} |
| 998 |
% \begin{exemple} |
| 999 |
% \SCALARVECTORPRODUCT{2}(3,5)(\sola,\solb) |
| 1000 |
% $2(3,5)=(\sola,\solb)$ |
| 1001 |
% |
| 1002 |
% \SCALARVECTORPRODUCT{2}(3,5,-1)(% |
| 1003 |
% \sola,\solb,\solc) |
| 1004 |
% $2(3,5,-1)=(\sola,\solb,\solc)$ |
| 1005 |
% \end{exemple} |
| 1006 |
% \end{description} |
| 1007 |
% \subsubsection{Scalar (dot) product and euclidean norm} |
| 1008 |
% \begin{description} |
| 1009 |
% \item[\cs{SCALARPRODUCT}\parg{x1,y1}\parg{x2,y2}\marg{\cs{cmd}}] |
| 1010 |
% \SpecialUsageIndex{\SCALARPRODUCT}% |
| 1011 |
% |
| 1012 |
% \item[\cs{SCALARPRODUCT}\parg{x1,y1,z1}\parg{x2,y2,z2}\marg{\cs{cmd}}] |
| 1013 |
% \SpecialUsageIndex{\SCALARPRODUCT}% |
| 1014 |
% |
| 1015 |
% \item[\cs{DOTPRODUCT}]\SpecialUsageIndex{\DOTPRODUCT}% |
| 1016 |
% is an alias of \cs{SCALARPRODUCT} \newinversion{2.0}. |
| 1017 |
% |
| 1018 |
% \item[\cs{VECTORNORM}\parg{x,y}\marg{\cs{cmd}}]\mbox{} |
| 1019 |
% \SpecialUsageIndex{\VECTORNORM}% |
| 1020 |
% |
| 1021 |
% \item[\cs{VECTORNORM}\parg{x,y,z}\marg{\cs{cmd}}]\mbox{} |
| 1022 |
% \SpecialUsageIndex{\VECTORNORM}% |
| 1023 |
% \begin{exemple} |
| 1024 |
% \SCALARPRODUCT(1,-1)(3,5){\sol} |
| 1025 |
% $(1,-1)\cdot(3,5)=\sol$ |
| 1026 |
% |
| 1027 |
% \DOTPRODUCT(1,-1,2)(3,5,-1){\sol} |
| 1028 |
% $(1,-1,2)\cdot(3,5,-1)=\sol$ |
| 1029 |
% |
| 1030 |
% \VECTORNORM(3,4)\sol |
| 1031 |
% $\left\|(3,4)\right\|=\sol$ |
| 1032 |
% |
| 1033 |
% \VECTORNORM(1,2,-2)\sol |
| 1034 |
% $\left\|(1,2,-2)\right\|=\sol$ |
| 1035 |
% \end{exemple} |
| 1036 |
% \end{description} |
| 1037 |
% \subsubsection{Vector (cross) product \newinversion{2.0}} |
| 1038 |
% \begin{description} |
| 1039 |
% |
| 1040 |
% \item[\cs{VECTORPRODUCT}\parg{x1,y1,z1}\parg{x2,y2,z2}\parg{\cs{cmd1},\cs{cmd2},\cs{cmd3}}] |
| 1041 |
% \SpecialUsageIndex{\VECTORPRODUCT}% |
| 1042 |
% |
| 1043 |
% \item[\cs{CROSSPRODUCT}]\SpecialUsageIndex{\CROSSPRODUCT}% |
| 1044 |
% is an alias of \cs{VECTORPRODUCT}. |
| 1045 |
% \begin{exemple} |
| 1046 |
% \CROSSPRODUCT(1,-1,2)(3,5,-1)% |
| 1047 |
% (\sola,\solb,\solc) |
| 1048 |
% $(1,-1,2)\times(3,5,-1)=(\sola,\solb,\solc)$ |
| 1049 |
% |
| 1050 |
% \VECTORPRODUCT(1,-1,2)(-3,3,-6)% |
| 1051 |
% (\sola,\solb,\solc) |
| 1052 |
% $(1,-1,2)\times(-3,3,-6)=(\sola,\solb,\solc)$ |
| 1053 |
% |
| 1054 |
% \end{exemple} |
| 1055 |
% \end{description} |
| 1056 |
% \subsubsection{Unit vector parallel to a given vector (normalized vector)} |
| 1057 |
% \begin{description} |
| 1058 |
% \item[\cs{UNITVECTOR}\parg{x,y}\parg{\TBS cmd1,\TBS cmd2}] |
| 1059 |
% \SpecialUsageIndex{\UNITVECTOR}% |
| 1060 |
% |
| 1061 |
% \item[\cs{UNITVECTOR}\parg{x,y,z}\parg{\TBS cmd1,\TBS cmd2,\TBS cmd3}] |
| 1062 |
% \mbox{}\SpecialUsageIndex{\UNITVECTOR} |
| 1063 |
% \begin{exemple} |
| 1064 |
% \UNITVECTOR(3,4)(\sola,\solb) |
| 1065 |
% $(\sola,\solb)$ |
| 1066 |
% |
| 1067 |
% \UNITVECTOR(1,2,-2)(\sola,\solb,\solc) |
| 1068 |
% $(\sola,\solb,\solc)$ |
| 1069 |
% \end{exemple} |
| 1070 |
% \end{description} |
| 1071 |
% \subsubsection{Absolute value (in each entry of a given vector)} |
| 1072 |
% \begin{description} |
| 1073 |
% \item[\cs{VECTORABSVALUE}\parg{x,y}\parg{\TBS cmd1,\TBS cmd2}] |
| 1074 |
% \SpecialUsageIndex{\VECTORABSVALUE}% |
| 1075 |
% |
| 1076 |
% \item[\cs{VECTORABSVALUE}\parg{x,y,z}\parg{\TBS cmd1,\TBS cmd2,\TBS cmd3}] |
| 1077 |
% \mbox{} \SpecialUsageIndex{\VECTORABSVALUE} |
| 1078 |
% \begin{exemple} |
| 1079 |
% \VECTORABSVALUE(3,-4)(\sola,\solb) |
| 1080 |
% $(\sola,\solb)$ |
| 1081 |
% |
| 1082 |
% \VECTORABSVALUE(3,-4,-1)(\sola,\solb,\solc) |
| 1083 |
% $(\sola,\solb,\solc)$ |
| 1084 |
% \end{exemple} |
| 1085 |
% \end{description} |
| 1086 |
% \subsubsection{Angle between two vectors \newinversion{2.0}} |
| 1087 |
% \begin{description} |
| 1088 |
% \item[\cs{TWOVECTORSANGLE}\parg{x1,y1}\parg{x2,y2}\marg{\cs{cmd}}] |
| 1089 |
% \SpecialUsageIndex{\TWOVECTORSANGLE}% |
| 1090 |
% |
| 1091 |
% \item[\cs{TWOVECTORSANGLE}\parg{x1,y1,z1}\parg{x2,y2,z2}\marg{\cs{cmd}}] |
| 1092 |
% \mbox{} \SpecialUsageIndex{TWOVECTORSANGLE} |
| 1093 |
% \begin{exemple} |
| 1094 |
% \TWOVECTORSANGLE(1,1)(0,1){\sol} |
| 1095 |
% $\sol$ radians |
| 1096 |
% \RADtoDEG{\sol}{\degsol} |
| 1097 |
% (or $\degsol$ degrees) |
| 1098 |
% |
| 1099 |
% \TWOVECTORSANGLE(1,0,0)(0,1,0){\sol} |
| 1100 |
% $\sol$ |
| 1101 |
% \RADtoDEG{\sol}{\degsol} |
| 1102 |
% (or $\degsol$ degrees) |
| 1103 |
% \end{exemple} |
| 1104 |
% \end{description} |
| 1105 |
% |
| 1106 |
% \subsection{Matrix operations} |
| 1107 |
% \subsubsection{Assignments} |
| 1108 |
% \begin{description} |
| 1109 |
% \item[\cs{MATRIXCOPY}% |
| 1110 |
% \parg{a11,a12;a21,a22}% |
| 1111 |
% \parg{\cs{cmd11},\cs{cmd12};\cs{cmd21},\cs{cmd22}}]\mbox{} |
| 1112 |
% \SpecialUsageIndex{\MATRIXCOPY}% |
| 1113 |
% |
| 1114 |
% \noindent |
| 1115 |
% Use this command to store the matrix $\begin{bmatrix} |
| 1116 |
% a11 & a12 \\ a21 & 22 |
| 1117 |
% \end{bmatrix}$ in \textttit{\TBS cmm11}, \textttit{\TBS cmm12}, |
| 1118 |
% \textttit{\TBS cmm21}, \textttit{\TBS cmm22}. |
| 1119 |
% The analogous $3\times3$ version is |
| 1120 |
% \item[\cs{MATRIXCOPY}% |
| 1121 |
% \parg{a11,a12,a13; \textup{[\dots]} ,a33}% |
| 1122 |
% \parg{\cs{cmd11},\cs{cmd12},\cs{cmd13};% |
| 1123 |
% \textup{[\dots]} ,\cs{cmd33}}]\mbox{} |
| 1124 |
% \SpecialUsageIndex{\MATRIXCOPY}% |
| 1125 |
% \begin{exemple} |
| 1126 |
% \MATRIXCOPY(1, -1, 2; |
| 1127 |
% 3, 0, 5; |
| 1128 |
% -1, 1, 4)% |
| 1129 |
% (\sola,\solb,\solc; |
| 1130 |
% \sold,\sole,\solf; |
| 1131 |
% \solg,\solh,\soli) |
| 1132 |
% $\begin{bmatrix} |
| 1133 |
% \sola & \solb & \solc \\ |
| 1134 |
% \sold & \sole & \solf \\ |
| 1135 |
% \solg & \solh & \soli |
| 1136 |
% \end{bmatrix}$ |
| 1137 |
% \end{exemple} |
| 1138 |
% \end{description} |
| 1139 |
% |
| 1140 |
% |
| 1141 |
% Henceforth, we will present only the syntax for commands |
| 1142 |
% operating with $2\times2$ matrices. |
| 1143 |
% In all cases, the syntax is similar if we work with $3\times3$ matrices. |
| 1144 |
% In the examples, we will work with either $2\times2$ or $3\times3$ matrices. |
| 1145 |
% \subsubsection{Transposed matrix} |
| 1146 |
% \begin{description} |
| 1147 |
% \item[\cs{TRANSPOSEMATRIX}% |
| 1148 |
% \parg{a11,a12;a21,a22}% |
| 1149 |
% \parg{\cs{cmd11},\cs{cmd12};\cs{cmd21},\cs{cmd22}}]\mbox{} |
| 1150 |
% \SpecialUsageIndex{\TRANSPOSEMATRIX}% |
| 1151 |
% \begin{exemple} |
| 1152 |
% \TRANSPOSEMATRIX(1,-1;3,0)% |
| 1153 |
% (\sola,\solb;\solc,\sold) |
| 1154 |
% $\begin{bmatrix} |
| 1155 |
% 1 & -1 \\ 3 & 0 |
| 1156 |
% \end{bmatrix}^T=\begin{bmatrix} |
| 1157 |
% \sola & \solb \\ \solc & \sold |
| 1158 |
% \end{bmatrix}$ |
| 1159 |
% \end{exemple} |
| 1160 |
% \end{description} |
| 1161 |
% |
| 1162 |
% |
| 1163 |
% \subsubsection{Matrix addition and subtraction} |
| 1164 |
% \begin{description} |
| 1165 |
% \item[\cs{MATRIXADD}% |
| 1166 |
% \parg{a11,a12;a21,a22}% |
| 1167 |
% \parg{b11,b12;b21,b22}% |
| 1168 |
% \parg{\cs{cmd11},\cs{cmd12};\cs{cmd21},\cs{cmd22}}] |
| 1169 |
% \SpecialUsageIndex{\MATRIXADD}% |
| 1170 |
% |
| 1171 |
% \item[\cs{MATRIXSUB}% |
| 1172 |
% \parg{a11,a12;a21,a22}% |
| 1173 |
% \parg{b11,b12;b21,b22}% |
| 1174 |
% \parg{\cs{cmd11},\cs{cmd12};\cs{cmd21},\cs{cmd22}}]\mbox{} |
| 1175 |
% \SpecialUsageIndex{\MATRIXSUB}% |
| 1176 |
% |
| 1177 |
% \begin{exemple} |
| 1178 |
% \MATRIXADD(1,-1;3,0)(3,5;-3,2)% |
| 1179 |
% (\sola,\solb;\solc,\sold) |
| 1180 |
% $\begin{bmatrix} |
| 1181 |
% 1 & -1 \\ 3 & 0 |
| 1182 |
% \end{bmatrix}+ |
| 1183 |
% \begin{bmatrix} |
| 1184 |
% 3 & 5 \\ -3 & 2 |
| 1185 |
% \end{bmatrix}=\begin{bmatrix} |
| 1186 |
% \sola & \solb \\ \solc & \sold |
| 1187 |
% \end{bmatrix}$ |
| 1188 |
% |
| 1189 |
% \MATRIXSUB(1,-1;3,0)(3,5;-3,2)% |
| 1190 |
% (\sola,\solb;\solc,\sold) |
| 1191 |
% $\begin{bmatrix} |
| 1192 |
% 1 & -1 \\ 3 & 0 |
| 1193 |
% \end{bmatrix}- |
| 1194 |
% \begin{bmatrix} |
| 1195 |
% 3 & 5 \\ -3 & 2 |
| 1196 |
% \end{bmatrix}=\begin{bmatrix} |
| 1197 |
% \sola & \solb \\ \solc & \sold |
| 1198 |
% \end{bmatrix}$ |
| 1199 |
% \end{exemple} |
| 1200 |
% \end{description} |
| 1201 |
% \subsubsection{Scalar-matrix product} |
| 1202 |
% \begin{description} |
| 1203 |
% \item[\cs{SCALARMATRIXPRODUCT}\marg{num}% |
| 1204 |
% \parg{a11,a12;a21,a22}% |
| 1205 |
% \parg{\cs{cmd11},\cs{cmd12};\cs{cmd21},\cs{cmd22}}]\mbox{} |
| 1206 |
% \SpecialUsageIndex{\SCALARMATRIXPRODUCT}% |
| 1207 |
% |
| 1208 |
% \begin{exemple} |
| 1209 |
% \SCALARMATRIXPRODUCT{3}(1,-1,2; |
| 1210 |
% 3, 0,5; |
| 1211 |
% -1, 1,4)% |
| 1212 |
% (\sola,\solb,\solc; |
| 1213 |
% \sold,\sole,\solf; |
| 1214 |
% \solg,\solh,\soli) |
| 1215 |
% $3\begin{bmatrix} |
| 1216 |
% 1 & -1 & 2 \\ 3 & 0 & 5 \\ -1 & 1 & 4 |
| 1217 |
% \end{bmatrix} |
| 1218 |
% =\begin{bmatrix} |
| 1219 |
% \sola & \solb & \solc \\ |
| 1220 |
% \sold & \sole & \solf \\ |
| 1221 |
% \solg & \solh & \soli |
| 1222 |
% \end{bmatrix}$ |
| 1223 |
% \end{exemple} |
| 1224 |
% \end{description} |
| 1225 |
% \subsubsection{Matriu-vector product} |
| 1226 |
% \begin{description} |
| 1227 |
% \item[\cs{MATRIXVECTORPRODUCT}% |
| 1228 |
% \parg{a11,a12;a21,a22}\parg{x,y}% |
| 1229 |
% \parg{\cs{cmd1},\cs{cmd2}}]\mbox{} |
| 1230 |
% \SpecialUsageIndex{\MATRIXVECTORPRODUCT}% |
| 1231 |
% \begin{exemple} |
| 1232 |
% \MATRIXVECTORPRODUCT(1,-1; |
| 1233 |
% 0, 2)(3,5)(\sola,\solb) |
| 1234 |
% $\begin{bmatrix} |
| 1235 |
% 1 & -1 \\ 0 & 2 |
| 1236 |
% \end{bmatrix} |
| 1237 |
% \begin{bmatrix} |
| 1238 |
% 3 \\ 5 |
| 1239 |
% \end{bmatrix} |
| 1240 |
% =\begin{bmatrix} |
| 1241 |
% \sola \\ \solb |
| 1242 |
% \end{bmatrix}$ |
| 1243 |
% \end{exemple} |
| 1244 |
% \end{description} |
| 1245 |
% \subsubsection{Product of two square matrices} |
| 1246 |
% \begin{description} |
| 1247 |
% \item[\cs{MATRIXPRODUCT}% |
| 1248 |
% \parg{a11,a12;a21,a22}% |
| 1249 |
% \parg{b11,b12;b21,b22}% |
| 1250 |
% \parg{\cs{cmd11},\cs{cmd12};\cs{cmd21},\cs{cmd22}}] |
| 1251 |
% \mbox{} |
| 1252 |
% \SpecialUsageIndex{\MATRIXPRODUCT}% |
| 1253 |
% \begin{exemple} |
| 1254 |
% \MATRIXPRODUCT(1,-1,2;3,0,5;-1,1,4)% |
| 1255 |
% (3,5,-1;-3,2,-5;1,-2,3)% |
| 1256 |
% (\sola,\solb,\solc; |
| 1257 |
% \sold,\sole,\solf; |
| 1258 |
% \solg,\solh,\soli) |
| 1259 |
% \begin{multline*} |
| 1260 |
% \begin{bmatrix} |
| 1261 |
% 1 & -1 & 2 \\ 3 & 0 & 5 \\ -1 & 1 & 4 |
| 1262 |
% \end{bmatrix} |
| 1263 |
% \begin{bmatrix} |
| 1264 |
% 3 & 5 & -1 \\ -3 & 2 & -5 \\ 1 & -2 & 3 |
| 1265 |
% \end{bmatrix}\\ |
| 1266 |
% =\begin{bmatrix} |
| 1267 |
% \sola & \solb & \solc \\ |
| 1268 |
% \sold & \sole & \solf \\ |
| 1269 |
% \solg & \solh & \soli |
| 1270 |
% \end{bmatrix} |
| 1271 |
% \end{multline*} |
| 1272 |
% \end{exemple} |
| 1273 |
% \end{description} |
| 1274 |
% \subsubsection{Determinant} |
| 1275 |
% \begin{description} |
| 1276 |
% \item[\cs{DETERMINANT}% |
| 1277 |
% \parg{a11,a12;a21,a22} |
| 1278 |
% \marg{\cs{cmd}}]\mbox{} |
| 1279 |
% \begin{exemple} |
| 1280 |
% \DETERMINANT(1,-1,2;3,0,5;-1,1,4){\sol} |
| 1281 |
% \SpecialUsageIndex{\DETERMINANT}% |
| 1282 |
% $\begin{vmatrix} |
| 1283 |
% 1 & -1 & 2 \\ 3 & 0 & 5 \\ -1 & 1 & 4 |
| 1284 |
% \end{vmatrix}=\sol$ |
| 1285 |
% \end{exemple} |
| 1286 |
% \end{description} |
| 1287 |
% \subsubsection{Inverse matrix} |
| 1288 |
% \begin{description} |
| 1289 |
% \item[\cs{INVERSEMATRIX}% |
| 1290 |
% \parg{a11,a12;a21,a22}% |
| 1291 |
% \parg{\cs{cmd11},\cs{cmd12};\cs{cmd21},\cs{cmd22}}]\mbox{} |
| 1292 |
% \SpecialUsageIndex{\INVERSEMATRIX}% |
| 1293 |
% \begin{exemple} |
| 1294 |
% \INVERSEMATRIX(1,-1;3,5)(% |
| 1295 |
% \sola,\solb;\solc,\sold) |
| 1296 |
% $\begin{bmatrix} |
| 1297 |
% 1 & -1 \\ 3 & 5 |
| 1298 |
% \end{bmatrix}^{-1}= |
| 1299 |
% \begin{bmatrix} |
| 1300 |
% \sola & \solb \\ \solc & \sold |
| 1301 |
% \end{bmatrix}$ |
| 1302 |
% \end{exemple} |
| 1303 |
% |
| 1304 |
% If the given matrix is singular, the \textsf{calculator} package returns |
| 1305 |
% a warning message |
| 1306 |
% and the \textttit{\cs{cmd11}}, \ldots, commands are marqued as undefined. |
| 1307 |
% \end{description} |
| 1308 |
% \subsubsection{Absolute value (in each entry)} |
| 1309 |
% \begin{description} |
| 1310 |
% \item[\cs{MATRIXABSVALUE}% |
| 1311 |
% \parg{a11,a12;a21,a22}% |
| 1312 |
% \parg{\cs{cmd11},\cs{cmd12};\cs{cmd21},\cs{cmd22}}]\mbox{} |
| 1313 |
% \SpecialUsageIndex{\MATRIXABSVALUE}% |
| 1314 |
% |
| 1315 |
% \begin{exemple} |
| 1316 |
% \MATRIXABSVALUE(1,-1,2;3,0,5;-1,1,4)% |
| 1317 |
% (\sola,\solb,\solc; |
| 1318 |
% \sold,\sole,\solf; |
| 1319 |
% \solg,\solh,\soli) |
| 1320 |
% $\begin{bmatrix} |
| 1321 |
% \sola & \solb & \solc \\ |
| 1322 |
% \sold & \sole & \solf \\ |
| 1323 |
% \solg & \solh & \soli |
| 1324 |
% \end{bmatrix}$ |
| 1325 |
% \end{exemple} |
| 1326 |
% \end{description} |
| 1327 |
% \subsubsection{Solving a linear system} |
| 1328 |
% \begin{description} |
| 1329 |
% \item[\cs{SOLVELINEARSYSTEM}% |
| 1330 |
% \parg{a11,a12;a21,a22}\parg{b1,b2}\parg{\cs{cmd1},\cs{cmd2}}] |
| 1331 |
% \SpecialUsageIndex{\SOLVELINEARSYSTEM}% |
| 1332 |
% solves the linear system |
| 1333 |
% $\begin{pmatrix} |
| 1334 |
% \textttit{a11}&\textttit{a12}\\ |
| 1335 |
% \textttit{a21}&\textttit{a22} |
| 1336 |
% \end{pmatrix} |
| 1337 |
% \begin{pmatrix} |
| 1338 |
% \textttit{x}\\ |
| 1339 |
% \textttit{y}\end{pmatrix} |
| 1340 |
% =\begin{pmatrix} |
| 1341 |
% \textttit{b1}\\ |
| 1342 |
% \textttit{b2} |
| 1343 |
% \end{pmatrix}$ |
| 1344 |
% and stores the solution in (\textttit{\cs{cmd1}},\textttit{\cs{cmd2}}). |
| 1345 |
% \begin{exemple} |
| 1346 |
% \SOLVELINEARSYSTEM(1,-1,2;3,0,5;-1,1,4)% |
| 1347 |
% (-4,4,-2)% |
| 1348 |
% (\sola,\solb,\solc) |
| 1349 |
% Solving the linear system |
| 1350 |
% \[ |
| 1351 |
% \begin{bmatrix} |
| 1352 |
% 1 & -1 & 2 \\ 3 & 0 & 5 \\ -1 & 1 & 4 |
| 1353 |
% \end{bmatrix}\mathsf{X}=\begin{bmatrix} |
| 1354 |
% -4\\4\\-2 |
| 1355 |
% \end{bmatrix} |
| 1356 |
% \] |
| 1357 |
% we obtain |
| 1358 |
% $\mathsf{X}=\begin{bmatrix} |
| 1359 |
% \sola \\ \solb\\ \solc |
| 1360 |
% \end{bmatrix}$ |
| 1361 |
% \end{exemple} |
| 1362 |
% If the given matrix is singular, the package \textsf{calculator} |
| 1363 |
% returns a warning message. |
| 1364 |
% When system is indeterminate, in the bi-dimensional case |
| 1365 |
% one of the solutions is computed; |
| 1366 |
% if the system is incompatible, |
| 1367 |
% then the \verb+\sola+, \dots, commands are marqued as undefined. |
| 1368 |
% For three equations systems, only determinate systems are solved.\footnote{% |
| 1369 |
% This is the only command that does not behave the same way with |
| 1370 |
% $2\times2$ and $3\times3$ matrices.} |
| 1371 |
% \end{description} |
| 1372 |
% |
| 1373 |
% \part{The \textsf{calculus} package} |
| 1374 |
% \section{What is a \emph{function}?} |
| 1375 |
% From the point of view of this package, a \emph {function} $f$ is a pair of |
| 1376 |
% formulae: the first one calculates $f(t)$; the other, $f'(t)$. |
| 1377 |
% Therefore, any function is applied using three arguments: |
| 1378 |
% the value of the variable $t$, |
| 1379 |
% and two command names where $f(t)$ and $f'(t)$ will be stored. |
| 1380 |
% For example, |
| 1381 |
% \begin{quote} |
| 1382 |
% \cs{SQUAREfunction}\Marg{num}\Marg{\TBS sol}\Marg{\TBS Dsol} |
| 1383 |
% \end{quote} |
| 1384 |
% computes $f(t)=t^2$ and $f'(t)=2t$ (where $t=$\textit{num}), |
| 1385 |
% and stores the results in the commands |
| 1386 |
% \textit{\TBS sol} and \textit{\TBS Dsol}.\footnote% |
| 1387 |
% {Do not spect any control about the existence or differentiability |
| 1388 |
% of the function; if the function or the derivative |
| 1389 |
% are not well defined, a \TeX{} error will occur.} |
| 1390 |
% |
| 1391 |
% \begin{exemple} |
| 1392 |
% \SQUAREfunction{3}{\sol}{\Dsol} |
| 1393 |
% If $f(t)=t^2$, then |
| 1394 |
% \[ |
| 1395 |
% f(3)=\sol \mbox{ and } f'(3)=\Dsol |
| 1396 |
% \] |
| 1397 |
% \end{exemple} |
| 1398 |
% \medskip |
| 1399 |
% |
| 1400 |
% \noindent |
| 1401 |
% For all functions defined here, you must use the following syntax: |
| 1402 |
% \begin{quote} |
| 1403 |
% \textttit{\TBS functionname}\Marg{num}\Marg{\TBS cmd1}\Marg{\TBS cmd2} |
| 1404 |
% \end{quote} |
| 1405 |
% being \textit{num} a number (or a command whose value is a number), |
| 1406 |
% and \verb+\+\textit{cmd1} and \verb+\+\textit{cmd2} two control sequence |
| 1407 |
% names where the values of the function and its derivative (in this number) |
| 1408 |
% will be stored. |
| 1409 |
% \medskip |
| 1410 |
% |
| 1411 |
% The key difference between this \emph{functions} and the instructions |
| 1412 |
% defined in the \textsf{calculator} package |
| 1413 |
% is the inclusion of the derivative; for example, the |\SQUARE{3}{\sol}| |
| 1414 |
% instruction computes, only, |
| 1415 |
% the square power of number $3$, while |\SQUAREfunction{3}{\sol}{\Dsol}| |
| 1416 |
% finds, also, the corresponding derivative. |
| 1417 |
% \section{Predefined functions} |
| 1418 |
% The \textsf{calculus} package |
| 1419 |
% predefines the most commonly used elementary functions, |
| 1420 |
% and includes several utilities for defining new ones. |
| 1421 |
% The predefined functions are the following: |
| 1422 |
% \SpecialUsageIndex{\ZEROfunction} |
| 1423 |
% \SpecialUsageIndex{ONEfunction} |
| 1424 |
% \SpecialUsageIndex{IDENTITYfunction} |
| 1425 |
% \SpecialUsageIndex{RECIPROCALfunction} |
| 1426 |
% \SpecialUsageIndex{SQUAREfunction} |
| 1427 |
% \SpecialUsageIndex{CUBEfunction} |
| 1428 |
% \SpecialUsageIndex{SQRTfunction} |
| 1429 |
% \SpecialUsageIndex{EXPfunction} |
| 1430 |
% \SpecialUsageIndex{LOGfunction} |
| 1431 |
% \SpecialUsageIndex{COSfunction} |
| 1432 |
% \SpecialUsageIndex{SINfunction} |
| 1433 |
% \SpecialUsageIndex{TANfunction} |
| 1434 |
% \SpecialUsageIndex{COTfunction} |
| 1435 |
% \SpecialUsageIndex{COSHfunction} |
| 1436 |
% \SpecialUsageIndex{SINHfunction} |
| 1437 |
% \SpecialUsageIndex{TANHfunction} |
| 1438 |
% \SpecialUsageIndex{COTHfunction} |
| 1439 |
% \SpecialUsageIndex{HEAVISIDEfunction} |
| 1440 |
% \begin{center} |
| 1441 |
% \begin{tabular}{llll} |
| 1442 |
% \ttfamily \cs{ZEROfunction} & $f(t)=0$ & |
| 1443 |
% \ttfamily \cs{ONEfunction} & $f(t)=1$ \\ |
| 1444 |
% \ttfamily \cs{IDENTITYfunction} & $f(t)=t$ & |
| 1445 |
% \ttfamily \cs{RECIPROCALfunction} & $f(t)=1/t$ \\ |
| 1446 |
% \ttfamily \cs{SQUAREfunction} & $f(t)=t^2$ & |
| 1447 |
% \ttfamily \cs{CUBEfunction} & $f(t)=t^3$ \\ |
| 1448 |
% \ttfamily \cs{SQRTfunction} & $f(t)=\sqrt t$ \\ |
| 1449 |
% \ttfamily \cs{EXPfunction} & $f(t)=\exp t$ & |
| 1450 |
% \ttfamily \cs{LOGfunction} & $f(t)=\log t$ \\ |
| 1451 |
% \ttfamily \cs{COSfunction} & $f(t)=\cos t$ & |
| 1452 |
% \ttfamily \cs{SINfunction} & $f(t)=\sin t$ \\ |
| 1453 |
% \ttfamily \cs{TANfunction} & $f(t)=\tan t$ & |
| 1454 |
% \ttfamily \cs{COTfunction} & $f(t)=\cot t$ \\ |
| 1455 |
% \ttfamily \cs{COSHfunction} & $f(t)=\cosh t$ & |
| 1456 |
% \ttfamily \cs{SINHfunction} & $f(t)=\sinh t$ \\ |
| 1457 |
% \ttfamily \cs{TANHfunction} & $f(t)=\tanh t$ & |
| 1458 |
% \ttfamily \cs{COTHfunction} & $f(t)=\coth t$ \\ |
| 1459 |
% \ttfamily \cs{HEAVISIDEfunction} & $f(t)=\begin{cases} |
| 1460 |
% 0 & \text{si $t<0$} \\ |
| 1461 |
% 1 & \text{si $t\geq0$} |
| 1462 |
% \end{cases}$ |
| 1463 |
% \end{tabular} |
| 1464 |
% \end{center} |
| 1465 |
% |
| 1466 |
% The following functions are added in version 2.0 \newinversion{2.0} |
| 1467 |
% |
| 1468 |
% \begin{center} |
| 1469 |
% \begin{tabular}{llll} |
| 1470 |
% \ttfamily \cs{ARCCOSfunction} & $f(t)=\arccos t$ & |
| 1471 |
% \ttfamily \cs{ARCSINfunction} & $f(t)=\arcsin t$ \\ |
| 1472 |
% \ttfamily \cs{ARCTANfunction} & $f(t)=\arctan t$ & |
| 1473 |
% \ttfamily \cs{ARCCOTfunction} & $f(t)=\arccot t$ \\ |
| 1474 |
% \ttfamily \cs{ARCOSHfunction} & $f(t)=\arcosh t$ & |
| 1475 |
% \ttfamily \cs{ARSINHfunction} & $f(t)=\arsinh t$ \\ |
| 1476 |
% \ttfamily \cs{ARTANHfunction} & $f(t)=\artanh t$ & |
| 1477 |
% \ttfamily \cs{ARCOTHfunction} & $f(t)=\arcoth t$ \\ |
| 1478 |
% \end{tabular} |
| 1479 |
% \end{center} |
| 1480 |
% |
| 1481 |
% In the following example, we use the |\LOGfunction| function to compute |
| 1482 |
% a table of the $\log$ function and its derivative. |
| 1483 |
% \begin{exemple} |
| 1484 |
% $\begin{array}{cll} |
| 1485 |
% x & \log x & \log' x \\ |
| 1486 |
% \LOGfunction{1}{\logx}{\Dlogx} |
| 1487 |
% 1 &\logx & \Dlogx\\ |
| 1488 |
% \LOGfunction{2}{\logx}{\Dlogx} |
| 1489 |
% 2 &\logx & \Dlogx\\ |
| 1490 |
% \LOGfunction{3}{\logx}{\Dlogx} |
| 1491 |
% 3 &\logx & \Dlogx\\ |
| 1492 |
% \LOGfunction{4}{\logx}{\Dlogx} |
| 1493 |
% 4 &\logx & \Dlogx\\ |
| 1494 |
% \LOGfunction{5}{\logx}{\Dlogx} |
| 1495 |
% 5 &\logx & \Dlogx\\ |
| 1496 |
% \LOGfunction{6}{\logx}{\Dlogx} |
| 1497 |
% 6 &\logx & \Dlogx |
| 1498 |
% \end{array}$ |
| 1499 |
% \end{exemple} |
| 1500 |
% |
| 1501 |
% \section{Operations with functions} |
| 1502 |
% We can define new functions using the following \emph{operations} |
| 1503 |
% (the last argument is the name of the new function): |
| 1504 |
% \begin{description} |
| 1505 |
% \item[\cs{CONSTANTfunction}\Marg{num}\Marg{\TBS Function}]% |
| 1506 |
% \SpecialUsageIndex{\CONSTANTfunction} |
| 1507 |
% defines \textit{\TBS Function} as the constant function \textit{num}. |
| 1508 |
% |
| 1509 |
% Example. Definition of the $F(t)=5$ function: |
| 1510 |
% |
| 1511 |
% |\CONSTANTfunction{5}{\F}| |
| 1512 |
% |
| 1513 |
% \item[\cs{SUMfunction}\Marg{\TBS function1}\Marg{\TBS function2}% |
| 1514 |
% \Marg{\TBS Function}]\SpecialUsageIndex{\SUMfunction} |
| 1515 |
% defines \textit{\TBS Function} as the sum of functions |
| 1516 |
% \textit{\TBS function1} and \textit{\TBS function2}. |
| 1517 |
% |
| 1518 |
% Example. Definition of the $F(t)=t^2+t^3$ function: |
| 1519 |
% |
| 1520 |
% |\SUMfunction{\SQUAREfunction}{\CUBEfunction}{\F}| |
| 1521 |
% |
| 1522 |
% \item[\cs{SUBTRACTfunction}\Marg{\TBS function1}\Marg{\TBS function2}% |
| 1523 |
% \Marg{\TBS Function}]\SpecialUsageIndex{\SUBTRACTfunction} |
| 1524 |
% defines \textit{\TBS Function} as the difference of functions |
| 1525 |
% \textit{\TBS function1} and \textit{\TBS function2}. |
| 1526 |
% |
| 1527 |
% Example. Definition of the $F(t)=t^2-t^3$ function: |
| 1528 |
% |
| 1529 |
% |\SUBTRACTfunction{\SQUAREfunction}{\CUBEfunction}{\F}| |
| 1530 |
% |
| 1531 |
% \item[\cs{PRODUCTfunction}\Marg{\TBS function1}\Marg{\TBS function2}% |
| 1532 |
% \Marg{\TBS Function}]\SpecialUsageIndex{\PRODUCTfunction} |
| 1533 |
% defines \textit{\TBS Function} as the product of functions |
| 1534 |
% \textit{\TBS function1} and \textit{\TBS function2} |
| 1535 |
% |
| 1536 |
% Example. Definition of the $F(t)=\mathrm e^t\cos t$ function: |
| 1537 |
% |
| 1538 |
% |\PRODUCTfunction{\EXPfunction}{\COSfunction}{\F}| |
| 1539 |
% |
| 1540 |
% \item[\cs{QUOTIENTfunction}\Marg{\TBS function1}\Marg{\TBS function2}% |
| 1541 |
% \Marg{\TBS Function}]\SpecialUsageIndex{\QUOTIENTfunction} |
| 1542 |
% defines \textit{\TBS Function} as the quotient of functions |
| 1543 |
% \textit{\TBS function1} and \textit{\TBS function2}. |
| 1544 |
% |
| 1545 |
% Example. Definition of the $F(t)=\mathrm e^t/\cos t$ function: |
| 1546 |
% |
| 1547 |
% |\QUOTIENTfunction{\EXPfunction}{\COSfunction}{\F}| |
| 1548 |
% |
| 1549 |
% \item[\cs{COMPOSITIONfunction}\Marg{\TBS function1}\Marg{\TBS function2}% |
| 1550 |
% \Marg{\TBS Function}]\SpecialUsageIndex{\COMPOSITIONfunction} |
| 1551 |
% defines \textit{\TBS Function} as the composition of functions |
| 1552 |
% \textit{\TBS function1} and \textit{\TBS function2}. |
| 1553 |
% |
| 1554 |
% Example. Definition of the $F(t)=\mathrm e^{\cos t}$ function: |
| 1555 |
% |
| 1556 |
% |\COMPOSITIONfunction{\EXPfunction}{\COSfunction}{\F}| |
| 1557 |
% |
| 1558 |
% (note than |\COMPOSITIONfunction{f}{g}{\F}| means |\F|$=f\circ g$). |
| 1559 |
% |
| 1560 |
% \item[\cs{SCALEfunction}\Marg{num}\Marg{\TBS function}\Marg{\TBS Function}]% |
| 1561 |
% \SpecialUsageIndex{\SCALEfunction} |
| 1562 |
% defines \textit{\TBS Function} as the product of number \textit{num} |
| 1563 |
% and function \textit{\TBS function}. |
| 1564 |
% |
| 1565 |
% Example. Definition of the $F(t)=3{\cos t}$ function: |
| 1566 |
% |
| 1567 |
% |\SCALEfunction{3}{\COSfunction}{\F}| |
| 1568 |
% |
| 1569 |
% \item[\cs{SCALEVARIABLEfunction}\Marg{num}\Marg{\TBS function}% |
| 1570 |
% \Marg{\TBS Function}]\SpecialUsageIndex{\SCALEVARIABLEfunction} |
| 1571 |
% scales the variable by factor \textit{num} and then applies the function |
| 1572 |
% \textit{\TBS function}. |
| 1573 |
% |
| 1574 |
% Example. Definition of the $F(t)=\cos 3t$ function: |
| 1575 |
% |
| 1576 |
% |\SCALEVARIABLEfunction{3}{\COSfunction}{\F}| |
| 1577 |
% |
| 1578 |
% \item[\cs{POWERfunction}\Marg{\TBS function}\Marg{num}\Marg{\TBS Function}]% |
| 1579 |
% \SpecialUsageIndex{\POWERfunction} |
| 1580 |
% defines \textit{\TBS Function} as the power of function |
| 1581 |
% \textit{\TBS function} to the exponent \textit{num} (a positive integer). |
| 1582 |
% Example. Definition of the $F(t)=t^5$ function: |
| 1583 |
% |
| 1584 |
% |\POWERfunction{\IDENTITYfunction}{5}{\F}| |
| 1585 |
% |
| 1586 |
% \item[\cs{LINEARCOMBINATIONfunction}\Marg{num1}\Marg{\TBS function1}% |
| 1587 |
% \Marg{num2}\Marg{\TBS function2}\Marg{\TBS Function}] |
| 1588 |
% \SpecialUsageIndex{\LINEARCOMBINATIONfunction} |
| 1589 |
% defines \textit{\TBS Function} as the linear combination of functions |
| 1590 |
% \textit{\TBS function1} and \textit{\TBS function2} |
| 1591 |
% multiplied, respectively, by numbers \textit{num1} and \textit{num2}. |
| 1592 |
% |
| 1593 |
% Example. Definition of the $F(t)=2t-3\cos t$ function: |
| 1594 |
% |
| 1595 |
% |\LINEARCOMBINATIONfunction{2}{\IDENTITYfunction}{-3}{\COSfunction}{\F}| |
| 1596 |
% \end{description} |
| 1597 |
% |
| 1598 |
% By combining properly this operations and the predefined functions, |
| 1599 |
% many elementary functions can be defined. |
| 1600 |
% |
| 1601 |
% \begin{exemple} |
| 1602 |
% % exp(-t) |
| 1603 |
% \SCALEVARIABLEfunction |
| 1604 |
% {-1}{\EXPfunction} |
| 1605 |
% {\NEGEXPfunction} |
| 1606 |
% |
| 1607 |
% % exp(-t)cos(t) |
| 1608 |
% \PRODUCTfunction |
| 1609 |
% {\NEGEXPfunction} |
| 1610 |
% {\COSfunction} |
| 1611 |
% {\NEGEXPCOSfunction} |
| 1612 |
% |
| 1613 |
% % 3t^2-2exp(-t)cos(t) |
| 1614 |
% \LINEARCOMBINATIONfunction |
| 1615 |
% {3}{\SQUAREfunction} |
| 1616 |
% {-2}{\NEGEXPCOSfunction} |
| 1617 |
% {\myfunction} |
| 1618 |
% |
| 1619 |
% \myfunction{5}{\sol}{\Dsol} |
| 1620 |
% |
| 1621 |
% If |
| 1622 |
% \[ |
| 1623 |
% f(t)=3t^2-2\mathrm{e}^{-t}\cos t |
| 1624 |
% \] |
| 1625 |
% then |
| 1626 |
% \[ |
| 1627 |
% \begin{gathered} |
| 1628 |
% f(5)=\sol\\ |
| 1629 |
% f'(5)=\Dsol |
| 1630 |
% \end{gathered} |
| 1631 |
% \] |
| 1632 |
% \end{exemple} |
| 1633 |
% |
| 1634 |
% \section{Polynomial functions} |
| 1635 |
% Although polynomial functions can be defined using linear combinations |
| 1636 |
% of power functions, |
| 1637 |
% to facilitate our work, the \textsf{calculus} package includes the |
| 1638 |
% following commands to define more easily the polynomials of |
| 1639 |
% 1, 2, and 3 degrees: |
| 1640 |
% |\newlpoly| (new \emph{linear} polynomial), |\newqpoly| |
| 1641 |
% (new \emph{quadratic} polynomial), |
| 1642 |
% and |\newcpoly| (new \emph{cubic} polynomial): |
| 1643 |
% \begin{description} |
| 1644 |
% \item[\cs{newlpoly}\Marg{\TBS Function}\Marg{a}\Marg{b}]% |
| 1645 |
% \SpecialUsageIndex{\newlpoly} |
| 1646 |
% stores the |
| 1647 |
% $p(t)=\texttt{\textit{a}}+\texttt{\textit{b}}t$ |
| 1648 |
% function in the \cs{\textit{Function}} command. |
| 1649 |
% \item[\cs{newqpoly}\Marg{\TBS Function}% |
| 1650 |
% \Marg{a}\Marg{b}\Marg{c}]\SpecialUsageIndex{\newqpoly} |
| 1651 |
% stores the |
| 1652 |
% $p(t)=\texttt{\textit{a}}+\texttt{\textit{b}}t+\texttt{\textit{c}}t^2$ |
| 1653 |
% function in the \cs{\textit{Function}} command. |
| 1654 |
% \item[\cs{newcpoly}\Marg{\TBS Function}\Marg{a}\Marg{b}\Marg{c}\Marg{d}]% |
| 1655 |
% \SpecialUsageIndex{\newcpoly} |
| 1656 |
% stores the |
| 1657 |
% $p(t)=\texttt{\textit{a}}+\texttt{\textit{b}}t+ |
| 1658 |
% \texttt{\textit{c}}t^2+\texttt{\textit{d}}t^3$ |
| 1659 |
% function in the \cs{\textit{Function}} command. |
| 1660 |
% \end{description} |
| 1661 |
% \begin{exemple} |
| 1662 |
% % \mypoly=1-x^2+x^3 |
| 1663 |
% \newcpoly{\mypoly}{1}{0}{-1}{1} |
| 1664 |
% \mypoly{2}{\sol}{\Dsol} |
| 1665 |
% $p'(2)=\Dsol$ |
| 1666 |
% \end{exemple} |
| 1667 |
% These declarations behave similarly to to the declaration |
| 1668 |
% |\newcommand|: |
| 1669 |
% If the name you want to assign to the new function is that of |
| 1670 |
% an already defined command, the \textsf{calculus} package returns |
| 1671 |
% an error message and do not redefines this command. |
| 1672 |
% To obtain any alternative behavior, our package includes |
| 1673 |
% three other sets of declarations: |
| 1674 |
% |
| 1675 |
% \begin{description} |
| 1676 |
% \item[\cs{renewlpoly}, \cs{renewqpoly}, \cs{renewcpoly}]% |
| 1677 |
% \SpecialUsageIndex{\renewlpoly}% |
| 1678 |
% \SpecialUsageIndex{\renewqpoly}% |
| 1679 |
% \SpecialUsageIndex{\renewcpoly} |
| 1680 |
% redefine the already existing command \cs{\textit{Function}}. |
| 1681 |
% If this command does not exist, then |
| 1682 |
% it is not defined and an error message occurs. |
| 1683 |
% \item[\cs{ensurelpoly}, \cs{ensureqpoly}, \cs{ensurecpoly}]% |
| 1684 |
% \SpecialUsageIndex{\ensurelpoly}% |
| 1685 |
% \SpecialUsageIndex{\ensureqpoly}% |
| 1686 |
% \SpecialUsageIndex{\ensurecpoly} |
| 1687 |
% define a new function. |
| 1688 |
% If the command \cs{\textit{Function}} already exists, |
| 1689 |
% it is not redefined. |
| 1690 |
% \item[\cs{forcelpoly}, \cs{forceqpoly}, \cs{forcecpoly}]% |
| 1691 |
% \SpecialUsageIndex{\forcelpoly}% |
| 1692 |
% \SpecialUsageIndex{\forceqpoly}% |
| 1693 |
% \SpecialUsageIndex{\forcecpoly} |
| 1694 |
% define a new function. |
| 1695 |
% If the command \cs{\textit{Function}} already exists, |
| 1696 |
% it is redefined. |
| 1697 |
% \end{description} |
| 1698 |
% \section{Vector-valued functions (or parametrically defined curves)} |
| 1699 |
% The instruction |
| 1700 |
% \begin{quote}\SpecialUsageIndex{\PARAMETRICfunction} |
| 1701 |
% |\PARAMETRICfunction|\Marg{\TBS Xfunction}\Marg{\TBS Yfunction}% |
| 1702 |
% \Marg{\TBS myvectorfunction} |
| 1703 |
% \end{quote} |
| 1704 |
% defines the new vector-valued function $f(t)=(x(t),y(t))$. |
| 1705 |
% |
| 1706 |
% The first and second arguments are a pair of functions already defined and, |
| 1707 |
% the third, the name of the new function we define. |
| 1708 |
% Once we have defined them, the new vector functions requires five arguments: |
| 1709 |
% \begin{quote} |
| 1710 |
% \textttit{\TBS myvectorfunction}\Marg{num}\Marg{\TBS cmd1}% |
| 1711 |
% \Marg{\TBS cmd2}\Marg{\TBS cmd3}\Marg{\TBS cmd4} |
| 1712 |
% \end{quote} |
| 1713 |
% where |
| 1714 |
% \begin{itemize} |
| 1715 |
% \item \textit{num} is a number $t$, |
| 1716 |
% \item \textit{\TBS cmd1} and \textit{\TBS cmd2} are two command names |
| 1717 |
% where the values of the $x(t)$ function and its derivative $x'(t)$ |
| 1718 |
% will be stored, and |
| 1719 |
% \item \textit{\TBS cmd3} and \textit{\TBS cmd4} will store |
| 1720 |
% $y(t)$ and $y'(t)$. |
| 1721 |
% \end{itemize} |
| 1722 |
% In short, in this context, a vector function is a pair of scalar functions. |
| 1723 |
% |
| 1724 |
% Instead of |\PARAMETRICfunction| we can use the alias |\VECTORfunction|.% |
| 1725 |
% \SpecialUsageIndex{\VECTORfunction} |
| 1726 |
% |
| 1727 |
% \begin{exemple} |
| 1728 |
% For the $f(t)=(t^2,t^3)$ function we have |
| 1729 |
% \VECTORfunction |
| 1730 |
% {\SQUAREfunction}{\CUBEfunction}{\F} |
| 1731 |
% |
| 1732 |
% \F{4}{\solx}{\Dsolx}{\soly}{\Dsoly} |
| 1733 |
% |
| 1734 |
% \[ |
| 1735 |
% f(4)=(\solx,\soly), f'(4)=(\Dsolx,\Dsoly) |
| 1736 |
% \] |
| 1737 |
% \end{exemple} |
| 1738 |
% |
| 1739 |
% \section{Vector-valued functions in polar coordinates} |
| 1740 |
% The following instruction: |
| 1741 |
% \begin{quote}\SpecialUsageIndex{\POLARfunction} |
| 1742 |
% |\POLARfunction|\Marg{\TBS rfunction}\Marg{\TBS Polarfunction} |
| 1743 |
% \end{quote} |
| 1744 |
% declares the vector function $f(\phi)=(r(\phi)\cos \phi,r(\phi)\sin \phi)$. |
| 1745 |
% The first argument is the |
| 1746 |
% $r=r(\phi)$ function, (an already defined function). |
| 1747 |
% For example, we can define the \emph{Archimedean spiral} $r(\phi)=0{,}5\phi$, |
| 1748 |
% as follows: |
| 1749 |
% \begin{Verbatim}[gobble=2] |
| 1750 |
% \SCALEfunction{0.5}{\IDENTITYfunction}{\rfunction} |
| 1751 |
% \POLARfunction{\rfunction}{\archimedes} |
| 1752 |
% \end{Verbatim} |
| 1753 |
% \section{Low-level instructions} |
| 1754 |
% Probably, many users of the package will not be interested |
| 1755 |
% in the implementation of the commands this package includes. |
| 1756 |
% If this is your case, you can ignore this section. |
| 1757 |
% \subsection{The \cs{newfunction} declaration and its variants} |
| 1758 |
% All the functions predefined by this package use the |\newfunction| |
| 1759 |
% declaration. |
| 1760 |
% This control sequence works as follows: |
| 1761 |
% \begin{description} |
| 1762 |
% \item[\cs{newfunction}\Marg{\TBS Function}\Marg{Instructions to compute |
| 1763 |
% \cs{y} and \cs{Dy} from \cs{t}}] |
| 1764 |
% \end{description} |
| 1765 |
% where the second argument is the list of the instructions you need to run |
| 1766 |
% to calculate the value of the function |\y| |
| 1767 |
% and the derivative |\Dy| in the |\t| point. |
| 1768 |
% |
| 1769 |
% For example, if you want to define the $f(t)=t^2+\mathrm e^t\cos t$ function, |
| 1770 |
% whose derivative is |
| 1771 |
% $f'(t)=2t+\mathrm e^t(\cos t-\sin t)$, |
| 1772 |
% using the high-level instructions we defined earlier, |
| 1773 |
% you can write the following instructions: |
| 1774 |
% \begin{Verbatim}[gobble=2] |
| 1775 |
% \PRODUCTfunction{\EXPfunction}{\COSfunction}{\ffunction} |
| 1776 |
% \SUMfunction{\SQUAREfunction}{\ffunction}{\Ffunction} |
| 1777 |
% \end{Verbatim} |
| 1778 |
% |
| 1779 |
% But you can also define this function using the \cs{newfunction} |
| 1780 |
% command as follows: |
| 1781 |
% \begin{Verbatim}[gobble=2] |
| 1782 |
% \newfunction{\Ffunction}{% |
| 1783 |
% \SQUARE{\t}{\tempA} % A=t^2 |
| 1784 |
% \EXP{\t}{\tempB} % B=e^t |
| 1785 |
% \COS{\t}{\tempC} % C=cos(t) |
| 1786 |
% \SIN{\t}{\tempD} % D=sin(t) |
| 1787 |
% \MULTIPLY{2}{\t}{\tempE} % E=2t |
| 1788 |
% \MULTIPLY{\tempB}{\tempC}{\tempC} % C=e^t cos(t) |
| 1789 |
% \MULTIPLY{\tempB}{\tempD}{\tempD} % D=e^t sin(t) |
| 1790 |
% \ADD{\tempA}{\tempC}{\y} % y=t^2 + e^t cos(t) |
| 1791 |
% \ADD{\tempE}{\tempC}{\tempC} % C=t^2 + e^t cos(t) |
| 1792 |
% \SUBTRACT{\tempC}{\tempD}{\Dy} % y'=t^2 + e^t cos(t) - e^t sin(t) |
| 1793 |
% } |
| 1794 |
% \end{Verbatim} |
| 1795 |
% |
| 1796 |
% It must be said, however, that the |\newfunction| declaration |
| 1797 |
% behaves similarly to |\newcommand| or |\newlpoly|: |
| 1798 |
% If the name you want to assign to the new function is that of an already |
| 1799 |
% defined command, % the \textsf{calculus} package returns an error message |
| 1800 |
% and does not redefines this command. |
| 1801 |
% To obtain any alternative behavior, our package includes three other |
| 1802 |
% versions of the |\newfunction| declarations: the |
| 1803 |
% |\renewfunction|, |\ensurefunction| and |\forcefunction| declarations. |
| 1804 |
% Each of these declarations behaves differently: |
| 1805 |
% \begin{description} |
| 1806 |
% \item[\cs{newfunction}]\SpecialUsageIndex{\newfunction} |
| 1807 |
% defines a new function. If the command \cs{\textit{Function}} already exists, |
| 1808 |
% it is not redefined and an error message occurs. |
| 1809 |
% \item[\cs{renewfunction}]\SpecialUsageIndex{\renewfunction} |
| 1810 |
% redefines the already existing command |
| 1811 |
% \cs{\textit{Function}}. |
| 1812 |
% If this command does not exists, then it is not defined |
| 1813 |
% and an error message occurs. |
| 1814 |
% \item[\cs{ensurefunction}]\SpecialUsageIndex{\ensurefunction} |
| 1815 |
% defines a new function. |
| 1816 |
% If the command \cs{\textit{Function}} already exists, |
| 1817 |
% it is not redefined. |
| 1818 |
% \item[\cs{forcefunction}]\SpecialUsageIndex{\forcefunction} |
| 1819 |
% defines a new function. |
| 1820 |
% If the command \cs{\textit{Function}} already exists, |
| 1821 |
% it is redefined. |
| 1822 |
% \end{description} |
| 1823 |
% \subsection{Vector functions and polar coordinates} |
| 1824 |
% You can (re)define a vector function $f(t)=(x(t),y(t))$ using the |
| 1825 |
% |\newvectorfunction|% |
| 1826 |
% \SpecialUsageIndex{\newvectorfunction}% |
| 1827 |
% \SpecialUsageIndex{\renewvectorfunction}% |
| 1828 |
% \SpecialUsageIndex{\ensurevectorfunction}% |
| 1829 |
% \SpecialUsageIndex{\forcevectorfunction} |
| 1830 |
% declaration or any |
| 1831 |
% of its variants |\renewvectorfunction|, |\ensurevectorfunction| |
| 1832 |
% and |\forcevectorfunction|: |
| 1833 |
% \begin{description} |
| 1834 |
% \item[\cs{newvectorfunction}\Marg{\TBS Function}\Marg{Instructions to compute |
| 1835 |
% \cs{x}, \cs{Dx}, \cs{y} and \cs{Dy} from \cs{t}}] |
| 1836 |
% \end{description} |
| 1837 |
% |
| 1838 |
% For example, you can define the function $f(t)=(t^2,t^3)$ |
| 1839 |
% in the following way: |
| 1840 |
% \begin{Verbatim}[gobble=2] |
| 1841 |
% \newvectorfunction{\F}{% |
| 1842 |
% \SQUARE{\t}{\x} % x=t^2 |
| 1843 |
% \MULTIPLY{2}{\t}{\Dx} % x'=2t |
| 1844 |
% \CUBE{\t}{\y} % y=t^3 |
| 1845 |
% \MULTIPLY{3}{\x}{\Dy} % y'=3t^2 |
| 1846 |
% } |
| 1847 |
% \end{Verbatim} |
| 1848 |
|
| 1849 |
% \SpecialUsageIndex{\newpolarfunction}% |
| 1850 |
% \SpecialUsageIndex{\renewpolarfunction}% |
| 1851 |
% \SpecialUsageIndex{\ensurepolarfunction}% |
| 1852 |
% \SpecialUsageIndex{\forcepolarfunction}% |
| 1853 |
% Finally, to define the $r=r(\phi)$ function, in polar coordinates, |
| 1854 |
% we have the declarations |
| 1855 |
% |\newpolarfunction|, |
| 1856 |
% |\renewpolarfunction|, |\ensurepolarfunction| and |\forcepolarfunction|. |
| 1857 |
% \begin{description} |
| 1858 |
% \item[\cs{newpolarfunction}\Marg{\TBS Function}\Marg{Instructions to compute |
| 1859 |
% \cs{r} and \cs{Dr} from \cs{t}}] |
| 1860 |
% \end{description} |
| 1861 |
% |
| 1862 |
% For example, you can define the \emph{cardioide} curve $r(\phi)=1+\cos \phi$, |
| 1863 |
% using high level instructions, |
| 1864 |
% \begin{Verbatim}[gobble=2] |
| 1865 |
% \SUMfunction{\ONEfunction}{\COSfunction}{\ffunction} % y=1 + cos t |
| 1866 |
% \POLARfunction{\ffunction}{\cardioide} |
| 1867 |
% \end{Verbatim} |
| 1868 |
% or, with the |\newpolarfunction| declaration, |
| 1869 |
% \begin{Verbatim}[gobble=2] |
| 1870 |
% \newpolarfunction{\cardioide}{% |
| 1871 |
% \COS{\t}{\r} |
| 1872 |
% \ADD{1}{\r}{\r} % r=1+cos t |
| 1873 |
% \SIN{\t}{\Dr} |
| 1874 |
% \MULTIPLY{-1}{\Dr}{\Dr} % r'=-sin t |
| 1875 |
% } |
| 1876 |
% \end{Verbatim} |
| 1877 |
% |
| 1878 |
% \StopEventually{} |
| 1879 |
% |
| 1880 |
% \part{Implementation} |
| 1881 |
% \section{\textsf{calculator}} |
| 1882 |
% \begin{macrocode} |
| 1883 |
%<*calculator> |
| 1884 |
\NeedsTeXFormat{LaTeX2e} |
| 1885 |
\ProvidesPackage{calculator}[2022/09/15 v.2.1] |
| 1886 |
% \end{macrocode} |
| 1887 |
% \subsection{Internal lengths and special numbers} |
| 1888 |
% \cs{cctr@lengtha} and \cs{cctr@lengthb} |
| 1889 |
% will be used in internal calculations and comparisons. |
| 1890 |
% \begin{macrocode} |
| 1891 |
\newdimen\cctr@lengtha |
| 1892 |
\newdimen\cctr@lengthb |
| 1893 |
% \end{macrocode} |
| 1894 |
% \begin{macro}{\cctr@epsilon} |
| 1895 |
% \cs{cctr@epsilon} will store the closest to zero length |
| 1896 |
% in the \TeX{} arithmetic: one scaled point |
| 1897 |
% ($1\,\mathsf{sp}=1/65536\,\mathsf{pt}$). |
| 1898 |
% This means the smallest positive number will be |
| 1899 |
% $0.00002\approx1/65536=1/2^{16}$. |
| 1900 |
% \begin{macrocode} |
| 1901 |
\newdimen\cctr@epsilon |
| 1902 |
\cctr@epsilon=1sp |
| 1903 |
% \end{macrocode} |
| 1904 |
% \end{macro} |
| 1905 |
% \begin{macro}{\cctr@logmaxnum} |
| 1906 |
% The largest \TeX{} number is $16383.99998\approx2^{14}$; |
| 1907 |
% \cs{cctr@logmaxnum} is the logarithm of this number, |
| 1908 |
% $9.704\approx\log16384$. |
| 1909 |
% \begin{macrocode} |
| 1910 |
\def\cctr@logmaxnum{9.704} |
| 1911 |
% \end{macrocode} |
| 1912 |
% \end{macro} |
| 1913 |
% \subsection{Warning messages} |
| 1914 |
% \begin{macrocode} |
| 1915 |
\def\cctr@Warntruncate#1#2{% |
| 1916 |
\PackageWarning{calculator}% |
| 1917 |
{The optional argument in truncate \MessageBreak |
| 1918 |
must be less than 5 \MessageBreak |
| 1919 |
I copy #1 to #2 \MessageBreak without truncating}} |
| 1920 |
|
| 1921 |
\def\cctr@Warnround#1#2{% |
| 1922 |
\PackageWarning{calculator}% |
| 1923 |
{The optional argument in round \MessageBreak |
| 1924 |
must be less than 5 \MessageBreak |
| 1925 |
I copy #1 to #2 \MessageBreak without rounding}} |
| 1926 |
|
| 1927 |
\def\cctr@Warndivzero#1#2{% |
| 1928 |
\PackageWarning{calculator}% |
| 1929 |
{Division by 0.\MessageBreak |
| 1930 |
I can't define #1/#2}} |
| 1931 |
|
| 1932 |
\def\cctr@Warnnogcd{% |
| 1933 |
\PackageWarning{calculator}% |
| 1934 |
{gcd(0,0) is not well defined}} |
| 1935 |
|
| 1936 |
\def\cctr@Warnnoposrad#1{% |
| 1937 |
\PackageWarning{calculator}% |
| 1938 |
{The argument in square root\MessageBreak |
| 1939 |
must be non negative\MessageBreak |
| 1940 |
I can't define sqrt(#1)}} |
| 1941 |
|
| 1942 |
\def\cctr@Warnnointexp#1#2{% |
| 1943 |
\PackageWarning{calculator}% |
| 1944 |
{The exponent in power function\MessageBreak |
| 1945 |
must be an integer\MessageBreak |
| 1946 |
I can't define #1^#2}} |
| 1947 |
|
| 1948 |
\def\cctr@Warnbigarcsin#1{% |
| 1949 |
\PackageWarning{calculator}% |
| 1950 |
{The argument in arcsin\MessageBreak |
| 1951 |
must be a number between -1 and 1\MessageBreak |
| 1952 |
I can't define arcsin(#1)}} |
| 1953 |
|
| 1954 |
\def\cctr@Warnbigarccos#1{% |
| 1955 |
\PackageWarning{calculator}% |
| 1956 |
{The argument in arccos\MessageBreak |
| 1957 |
must be a number between -1 and 1\MessageBreak |
| 1958 |
I can't define arccos(#1)}} |
| 1959 |
|
| 1960 |
\def\cctr@Warnsmallarcosh#1{% |
| 1961 |
\PackageWarning{calculator}% |
| 1962 |
{The argument in arcosh\MessageBreak |
| 1963 |
must be a number greater or equal than 1\MessageBreak |
| 1964 |
I can't define arcosh(#1)}} |
| 1965 |
|
| 1966 |
\def\cctr@Warnbigartanh#1{% |
| 1967 |
\PackageWarning{calculator}% |
| 1968 |
{The argument in artanh\MessageBreak |
| 1969 |
must be a number between -1 and 1\MessageBreak |
| 1970 |
I can't define artanh(#1)}} |
| 1971 |
|
| 1972 |
\def\cctr@Warnsmallarcoth#1{% |
| 1973 |
\PackageWarning{calculator}% |
| 1974 |
{The argument in arcoth\MessageBreak |
| 1975 |
must be a number greater than 1\MessageBreak |
| 1976 |
or smaller than -1\MessageBreak |
| 1977 |
I can't define arcoth(#1)}} |
| 1978 |
|
| 1979 |
\def\cctr@Warnsingmatrix#1#2#3#4{% |
| 1980 |
\PackageWarning{calculator}% |
| 1981 |
{Matrix (#1 #2 ; #3 #4) is singular\MessageBreak |
| 1982 |
Its inverse is not defined}} |
| 1983 |
|
| 1984 |
\def\cctr@WarnsingTDmatrix#1#2#3#4#5#6#7#8#9{% |
| 1985 |
\PackageWarning{calculator}% |
| 1986 |
{Matrix (#1 #2 #3; #4 #5 #6; #7 #8 #9) is singular\MessageBreak |
| 1987 |
Its inverse is not defined}} |
| 1988 |
|
| 1989 |
\def\cctr@WarnIncLinSys{\PackageWarning{calculator}{% |
| 1990 |
Incompatible linear system}} |
| 1991 |
|
| 1992 |
\def\cctr@WarnIncTDLinSys{\PackageWarning{calculator}{% |
| 1993 |
Incompatible or indeterminate linear system\MessageBreak |
| 1994 |
For 3x3 systems I can solve only determinate systems}} |
| 1995 |
|
| 1996 |
\def\cctr@WarnIndLinSys{\PackageWarning{calculator}{% |
| 1997 |
Indeterminate linear system.\MessageBreak |
| 1998 |
I will choose one of the infinite solutions}} |
| 1999 |
|
| 2000 |
\def\cctr@WarnZeroLinSys{\PackageWarning{calculator}{% |
| 2001 |
0x=0 linear system. Every vector is a solution!\MessageBreak |
| 2002 |
I will choose the (0,0) solution}} |
| 2003 |
|
| 2004 |
\def\cctr@Warninftan#1{% |
| 2005 |
\PackageWarning{calculator}{% |
| 2006 |
Undefined tangent.\MessageBreak |
| 2007 |
The cosine of #1 is zero and, then,\MessageBreak |
| 2008 |
the tangent of #1 is not defined}} |
| 2009 |
|
| 2010 |
\def\cctr@Warninfcotan#1{% |
| 2011 |
\PackageWarning{calculator}{% |
| 2012 |
Undefined cotangent.\MessageBreak |
| 2013 |
The sine of #1 is zero and, then,\MessageBreak |
| 2014 |
the cotangent of #1 is not defined}} |
| 2015 |
|
| 2016 |
\def\cctr@Warninfexp#1{% |
| 2017 |
\PackageWarning{calculator}{% |
| 2018 |
The absolute value of the variable\MessageBreak |
| 2019 |
in the exponential function must be less than |
| 2020 |
\cctr@logmaxnum\MessageBreak |
| 2021 |
(the logarithm of the max number I know)\MessageBreak |
| 2022 |
I can't define exp(#1)}} |
| 2023 |
|
| 2024 |
\def\cctr@Warninfexpb#1#2{% |
| 2025 |
\PackageWarning{calculator}{% |
| 2026 |
The base\MessageBreak |
| 2027 |
in the exponential function must be positive. |
| 2028 |
\MessageBreak |
| 2029 |
I can't define #1^(#2)}} |
| 2030 |
|
| 2031 |
\def\cctr@Warninflog#1{% |
| 2032 |
\PackageWarning{calculator}{% |
| 2033 |
The value of the variable\MessageBreak |
| 2034 |
in the logarithm function must be positive\MessageBreak |
| 2035 |
I can't define log(#1)}} |
| 2036 |
|
| 2037 |
\def\cctr@Warncrossprod(#1)(#2){% |
| 2038 |
\PackageWarning{calculator}% |
| 2039 |
{Vector product only defined\MessageBreak |
| 2040 |
for 3 dimmensional vectors.\MessageBreak |
| 2041 |
I can't define (#1)x(#2)}} |
| 2042 |
|
| 2043 |
\def\cctr@Warnnoangle(#1)(#2){% |
| 2044 |
\PackageWarning{calculator}% |
| 2045 |
{Angle between two vectors only defined\MessageBreak |
| 2046 |
for nonzero vectors.\MessageBreak |
| 2047 |
I can't define an angle between (#1) and (#2)}} |
| 2048 |
% \end{macrocode} |
| 2049 |
% \subsection{Operations with numbers} |
| 2050 |
% \subsubsection*{Assignements and comparisons} |
| 2051 |
% \begin{macro}{\COPY} |
| 2052 |
% \cs{COPY}\marg{\#1}\marg{\#2} |
| 2053 |
% defines the \textit{\#2} command as the number \textit{\#1}. |
| 2054 |
% \begin{macrocode} |
| 2055 |
\def\COPY#1#2{\edef#2{#1}\ignorespaces} |
| 2056 |
% \end{macrocode} |
| 2057 |
% \end{macro} |
| 2058 |
% \begin{macro}{\GLOBALCOPY} |
| 2059 |
% Global version of \cs{COPY}. |
| 2060 |
% The new defined command \textit{\#2} is not changed outside groups. |
| 2061 |
% \begin{macrocode} |
| 2062 |
\def\GLOBALCOPY#1#2{\xdef#2{#1}\ignorespaces} |
| 2063 |
% \end{macrocode} |
| 2064 |
% \end{macro} |
| 2065 |
% \begin{macro}{\@OUTPUTSOL} |
| 2066 |
% \cs{@OUTPUTSOL}\marg{\#1}: an internal macro to save solutions |
| 2067 |
% when a group is closed. |
| 2068 |
% |
| 2069 |
% The global c.s. \cs{cctr@outa} preserves solutions. |
| 2070 |
% Whenever we use any temporary parameters in the definition |
| 2071 |
% of an instruction, |
| 2072 |
% we use a group to ensure the local character of those parameters. |
| 2073 |
% The instruction \cs{@OUTPUTSOL} is a bypass to export the solution. |
| 2074 |
% \begin{macrocode} |
| 2075 |
\def\@OUTPUTSOL#1{\GLOBALCOPY{#1}{\cctr@outa}\endgroup\COPY{\cctr@outa}{#1}} |
| 2076 |
% \end{macrocode} |
| 2077 |
% \end{macro} |
| 2078 |
% \begin{macro}{\@OUTPUTSOLS} |
| 2079 |
% Analogous to \cs{@OUTPUTSOL}, preserving a pair of solutions. |
| 2080 |
% \begin{macrocode} |
| 2081 |
\def\@OUTPUTSOLS#1#2{\GLOBALCOPY{#1}{\cctr@outa} |
| 2082 |
\GLOBALCOPY{#2}{\cctr@outb}\endgroup |
| 2083 |
\COPY{\cctr@outa}{#1}\COPY{\cctr@outb}{#2}} |
| 2084 |
% \end{macrocode} |
| 2085 |
% \end{macro} |
| 2086 |
% \begin{macro}{\MAX} |
| 2087 |
% \cs{MAX}\marg{\#1}\marg{\#2}\marg{\#3} |
| 2088 |
% defines the \textit{\#3} command as the maximum of numbers |
| 2089 |
% \textit{\#1} and \textit{\#2}. |
| 2090 |
% \begin{macrocode} |
| 2091 |
\def\MAX#1#2#3{% |
| 2092 |
\ifdim #1\p@ < #2\p@ |
| 2093 |
\COPY{#2}{#3}\else\COPY{#1}{#3}\fi\ignorespaces} |
| 2094 |
% \end{macrocode} |
| 2095 |
% \end{macro} |
| 2096 |
% \begin{macro}{\MIN} |
| 2097 |
% \cs{MIN}\marg{\#1}\marg{\#2}\marg{\#3} |
| 2098 |
% defines the \textit{\#3} command as the minimum of numbers |
| 2099 |
% \textit{\#1} and \textit{\#2}. |
| 2100 |
% \begin{macrocode} |
| 2101 |
\def\MIN#1#2#3{% |
| 2102 |
\ifdim #1\p@ > #2\p@ |
| 2103 |
\COPY{#2}{#3}\else\COPY{#1}{#3}\fi\ignorespaces} |
| 2104 |
% \end{macrocode} |
| 2105 |
% \end{macro} |
| 2106 |
% \subsubsection*{Real arithmetic} |
| 2107 |
% \begin{macro}{\ABSVALUE} |
| 2108 |
% \cs{ABSVALUE}\marg{\#1}\marg{\#2} |
| 2109 |
% defines the \textit{\#2} command as the |
| 2110 |
% absolute value of number \textit{\#1}. |
| 2111 |
% \begin{macrocode} |
| 2112 |
\def\ABSVALUE#1#2{% |
| 2113 |
\ifdim #1\p@<\z@ |
| 2114 |
\MULTIPLY{-1}{#1}{#2}\else\COPY{#1}{#2}\fi} |
| 2115 |
% \end{macrocode} |
| 2116 |
% \end{macro} |
| 2117 |
% \paragraph*{Product, sum and difference} |
| 2118 |
% \begin{macro}{\MULTIPLY} |
| 2119 |
% \cs{MULTIPLY}\marg{\#1}\marg{\#2}\marg{\#3} |
| 2120 |
% defines the \textit{\#3} command as the |
| 2121 |
% product of numbers \textit{\#1} and \textit{\#2}. |
| 2122 |
% \begin{macrocode} |
| 2123 |
\def\MULTIPLY#1#2#3{\cctr@lengtha=#1\p@ |
| 2124 |
\cctr@lengtha=#2\cctr@lengtha |
| 2125 |
\edef#3{\expandafter\strip@pt\cctr@lengtha}\ignorespaces} |
| 2126 |
% \end{macrocode} |
| 2127 |
% \end{macro} |
| 2128 |
% \begin{macro}{\ADD} |
| 2129 |
% \cs{ADD}\marg{\#1}\marg{\#2}\marg{\#3} |
| 2130 |
% defines the \textit{\#3} command as the |
| 2131 |
% sum of numbers \textit{\#1} and \textit{\#2}. |
| 2132 |
% \begin{macrocode} |
| 2133 |
\def\ADD#1#2#3{\cctr@lengtha=#1\p@ |
| 2134 |
\cctr@lengthb=#2\p@ |
| 2135 |
\advance\cctr@lengtha by \cctr@lengthb |
| 2136 |
\edef#3{\expandafter\strip@pt\cctr@lengtha}\ignorespaces} |
| 2137 |
% \end{macrocode} |
| 2138 |
% \end{macro} |
| 2139 |
% \begin{macro}{\SUBTRACT} |
| 2140 |
% \cs{SUBTRACT}\marg{\#1}\marg{\#2}\marg{\#3} |
| 2141 |
% defines the \textit{\#3} command as the |
| 2142 |
% difference of numbers \textit{\#1} and \textit{\#2}. |
| 2143 |
% \begin{macrocode} |
| 2144 |
\def\SUBTRACT#1#2#3{\ADD{#1}{-#2}{#3}} |
| 2145 |
% \end{macrocode} |
| 2146 |
% \end{macro} |
| 2147 |
% \paragraph*{Divisions} |
| 2148 |
% We define several kinds of \emph{divisions}: the quotient of |
| 2149 |
% two real numbers, the integer quotient, and the quotient of |
| 2150 |
% two lengths. |
| 2151 |
% The basic algorithm is a lightly modified version of the Beccari's division. |
| 2152 |
% \begin{macro}{\DIVIDE} |
| 2153 |
% \cs{DIVIDE}\marg{\#1}\marg{\#2}\marg{\#3} |
| 2154 |
% defines the \textit{\#3} command as the |
| 2155 |
% quotient of numbers \textit{\#1} and \textit{\#2}. |
| 2156 |
% \begin{macrocode} |
| 2157 |
\def\DIVIDE#1#2#3{% |
| 2158 |
\begingroup |
| 2159 |
% \end{macrocode} |
| 2160 |
% Absolute values of dividend and divisor |
| 2161 |
% \begin{macrocode} |
| 2162 |
\ABSVALUE{#1}{\cctr@tempD} |
| 2163 |
\ABSVALUE{#2}{\cctr@tempd} |
| 2164 |
% \end{macrocode} |
| 2165 |
% The sign of quotient |
| 2166 |
% \begin{macrocode} |
| 2167 |
\ifdim#1\p@<\z@\ifdim#2\p@>\z@\COPY{-1}{\cctr@sign} |
| 2168 |
\else\COPY{1}{\cctr@sign}\fi |
| 2169 |
\else\ifdim#2\p@>\z@\COPY{1}{\cctr@sign} |
| 2170 |
\else\COPY{-1}{\cctr@sign}\fi |
| 2171 |
\fi |
| 2172 |
% \end{macrocode} |
| 2173 |
% Integer part of quotient |
| 2174 |
% \begin{macrocode} |
| 2175 |
\@DIVIDE{\cctr@tempD}{\cctr@tempd}{\cctr@tempq}{\cctr@tempr} |
| 2176 |
\COPY{\cctr@tempq.}{\cctr@Q} |
| 2177 |
% \end{macrocode} |
| 2178 |
% Fractional part up to five decimal places. |
| 2179 |
% \cs{cctr@ndec} is the number of decimal places already computed. |
| 2180 |
% \begin{macrocode} |
| 2181 |
\COPY{0}{\cctr@ndec} |
| 2182 |
\@whilenum \cctr@ndec<5 \do{% |
| 2183 |
% \end{macrocode} |
| 2184 |
% Each decimal place is calculated by multiplying by 10 the last remainder |
| 2185 |
% and dividing it by the divisor. |
| 2186 |
% But when the remainder is greater than 1638.3, an overflow occurs, because |
| 2187 |
% 16383.99998 is the greatest number. |
| 2188 |
% So, instead, we multiply the divisor by 0.1. |
| 2189 |
% \begin{macrocode} |
| 2190 |
\ifdim\cctr@tempr\p@<1638\p@ |
| 2191 |
\MULTIPLY{\cctr@tempr}{10}{\cctr@tempD} |
| 2192 |
\else |
| 2193 |
\COPY{\cctr@tempr}{\cctr@tempD} |
| 2194 |
\MULTIPLY{\cctr@tempd}{0.1}{\cctr@tempd} |
| 2195 |
\fi |
| 2196 |
\@DIVIDE{\cctr@tempD}{\cctr@tempd}{\cctr@tempq}{\cctr@tempr} |
| 2197 |
\COPY{\cctr@Q\cctr@tempq}{\cctr@Q} |
| 2198 |
\ADD{1}{\cctr@ndec}{\cctr@ndec}}% |
| 2199 |
% \end{macrocode} |
| 2200 |
% Adjust the sign and return the solution. |
| 2201 |
% \begin{macrocode} |
| 2202 |
\MULTIPLY{\cctr@sign}{\cctr@Q}{#3} |
| 2203 |
\@OUTPUTSOL{#3}} |
| 2204 |
% \end{macrocode} |
| 2205 |
% \end{macro} |
| 2206 |
% \begin{macro}{\@DIVIDE} |
| 2207 |
% The \cs{@DIVIDE}\parg{\#1} \parg{\#2}\parg{\#3}\parg{\#4} |
| 2208 |
% command computes $\textit{\#1}/\textit{\#2}$ and |
| 2209 |
% returns an integer quotient (\textit{\#3}) and a real remainder |
| 2210 |
% (\textit{\#4}). |
| 2211 |
% \begin{macrocode} |
| 2212 |
\def\@DIVIDE#1#2#3#4{% |
| 2213 |
\@INTEGERDIVIDE{#1}{#2}{#3} |
| 2214 |
\MULTIPLY{#2}{#3}{#4} |
| 2215 |
\SUBTRACT{#1}{#4}{#4}} |
| 2216 |
% \end{macrocode} |
| 2217 |
% \end{macro} |
| 2218 |
% \begin{macro}{\@INTEGERDIVIDE} |
| 2219 |
% \cs{@INTEGERDIVIDE} divides two numbers (not necessarily integer) |
| 2220 |
% and returns an integer |
| 2221 |
% (this is the integer quotient only for nonnegative integers). |
| 2222 |
% \begin{macrocode} |
| 2223 |
\def\@INTEGERDIVIDE#1#2#3{% |
| 2224 |
\cctr@lengtha=#1\p@ |
| 2225 |
\cctr@lengthb=#2\p@ |
| 2226 |
\ifdim\cctr@lengthb=\z@ |
| 2227 |
\let#3\undefined |
| 2228 |
\cctr@Warndivzero#1#2% |
| 2229 |
\else |
| 2230 |
\divide\cctr@lengtha\cctr@lengthb |
| 2231 |
\COPY{\number\cctr@lengtha}{#3} |
| 2232 |
\fi\ignorespaces} |
| 2233 |
% \end{macrocode} |
| 2234 |
% \end{macro} |
| 2235 |
% \changes{v2.0}{2014/02/13}{New commands: \cs{LENGTHADD}, |
| 2236 |
% \cs{LENGTHSUBTRACT}} |
| 2237 |
% \begin{macro}{\LENGTHADD} |
| 2238 |
% The sum of two lengths. |
| 2239 |
% \cs{LENGTHADD}\marg{\#1}\marg{\#2}\marg{\#3} |
| 2240 |
% stores in \textit{\#3} the sum of the lenghts |
| 2241 |
% \textit{\#1} and \textit{\#2} (\#3 must be a length). |
| 2242 |
% \begin{macrocode} |
| 2243 |
\def\LENGTHADD#1#2#3{\cctr@lengtha=#1 |
| 2244 |
\cctr@lengthb=#2 |
| 2245 |
\advance\cctr@lengtha by \cctr@lengthb |
| 2246 |
\setlength{#3}{\cctr@lengtha}\ignorespaces} |
| 2247 |
% \end{macrocode} |
| 2248 |
% \end{macro} |
| 2249 |
% \begin{macro}{\LENGTHSUBTRACT} |
| 2250 |
% The difference of two lengths. |
| 2251 |
% \cs{LENGTHSUBTRACT}\marg{\#1}\marg{\#2}\marg{\#3} |
| 2252 |
% stores in \textit{\#3} the difference of the lenghts |
| 2253 |
% \textit{\#1} and \textit{\#2} (\#3 must be a length). |
| 2254 |
% \begin{macrocode} |
| 2255 |
\def\LENGTHSUBTRACT#1#2#3{% |
| 2256 |
\LENGTHADD{#1}{-#2}{#3}} |
| 2257 |
% \end{macrocode} |
| 2258 |
% \end{macro} |
| 2259 |
% \begin{macro}{\LENGTHDIVIDE} |
| 2260 |
% The quotient of two lengths must be a number (not a length). |
| 2261 |
% For example, one inch over one centimeter equals $2.54$. |
| 2262 |
% \cs{LENGTHDIVIDE}\marg{\#1}\marg{\#2}\marg{\#3} |
| 2263 |
% stores in \textit{\#3} the quotient of the lenghts |
| 2264 |
% \textit{\#1} and \textit{\#2}. |
| 2265 |
% \begin{macrocode} |
| 2266 |
\def\LENGTHDIVIDE#1#2#3{% |
| 2267 |
\begingroup |
| 2268 |
\cctr@lengtha=#1 |
| 2269 |
\cctr@lengthb=#2 |
| 2270 |
\edef\cctr@tempa{\expandafter\strip@pt\cctr@lengtha}% |
| 2271 |
\edef\cctr@tempb{\expandafter\strip@pt\cctr@lengthb}% |
| 2272 |
\DIVIDE{\cctr@tempa}{\cctr@tempb}{#3} |
| 2273 |
\@OUTPUTSOL{#3}} |
| 2274 |
% \end{macrocode} |
| 2275 |
% \end{macro} |
| 2276 |
% \paragraph*{Powers} |
| 2277 |
% \begin{macro}{\SQUARE} |
| 2278 |
% \cs{SQUARE}\marg{\#1}\marg{\#2} |
| 2279 |
% stores \textit{\#1} squared in \textit{\#2}. |
| 2280 |
% \begin{macrocode} |
| 2281 |
\def\SQUARE#1#2{\MULTIPLY{#1}{#1}{#2}} |
| 2282 |
% \end{macrocode} |
| 2283 |
% \end{macro} |
| 2284 |
% \begin{macro}{\CUBE} |
| 2285 |
% \cs{CUBE}\marg{\#1}\marg{\#2} |
| 2286 |
% stores \textit{\#1} cubed in \textit{\#2}. |
| 2287 |
% \begin{macrocode} |
| 2288 |
\def\CUBE#1#2{\MULTIPLY{#1}{#1}{#2}\MULTIPLY{#2}{#1}{#2}} |
| 2289 |
% \end{macrocode} |
| 2290 |
% \end{macro} |
| 2291 |
% \begin{macro}{\POWER} |
| 2292 |
% \cs{POWER}\marg{\#1}\marg{\#2}\marg{\#3} |
| 2293 |
% stores in \textit{\#3} the power $\textit{\#1}^{\textit{\#2}}$ |
| 2294 |
% \begin{macrocode} |
| 2295 |
\def\POWER#1#2#3{% |
| 2296 |
\begingroup |
| 2297 |
\INTEGERPART{#2}{\cctr@tempexp} |
| 2298 |
\ifdim \cctr@tempexp\p@<#2\p@ |
| 2299 |
\cctr@Warnnointexp{#1}{#2} |
| 2300 |
\let#3\undefined |
| 2301 |
\else |
| 2302 |
% \end{macrocode} |
| 2303 |
% This ensures that power will be defined only if the exponent is an integer. |
| 2304 |
% \begin{macrocode} |
| 2305 |
\@POWER{#1}{#2}{#3}\fi\@OUTPUTSOL{#3}} |
| 2306 |
% \end{macrocode} |
| 2307 |
% \end{macro} |
| 2308 |
% \begin{macrocode} |
| 2309 |
\def\@POWER#1#2#3{% |
| 2310 |
\begingroup |
| 2311 |
\ifdim #2\p@<\z@ |
| 2312 |
% \end{macrocode} |
| 2313 |
% For negative exponents, $a^n=(1/a)^{-n}$. |
| 2314 |
% \begin{macrocode} |
| 2315 |
\DIVIDE{1}{#1}{\cctr@tempb} |
| 2316 |
\MULTIPLY{-1}{#2}{\cctr@tempc} |
| 2317 |
\@POWER{\cctr@tempb}{\cctr@tempc}{#3} |
| 2318 |
\else |
| 2319 |
\COPY{0}{\cctr@tempa} |
| 2320 |
\COPY{1}{#3} |
| 2321 |
\@whilenum \cctr@tempa<#2 \do {% |
| 2322 |
\MULTIPLY{#1}{#3}{#3} |
| 2323 |
\ADD{1}{\cctr@tempa}{\cctr@tempa}}% |
| 2324 |
\fi\@OUTPUTSOL{#3}} |
| 2325 |
% \end{macrocode} |
| 2326 |
|
| 2327 |
% \subsubsection*{Integer arithmetic and related things} |
| 2328 |
% \begin{macro}{\INTEGERDIVISION} |
| 2329 |
% \cs{INTEGERDIVISION}\marg{\#1}\marg{\#2}\marg{\#3}\marg{\#4} |
| 2330 |
% computes the division $\textit{\#1}/\textit{\#2}$ and returns |
| 2331 |
% an integer quotient and a positive remainder. |
| 2332 |
% \begin{macrocode} |
| 2333 |
\def\INTEGERDIVISION#1#2#3#4{% |
| 2334 |
\begingroup |
| 2335 |
\ABSVALUE{#2}{\cctr@tempd} |
| 2336 |
\@DIVIDE{#1}{#2}{#3}{#4} |
| 2337 |
\ifdim #4\p@<\z@ |
| 2338 |
\ifdim #1\p@<\z@ |
| 2339 |
\ifdim #2\p@<\z@ |
| 2340 |
\ADD{#3}{1}{#3} |
| 2341 |
\else |
| 2342 |
\SUBTRACT{#3}{1}{#3} |
| 2343 |
\fi |
| 2344 |
\ADD{#4}{\cctr@tempd}{#4} |
| 2345 |
\fi\fi\@OUTPUTSOLS{#3}{#4}} |
| 2346 |
% \end{macrocode} |
| 2347 |
% \end{macro} |
| 2348 |
% \begin{macro}{\MODULO} |
| 2349 |
% \cs{MODULO}\marg{\#1}\marg{\#2}\marg{\#3} |
| 2350 |
% returns the remainder of division $\textit{\#1}/\textit{\#2}$. |
| 2351 |
% \begin{macrocode} |
| 2352 |
\def\MODULO#1#2#3{% |
| 2353 |
\begingroup |
| 2354 |
\INTEGERDIVISION{#1}{#2}{\cctr@temp}{#3}\@OUTPUTSOL{#3}} |
| 2355 |
% \end{macrocode} |
| 2356 |
% \end{macro} |
| 2357 |
% \begin{macro}{\INTEGERQUOTIENT} |
| 2358 |
% \cs{INTEGERQUOTIENT}\marg{\#1}\marg{\#2}\marg{\#3} |
| 2359 |
% returns the integer quotient of division |
| 2360 |
% $\textit{\#1}/\textit{\#2}$. |
| 2361 |
% \begin{macrocode} |
| 2362 |
\def\INTEGERQUOTIENT#1#2#3{% |
| 2363 |
\begingroup |
| 2364 |
\INTEGERDIVISION{#1}{#2}{#3}{\cctr@temp}\@OUTPUTSOL{#3}} |
| 2365 |
% \end{macrocode} |
| 2366 |
% \end{macro} |
| 2367 |
% \begin{macro}{\INTEGERPART} |
| 2368 |
% \cs{INTEGERPART}\marg{\#1}\marg{\#2} |
| 2369 |
% returns the integer part of \textit{\#2}. |
| 2370 |
% \begin{macrocode} |
| 2371 |
\def\@@INTEGERPART#1.#2.#3)#4{\ifnum #11=1 \COPY{0}{#4} |
| 2372 |
\else \ADD{0}{#1}{#4}\fi} |
| 2373 |
\def\@INTEGERPART#1#2{\expandafter\@@INTEGERPART#1..){#2}} |
| 2374 |
\def\INTEGERPART#1#2{\begingroup |
| 2375 |
\ifdim #1\p@<\z@ |
| 2376 |
\MULTIPLY{-1}{#1}{\cctr@temp} |
| 2377 |
\INTEGERPART{\cctr@temp}{#2} |
| 2378 |
\ifdim #2\p@<\cctr@temp\p@ |
| 2379 |
\SUBTRACT{-#2}{1}{#2} |
| 2380 |
\else \COPY{-#2}{#2} |
| 2381 |
\fi |
| 2382 |
\else |
| 2383 |
\@INTEGERPART{#1}{#2} |
| 2384 |
\fi\@OUTPUTSOL{#2}} |
| 2385 |
% \end{macrocode} |
| 2386 |
% \end{macro} |
| 2387 |
% \begin{macro}{\FLOOR} |
| 2388 |
% \cs{FLOOR} is an alias for \cs{INTEGERPART}. |
| 2389 |
% \begin{macrocode} |
| 2390 |
\let\FLOOR\INTEGERPART |
| 2391 |
% \end{macrocode} |
| 2392 |
% \end{macro} |
| 2393 |
% \begin{macro}{\FRACTIONALPART} |
| 2394 |
% \cs{FRACTIONALPART}\marg{\#1}\marg{\#2} |
| 2395 |
% returns the fractional part of |
| 2396 |
% \textit{\#2}. |
| 2397 |
% \changes{v2.1}{2022/09/15}{Bug fixed} |
| 2398 |
% \begin{macrocode} |
| 2399 |
\def\@@FRACTIONALPART#1.#2.#3)#4{\ifnum #21=1 \COPY{0}{#4} |
| 2400 |
\else \ADD{0}{0.#2}{#4}\fi} |
| 2401 |
\def\@FRACTIONALPART#1#2{\expandafter\@@FRACTIONALPART#1..){#2}} |
| 2402 |
\def\FRACTIONALPART#1#2{\begingroup |
| 2403 |
\ifdim #1\p@<\z@ |
| 2404 |
\INTEGERPART{#1}{\cctr@tempA} |
| 2405 |
\SUBTRACT{#1}{\cctr@tempA}{#2} |
| 2406 |
\else |
| 2407 |
\@FRACTIONALPART{#1}{#2} |
| 2408 |
\fi\@OUTPUTSOL{#2}} |
| 2409 |
|
| 2410 |
% \end{macrocode} |
| 2411 |
% \end{macro} |
| 2412 |
% \begin{macro}{\TRUNCATE} |
| 2413 |
% \cs{TRUNCATE}\oarg{\#1}\marg{\#2}\marg{\#3} |
| 2414 |
% truncates \textit{\#2} to \textit{\#1} (0, 1, 2 (default), 3 or 4) digits. |
| 2415 |
% \changes{v2.1}{2022/09/15}{Bug fixed} |
| 2416 |
% \begin{macrocode} |
| 2417 |
\def\TRUNCATE{\@ifnextchar[\@@TRUNCATE\@TRUNCATE} |
| 2418 |
\def\@TRUNCATE#1#2{\@@TRUNCATE[2]{#1}{#2}} |
| 2419 |
\def\@@TRUNCATE[#1]#2#3{% |
| 2420 |
\begingroup |
| 2421 |
\ifdim #1\p@ > 4\p@ \cctr@Warntruncate{#2}{\noexpand#3} \COPY{#2}{#3} |
| 2422 |
\else |
| 2423 |
\INTEGERPART{#2}{\cctr@tempa} |
| 2424 |
\ifdim \cctr@tempa\p@ = #2\p@ |
| 2425 |
\expandafter\@@@TRUNCATE\[email protected].)[#1]{#3} |
| 2426 |
\else |
| 2427 |
\expandafter\@@@TRUNCATE#200000.)[#1]{#3} |
| 2428 |
\fi\fi |
| 2429 |
\@OUTPUTSOL{#3}} |
| 2430 |
|
| 2431 |
\def\@@@TRUNCATE#1.#2#3#4#5#6.#7)[#8]#9{% |
| 2432 |
\ifcase #8 |
| 2433 |
\COPY{#1}{#9} |
| 2434 |
\or\COPY{#1.#2}{#9} |
| 2435 |
\or\COPY{#1.#2#3}{#9} |
| 2436 |
\or\COPY{#1.#2#3#4}{#9} |
| 2437 |
\or\COPY{#1.#2#3#4#5}{#9} |
| 2438 |
\fi} |
| 2439 |
% \end{macrocode} |
| 2440 |
% \end{macro} |
| 2441 |
% \begin{macro}{\ROUND} |
| 2442 |
% \cs{ROUND}\oarg{\#1}\marg{\#2}\marg{\#3} |
| 2443 |
% rounds \textit{\#2} to \textit{\#1} (0, 1, 2 (default), 3 or 4) digits. |
| 2444 |
% \changes{v2.1}{2022/09/15}{Bug fixed} |
| 2445 |
% \begin{macrocode} |
| 2446 |
\def\ROUND{\@ifnextchar[\@@ROUND\@ROUND} |
| 2447 |
\def\@ROUND#1#2{\@@ROUND[2]{#1}{#2}} |
| 2448 |
\def\@@ROUND[#1]#2#3{% |
| 2449 |
\begingroup |
| 2450 |
\ifdim #1\p@ > 4\p@ \cctr@Warnround{#2}{\noexpand#3} \COPY{#2}{#3} |
| 2451 |
\else |
| 2452 |
\INTEGERPART{#2}{\cctr@tempa} |
| 2453 |
\ifdim \cctr@tempa\p@ = #2\p@ |
| 2454 |
\expandafter\@@@ROUND\[email protected].)[#1]{#3} |
| 2455 |
\else |
| 2456 |
\expandafter\@@@ROUND#200000.)[#1]{#3} |
| 2457 |
\fi |
| 2458 |
\fi |
| 2459 |
\@OUTPUTSOL{#3}} |
| 2460 |
|
| 2461 |
\def\@@@ROUND#1.#2#3#4#5#6.#7)[#8]#9{% |
| 2462 |
\ifcase #8 |
| 2463 |
\COPY{#1}{#9} \ifnum #2>4 \ADD{#1}{1}{\cctr@tempp}\COPY{\cctr@tempp}{#9} \fi |
| 2464 |
\or\COPY{#1.#2}{#9} \ifnum #3>4 \ADD{#2}{1}\cctr@tempq\COPY{#1}{\cctr@tempp} |
| 2465 |
\ifnum\cctr@tempq=10\ADD{\cctr@tempp}{1}\cctr@tempp\COPY{0}{\cctr@tempq}\fi |
| 2466 |
\COPY{\cctr@tempp.\cctr@tempq}{#9} |
| 2467 |
\fi |
| 2468 |
\or\COPY{#1.#2#3}{#9} \ifnum #4>4 \ADD{#3}1\cctr@tempq\COPY{#2}{\cctr@tempp}\COPY{#1}{\cctr@tempo} |
| 2469 |
\ifnum\cctr@tempq=10\ADD{\cctr@tempp}{1}{\cctr@tempp}\COPY{0}{\cctr@tempq}\fi |
| 2470 |
\ifnum\cctr@tempp=10\ADD{\cctr@tempo}{1}\cctr@tempo\COPY{0}{\cctr@tempp}\fi |
| 2471 |
\COPY{\cctr@tempo.\cctr@tempp\cctr@tempq}{#9} |
| 2472 |
\fi |
| 2473 |
\or\COPY{#1.#2#3#4}{#9} \ifnum #5>4 \ADD{#4}1\cctr@tempq\COPY{#3}{\cctr@tempp}\COPY{#2}{\cctr@tempo}\COPY{#1}{\cctr@tempn} |
| 2474 |
\ifnum\cctr@tempq=10\ADD{\cctr@tempp}{1}{\cctr@tempp}\COPY{0}{\cctr@tempq}\fi |
| 2475 |
\ifnum\cctr@tempp=10\ADD{\cctr@tempo}{1}\cctr@tempo\COPY{0}{\cctr@tempp}\fi |
| 2476 |
\ifnum\cctr@tempo=10\ADD{\cctr@tempn}{1}\cctr@tempn\COPY{0}{\cctr@tempo}\fi |
| 2477 |
\COPY{\cctr@tempn.\cctr@tempo\cctr@tempp\cctr@tempq}{#9} |
| 2478 |
\fi |
| 2479 |
\or\COPY{#1.#2#3#4#5}{#9} \ifnum #6>4 \ADD{#5}1\cctr@tempq\COPY{#4}{\cctr@tempp}\COPY{#3}{\cctr@tempo}\COPY{#2}{\cctr@tempn}\COPY{#1}{\cctr@tempm} |
| 2480 |
\ifnum\cctr@tempq=10\ADD{\cctr@tempp}{1}{\cctr@tempp}\COPY{0}{\cctr@tempq}\fi |
| 2481 |
\ifnum\cctr@tempp=10\ADD{\cctr@tempo}{1}\cctr@tempo\COPY{0}{\cctr@tempp}\fi |
| 2482 |
\ifnum\cctr@tempo=10\ADD{\cctr@tempn}{1}\cctr@tempn\COPY{0}{\cctr@tempo}\fi |
| 2483 |
\ifnum\cctr@tempn=10\ADD{\cctr@tempm}{1}\cctr@tempm\COPY{0}{\cctr@tempn}\fi |
| 2484 |
\COPY{\cctr@tempm.\cctr@tempn\cctr@tempo\cctr@tempp\cctr@tempq}{#9} |
| 2485 |
\fi} |
| 2486 |
% \end{macrocode} |
| 2487 |
% \end{macro} |
| 2488 |
% \begin{macro}{\GCD} |
| 2489 |
% \cs{GCD}\marg{\#1}\marg{\#2}\marg{\#3} |
| 2490 |
% Greatest common divisor, using the Euclidean algorithm |
| 2491 |
% \begin{macrocode} |
| 2492 |
\def\GCD#1#2#3{% |
| 2493 |
\begingroup |
| 2494 |
\ABSVALUE{#1}{\cctr@tempa} |
| 2495 |
\ABSVALUE{#2}{\cctr@tempb} |
| 2496 |
\MAX{\cctr@tempa}{\cctr@tempb}{\cctr@tempc} |
| 2497 |
\MIN{\cctr@tempa}{\cctr@tempb}{\cctr@tempa} |
| 2498 |
\COPY{\cctr@tempc}{\cctr@tempb} |
| 2499 |
\ifnum \cctr@tempa = 0 |
| 2500 |
\ifnum \cctr@tempb = 0 |
| 2501 |
\cctr@Warnnogcd |
| 2502 |
\let#3\undefined |
| 2503 |
\else |
| 2504 |
\COPY{\cctr@tempb}{#3} |
| 2505 |
\fi |
| 2506 |
\else |
| 2507 |
% \end{macrocode} |
| 2508 |
% Euclidean algorithm: if $c\equiv b \pmod{a}$ then $\gcd(b,a)=\gcd(a,c)$. |
| 2509 |
% Iterating this property, we obtain $\gcd(b,a)$ as the last nonzero residual. |
| 2510 |
% \begin{macrocode} |
| 2511 |
\@whilenum \cctr@tempa > \z@ \do {% |
| 2512 |
\COPY{\cctr@tempa}{#3}% |
| 2513 |
\MODULO{\cctr@tempb}{\cctr@tempa}{\cctr@tempc}% |
| 2514 |
\COPY\cctr@tempa\cctr@tempb% |
| 2515 |
\COPY\cctr@tempc\cctr@tempa} |
| 2516 |
\fi\ignorespaces\@OUTPUTSOL{#3}} |
| 2517 |
% \end{macrocode} |
| 2518 |
% \end{macro} |
| 2519 |
% \begin{macro}{\LCM} |
| 2520 |
% \cs{LCM}\marg{\#1}\marg{\#2}\marg{\#3} |
| 2521 |
% Least common multiple. |
| 2522 |
% \begin{macrocode} |
| 2523 |
\def\LCM#1#2#3{% |
| 2524 |
\GCD{#1}{#2}{#3}% |
| 2525 |
\ifx #3\undefined \COPY{0}{#3} |
| 2526 |
\else |
| 2527 |
\DIVIDE{#1}{#3}{#3} |
| 2528 |
\MULTIPLY{#2}{#3}{#3} |
| 2529 |
\ABSVALUE{#3}{#3} |
| 2530 |
\fi} |
| 2531 |
% \end{macrocode} |
| 2532 |
% \end{macro} |
| 2533 |
% \begin{macro}{\FRACTIONSIMPLIFY} |
| 2534 |
% \cs{FRACTIONSIMPLIFY}\marg{\#1}\marg{\#2}\marg{\#3}\marg{\#4} |
| 2535 |
% Fraction simplification: $\textit{\#3}/\textit{\#4}$ is the irreducible |
| 2536 |
% fraction equivalent to $\textit{\#1}/\textit{\#2}$. |
| 2537 |
% \begin{macrocode} |
| 2538 |
\def\FRACTIONSIMPLIFY#1#2#3#4{% |
| 2539 |
\ifnum #1=\z@ |
| 2540 |
\COPY{0}{#3}\COPY{1}{#4} |
| 2541 |
\else |
| 2542 |
\GCD{#1}{#2}{#3}% |
| 2543 |
\DIVIDE{#2}{#3}{#4} |
| 2544 |
\DIVIDE{#1}{#3}{#3} |
| 2545 |
\ifnum #4<0 \MULTIPLY{-1}{#4}{#4}\MULTIPLY{-1}{#3}{#3}\fi |
| 2546 |
\fi\ignorespaces} |
| 2547 |
% \end{macrocode} |
| 2548 |
% \end{macro} |
| 2549 |
% \subsubsection*{Elementary functions} |
| 2550 |
% \paragraph*{Square roots} |
| 2551 |
% \begin{macro}{\SQUAREROOT} |
| 2552 |
% \cs{SQUAREROOT}\marg{\#1}\marg{\#2} |
| 2553 |
% defines \textit{\#2} as the square root of \textit{\#1}, |
| 2554 |
% using the Newton's method: $x_{n+1}=x_n-(x_n^2-\textit{\#1})/(2x_n)$. |
| 2555 |
% \begin{macrocode} |
| 2556 |
\def\SQUAREROOT#1#2{% |
| 2557 |
\begingroup |
| 2558 |
\ifdim #1\p@ = \z@ |
| 2559 |
\COPY{0}{#2} |
| 2560 |
\else |
| 2561 |
\ifdim #1\p@ < \z@ |
| 2562 |
\let#2\undefined |
| 2563 |
\cctr@Warnnoposrad{#1}% |
| 2564 |
\else |
| 2565 |
% \end{macrocode} |
| 2566 |
% We take \textit{\#1} as the initial approximation. |
| 2567 |
% \begin{macrocode} |
| 2568 |
\COPY{#1}{#2} |
| 2569 |
% \end{macrocode} |
| 2570 |
% \cs{cctr@lengthb} will be the difference of two successive iterations. |
| 2571 |
% |
| 2572 |
% We start with |\cctr@lengthb=5\p@| to ensure almost one iteration. |
| 2573 |
% \begin{macrocode} |
| 2574 |
\cctr@lengthb=5\p@ |
| 2575 |
% \end{macrocode} |
| 2576 |
% Successive iterations |
| 2577 |
% \begin{macrocode} |
| 2578 |
\@whilenum \cctr@lengthb>\cctr@epsilon \do {% |
| 2579 |
% \end{macrocode} |
| 2580 |
% Copy the actual approximation to \cs{cctr@tempw} |
| 2581 |
% \begin{macrocode} |
| 2582 |
\COPY{#2}{\cctr@tempw} |
| 2583 |
\DIVIDE{#1}{\cctr@tempw}{\cctr@tempz} |
| 2584 |
\ADD{\cctr@tempw}{\cctr@tempz}{\cctr@tempz} |
| 2585 |
\DIVIDE{\cctr@tempz}{2}{\cctr@tempz} |
| 2586 |
% \end{macrocode} |
| 2587 |
% Now, \cs{cctr@tempz} is the new approximation. |
| 2588 |
% \begin{macrocode} |
| 2589 |
\COPY{\cctr@tempz}{#2} |
| 2590 |
% \end{macrocode} |
| 2591 |
% Finally, we store in \cs{cctr@lengthb} the difference |
| 2592 |
% of the two last approximations, finishing the loop. |
| 2593 |
% \begin{macrocode} |
| 2594 |
\SUBTRACT{#2}{\cctr@tempw}{\cctr@tempw} |
| 2595 |
\cctr@lengthb=\cctr@tempw\p@% |
| 2596 |
\ifnum |
| 2597 |
\cctr@lengthb<\z@ \cctr@lengthb=-\cctr@lengthb |
| 2598 |
\fi} |
| 2599 |
\fi\fi\@OUTPUTSOL{#2}} |
| 2600 |
% \end{macrocode} |
| 2601 |
% \end{macro} |
| 2602 |
% \begin{macro}{\SQRT} |
| 2603 |
% \cs{SQRT} is an alias for \cs{SQUAREROOT}. |
| 2604 |
% \begin{macrocode} |
| 2605 |
\let\SQRT\SQUAREROOT |
| 2606 |
% \end{macrocode} |
| 2607 |
% \end{macro} |
| 2608 |
% \paragraph{Trigonometric functions} |
| 2609 |
% For a variable close enough to zero, the sine and tangent functions |
| 2610 |
% are computed using some continued fractions. |
| 2611 |
% Then, all trigonometric functions are derived from well-known formulas. |
| 2612 |
% \begin{macro}{\SIN} |
| 2613 |
% \cs{SIN}\marg{\#1}\marg{\#2}. Sine of \textit{\#1}. |
| 2614 |
% \begin{macrocode} |
| 2615 |
\def\SIN#1#2{% |
| 2616 |
\begingroup |
| 2617 |
% \end{macrocode} |
| 2618 |
% Exact sine for $t\in\{\pi/2,-\pi/2,3\pi/2\}$ |
| 2619 |
% \begin{macrocode} |
| 2620 |
\ifdim #1\p@=-\numberHALFPI\p@ \COPY{-1}{#2} |
| 2621 |
\else |
| 2622 |
\ifdim #1\p@=\numberHALFPI\p@ \COPY{1}{#2} |
| 2623 |
\else |
| 2624 |
\ifdim #1\p@=\numberTHREEHALFPI\p@ \COPY{-1}{#2} |
| 2625 |
\else |
| 2626 |
% \end{macrocode} |
| 2627 |
% If $\left\vert t \right\vert>\pi/2$, change $t$ to a smaller value. |
| 2628 |
% \begin{macrocode} |
| 2629 |
\ifdim#1\p@<-\numberHALFPI\p@ |
| 2630 |
\ADD{#1}{\numberTWOPI}{\cctr@tempb} |
| 2631 |
\SIN{\cctr@tempb}{#2} |
| 2632 |
\else |
| 2633 |
\ifdim #1\p@<\numberHALFPI\p@ |
| 2634 |
% \end{macrocode} |
| 2635 |
% Compute the sine. |
| 2636 |
% \begin{macrocode} |
| 2637 |
\@BASICSINE{#1}{#2} |
| 2638 |
\else |
| 2639 |
\ifdim #1\p@<\numberTHREEHALFPI\p@ |
| 2640 |
\SUBTRACT{\numberPI}{#1}{\cctr@tempb} |
| 2641 |
\SIN{\cctr@tempb}{#2} |
| 2642 |
\else |
| 2643 |
\SUBTRACT{#1}{\numberTWOPI}{\cctr@tempb} |
| 2644 |
\SIN{\cctr@tempb}{#2} |
| 2645 |
\fi\fi\fi\fi\fi\fi\@OUTPUTSOL{#2}} |
| 2646 |
% \end{macrocode} |
| 2647 |
% \end{macro} |
| 2648 |
% \begin{macro}{\@BASICSINE} |
| 2649 |
% \cs{@BASICSINE}\marg{\#1}\marg{\#2} applies this approximation: |
| 2650 |
% \[ |
| 2651 |
% \sin x = \frac{x}{ |
| 2652 |
% 1+\displaystyle\frac{x^2}{ |
| 2653 |
% 2\cdot3-x^2+\displaystyle\frac{2\cdot3x^2}{ |
| 2654 |
% 4\cdot5-x^2+\displaystyle\frac{4\cdot5x^2}{ |
| 2655 |
% 6\cdot7-x^2+\cdots |
| 2656 |
% } |
| 2657 |
% } |
| 2658 |
% } |
| 2659 |
% } |
| 2660 |
% \] |
| 2661 |
% \begin{macrocode} |
| 2662 |
\def\@BASICSINE#1#2{% |
| 2663 |
\begingroup |
| 2664 |
\ABSVALUE{#1}{\cctr@tempa} |
| 2665 |
% \end{macrocode} |
| 2666 |
% Exact sine of zero |
| 2667 |
% \begin{macrocode} |
| 2668 |
\ifdim\cctr@tempa\p@=\z@ \COPY{0}{#2} |
| 2669 |
\else |
| 2670 |
% \end{macrocode} |
| 2671 |
% For $t$ very close to zero, $\sin t\approx t$. |
| 2672 |
% \begin{macrocode} |
| 2673 |
\ifdim \cctr@tempa\p@<0.009\p@\COPY{#1}{#2} |
| 2674 |
\else |
| 2675 |
% \end{macrocode} |
| 2676 |
% Compute the continued fraction. |
| 2677 |
% \begin{macrocode} |
| 2678 |
\SQUARE{#1}{\cctr@tempa} |
| 2679 |
\DIVIDE{\cctr@tempa}{42}{#2} |
| 2680 |
\SUBTRACT{1}{#2}{#2} |
| 2681 |
\MULTIPLY{#2}{\cctr@tempa}{#2} |
| 2682 |
\DIVIDE{#2}{20}{#2} |
| 2683 |
\SUBTRACT{1}{#2}{#2} |
| 2684 |
\MULTIPLY{#2}{\cctr@tempa}{#2} |
| 2685 |
\DIVIDE{#2}{6}{#2} |
| 2686 |
\SUBTRACT{1}{#2}{#2} |
| 2687 |
\MULTIPLY{#2}{#1}{#2} |
| 2688 |
\fi\fi\@OUTPUTSOL{#2}} |
| 2689 |
% \end{macrocode} |
| 2690 |
% \end{macro} |
| 2691 |
% \begin{macro}{\COS} |
| 2692 |
% \cs{COS}\marg{\#1}\marg{\#2}. Cosine of \textit{\#1}: $\cos t=\sin(t+\pi/2)$. |
| 2693 |
% \begin{macrocode} |
| 2694 |
\def\COS#1#2{% |
| 2695 |
\begingroup |
| 2696 |
\ADD{\numberHALFPI}{#1}{\cctr@tempc} |
| 2697 |
\SIN{\cctr@tempc}{#2}\@OUTPUTSOL{#2}} |
| 2698 |
% \end{macrocode} |
| 2699 |
% \end{macro} |
| 2700 |
% \begin{macro}{\TAN} |
| 2701 |
% \cs{TAN}\marg{\#1}\marg{\#2}. Tangent of \textit{\#1}. |
| 2702 |
% \begin{macrocode} |
| 2703 |
\def\TAN#1#2{% |
| 2704 |
\begingroup |
| 2705 |
% \end{macrocode} |
| 2706 |
% Tangent is infinite for $t=\pm\pi/2$ |
| 2707 |
% \begin{macrocode} |
| 2708 |
\ifdim #1\p@=-\numberHALFPI\p@ |
| 2709 |
\cctr@Warninftan{#1} |
| 2710 |
\let#2\undefined |
| 2711 |
\else |
| 2712 |
\ifdim #1\p@=\numberHALFPI\p@ |
| 2713 |
\cctr@Warninftan{#1} |
| 2714 |
\let#2\undefined |
| 2715 |
\else |
| 2716 |
% \end{macrocode} |
| 2717 |
% If $\left\vert t \right\vert>\pi/2$, change $t$ to a smaller value. |
| 2718 |
% \begin{macrocode} |
| 2719 |
\ifdim #1\p@<-\numberHALFPI\p@ |
| 2720 |
\ADD{#1}{\numberPI}{\cctr@tempb} |
| 2721 |
\TAN{\cctr@tempb}{#2} |
| 2722 |
\else |
| 2723 |
\ifdim #1\p@<\numberHALFPI\p@ |
| 2724 |
% \end{macrocode} |
| 2725 |
% Compute the tangent. |
| 2726 |
% \begin{macrocode} |
| 2727 |
\@BASICTAN{#1}{#2} |
| 2728 |
\else |
| 2729 |
\SUBTRACT{#1}{\numberPI}{\cctr@tempb} |
| 2730 |
\TAN{\cctr@tempb}{#2} |
| 2731 |
\fi\fi\fi\fi\@OUTPUTSOL{#2}} |
| 2732 |
% \end{macrocode} |
| 2733 |
% \end{macro} |
| 2734 |
% \begin{macro}{\@BASICTAN} |
| 2735 |
% \cs{@BASICTAN}\marg{\#1}\marg{\#2} applies this approximation: |
| 2736 |
% \[ |
| 2737 |
% \tan x = \frac{1}{ |
| 2738 |
% \displaystyle\frac{1}{x}-\displaystyle\frac{1}{ |
| 2739 |
% \displaystyle\frac{3}{x}-\displaystyle\frac{1}{ |
| 2740 |
% \displaystyle\frac{5}{x}-\displaystyle\frac{1}{ |
| 2741 |
% \displaystyle\frac{7}{x}-\displaystyle\frac{1}{ |
| 2742 |
% \displaystyle\frac{9}{x}-\displaystyle\frac{1}{ |
| 2743 |
% \displaystyle\frac{11}{x}- |
| 2744 |
% \cdots |
| 2745 |
% } |
| 2746 |
% } |
| 2747 |
% } |
| 2748 |
% } |
| 2749 |
% } |
| 2750 |
% } |
| 2751 |
% \] |
| 2752 |
% \begin{macrocode} |
| 2753 |
\def\@BASICTAN#1#2{% |
| 2754 |
\begingroup |
| 2755 |
\ABSVALUE{#1}{\cctr@tempa} |
| 2756 |
% \end{macrocode} |
| 2757 |
% Exact tangent of zero. |
| 2758 |
% \begin{macrocode} |
| 2759 |
\ifdim\cctr@tempa\p@=\z@ \COPY{0}{#2} |
| 2760 |
\else |
| 2761 |
% \end{macrocode} |
| 2762 |
% For $t$ very close to zero, $\tan t\approx t$. |
| 2763 |
% \begin{macrocode} |
| 2764 |
\ifdim\cctr@tempa\p@<0.04\p@ |
| 2765 |
\COPY{#1}{#2} |
| 2766 |
\else |
| 2767 |
% \end{macrocode} |
| 2768 |
% Compute the continued fraction. |
| 2769 |
% \begin{macrocode} |
| 2770 |
\DIVIDE{#1}{11}{#2} |
| 2771 |
\DIVIDE{9}{#1}{\cctr@tempa} |
| 2772 |
\SUBTRACT{\cctr@tempa}{#2}{#2} |
| 2773 |
\DIVIDE{1}{#2}{#2} |
| 2774 |
\DIVIDE{7}{#1}{\cctr@tempa} |
| 2775 |
\SUBTRACT{\cctr@tempa}{#2}{#2} |
| 2776 |
\DIVIDE{1}{#2}{#2} |
| 2777 |
\DIVIDE{5}{#1}{\cctr@tempa} |
| 2778 |
\SUBTRACT{\cctr@tempa}{#2}{#2} |
| 2779 |
\DIVIDE{1}{#2}{#2} |
| 2780 |
\DIVIDE{3}{#1}{\cctr@tempa} |
| 2781 |
\SUBTRACT{\cctr@tempa}{#2}{#2} |
| 2782 |
\DIVIDE{1}{#2}{#2} |
| 2783 |
\DIVIDE{1}{#1}{\cctr@tempa} |
| 2784 |
\SUBTRACT{\cctr@tempa}{#2}{#2} |
| 2785 |
\DIVIDE{1}{#2}{#2} |
| 2786 |
\fi\fi\@OUTPUTSOL{#2}} |
| 2787 |
% \end{macrocode} |
| 2788 |
% \end{macro} |
| 2789 |
% \begin{macro}{\COT} |
| 2790 |
% \cs{COT}\marg{\#1}\marg{\#2}. Cotangent of \textit{\#1}: |
| 2791 |
% If $\cos t=0$ then $\cot t=0$; if $\tan t=0$ then $\cot t=\infty$. |
| 2792 |
% Otherwise, $\cot t=1/\tan t$. |
| 2793 |
% \begin{macrocode} |
| 2794 |
\def\COT#1#2{% |
| 2795 |
\begingroup |
| 2796 |
\COS{#1}{#2} |
| 2797 |
\ifdim #2\p@ = \z@ |
| 2798 |
\COPY{0}{#2} |
| 2799 |
\else |
| 2800 |
\TAN{#1}{#2} |
| 2801 |
\ifdim #2\p@ = \z@ |
| 2802 |
\cctr@Warninfcotan{#1} |
| 2803 |
\let#2\undefined |
| 2804 |
\else |
| 2805 |
\DIVIDE{1}{#2}{#2} |
| 2806 |
\fi\fi\@OUTPUTSOL{#2}} |
| 2807 |
% \end{macrocode} |
| 2808 |
% \end{macro} |
| 2809 |
% \begin{macro}{\DEGtoRAD} |
| 2810 |
% \cs{DEGtoRAD}\marg{\#1}\marg{\#2}. Convert degrees to radians. |
| 2811 |
% \begin{macrocode} |
| 2812 |
\def\DEGtoRAD#1#2{\DIVIDE{#1}{57.29578}{#2}} |
| 2813 |
% \end{macrocode} |
| 2814 |
% \end{macro} |
| 2815 |
% \begin{macro}{\RADtoDEG} |
| 2816 |
% \cs{RADtoDEG}\marg{\#1}\marg{\#2}. Convert radians to degrees. |
| 2817 |
% \begin{macrocode} |
| 2818 |
\def\RADtoDEG#1#2{\MULTIPLY{#1}{57.29578}{#2}} |
| 2819 |
% \end{macrocode} |
| 2820 |
% \end{macro} |
| 2821 |
% \begin{macro}{\REDUCERADIANSANGLE} |
| 2822 |
% Reduces to the trigonometrically equivalent arc in $]{-}\pi,\pi]$. |
| 2823 |
% \begin{macrocode} |
| 2824 |
\def\REDUCERADIANSANGLE#1#2{% |
| 2825 |
\COPY{#1}{#2} |
| 2826 |
\ifdim #1\p@ < -\numberPI\p@ |
| 2827 |
\ADD{#1}{\numberTWOPI}{#2} |
| 2828 |
\REDUCERADIANSANGLE{#2}{#2} |
| 2829 |
\fi |
| 2830 |
\ifdim #1\p@ > \numberPI\p@ |
| 2831 |
\SUBTRACT{#1}{\numberTWOPI}{#2} |
| 2832 |
\REDUCERADIANSANGLE{#2}{#2} |
| 2833 |
\fi |
| 2834 |
\ifdim #1\p@ = -180\p@ \COPY{\numberPI}{#2} \fi} |
| 2835 |
% \end{macrocode} |
| 2836 |
% \end{macro} |
| 2837 |
% \begin{macro}{\REDUCEDEGREESANGLE} |
| 2838 |
% Reduces to the trigonometrically equivalent angle in $]{-}180,180]$. |
| 2839 |
% \begin{macrocode} |
| 2840 |
\def\REDUCEDEGREESANGLE#1#2{% |
| 2841 |
\COPY{#1}{#2} |
| 2842 |
\ifdim #1\p@ < -180\p@ |
| 2843 |
\ADD{#1}{360}{#2} |
| 2844 |
\REDUCEDEGREESANGLE{#2}{#2} |
| 2845 |
\fi |
| 2846 |
\ifdim #1\p@ > 180\p@ |
| 2847 |
\SUBTRACT{#1}{360}{#2} |
| 2848 |
\REDUCEDEGREESANGLE{#2}{#2} |
| 2849 |
\fi |
| 2850 |
\ifdim #1\p@ = -180\p@ \COPY{180}{#2} \fi} |
| 2851 |
% \end{macrocode} |
| 2852 |
% \end{macro} |
| 2853 |
% \subparagraph*{Trigonometric functions in degrees} |
| 2854 |
% Four next commands compute trigonometric functions |
| 2855 |
% in \emph{degrees}. By default, a circle has $360$ |
| 2856 |
% degrees, but we can use an arbitrary number of divisions |
| 2857 |
% using the optional argument of these commands. |
| 2858 |
% \begin{macro}{\DEGREESSIN} |
| 2859 |
% \cs{DEGREESSIN}\oarg{\#1}\marg{\#2}\marg{\#3}. |
| 2860 |
% Sine of \textit{\#2} \emph{degrees}. |
| 2861 |
% \begin{macrocode} |
| 2862 |
\def\DEGREESSIN{\@ifnextchar[\@@DEGREESSIN\@DEGREESSIN} |
| 2863 |
% \end{macrocode} |
| 2864 |
% \end{macro} |
| 2865 |
% \begin{macro}{\DEGREESCOS} |
| 2866 |
% \cs{DEGREESCOS}\oarg{\#1}\marg{\#2}\marg{\#3}. |
| 2867 |
% Cosine of \textit{\#2} \emph{degrees}. |
| 2868 |
% \begin{macrocode} |
| 2869 |
\def\DEGREESCOS{\@ifnextchar[\@@DEGREESCOS\@DEGREESCOS} |
| 2870 |
% \end{macrocode} |
| 2871 |
% \end{macro} |
| 2872 |
% \begin{macro}{\DEGREESTAN} |
| 2873 |
% \cs{DEGREESTAN}\oarg{\#1}\marg{\#2}\marg{\#3}. |
| 2874 |
% Tangent of \textit{\#2} \emph{degrees}. |
| 2875 |
% \begin{macrocode} |
| 2876 |
\def\DEGREESTAN{\@ifnextchar[\@@DEGREESTAN\@DEGREESTAN} |
| 2877 |
% \end{macrocode} |
| 2878 |
% \end{macro} |
| 2879 |
% \begin{macro}{\DEGREESCOT} |
| 2880 |
% \cs{DEGREESCOT}\oarg{\#1}\marg{\#2}\marg{\#3}. |
| 2881 |
% Cotangent of \textit{\#2} \emph{degrees}. |
| 2882 |
% \begin{macrocode} |
| 2883 |
\def\DEGREESCOT{\@ifnextchar[\@@DEGREESCOT\@DEGREESCOT} |
| 2884 |
% \end{macrocode} |
| 2885 |
% \end{macro} |
| 2886 |
% \begin{macro}{\@DEGREESSIN} |
| 2887 |
% \cs{@DEGREESSIN} computes the sine in sexagesimal \emph{degrees}. |
| 2888 |
% \begin{macrocode} |
| 2889 |
\def\@DEGREESSIN#1#2{% |
| 2890 |
\begingroup |
| 2891 |
\ifdim #1\p@=-90\p@ \COPY{-1}{#2} |
| 2892 |
\else |
| 2893 |
\ifdim #1\p@=90\p@ \COPY{1}{#2} |
| 2894 |
\else |
| 2895 |
\ifdim #1\p@=270\p@ \COPY{-1}{#2} |
| 2896 |
\else |
| 2897 |
\ifdim#1\p@<-90\p@ |
| 2898 |
\ADD{#1}{360}{\cctr@tempb} |
| 2899 |
\DEGREESSIN{\cctr@tempb}{#2} |
| 2900 |
\else |
| 2901 |
\ifdim #1\p@<90\p@ |
| 2902 |
\DEGtoRAD{#1}{\cctr@tempb} |
| 2903 |
\@BASICSINE{\cctr@tempb}{#2} |
| 2904 |
\else |
| 2905 |
\ifdim #1\p@<270\p@ |
| 2906 |
\SUBTRACT{180}{#1}{\cctr@tempb} |
| 2907 |
\DEGREESSIN{\cctr@tempb}{#2} |
| 2908 |
\else |
| 2909 |
\SUBTRACT{#1}{360}{\cctr@tempb} |
| 2910 |
\DEGREESSIN{\cctr@tempb}{#2} |
| 2911 |
\fi\fi\fi\fi\fi\fi\@OUTPUTSOL{#2}} |
| 2912 |
% \end{macrocode} |
| 2913 |
% \end{macro} |
| 2914 |
% \begin{macro}{\@DEGREESCOS} |
| 2915 |
% \cs{@DEGREESCOS} computes the cosine in sexagesimal \emph{degrees}. |
| 2916 |
% \begin{macrocode} |
| 2917 |
\def\@DEGREESCOS#1#2{% |
| 2918 |
\begingroup |
| 2919 |
\ADD{90}{#1}{\cctr@tempc} |
| 2920 |
\DEGREESSIN{\cctr@tempc}{#2}\@OUTPUTSOL{#2}} |
| 2921 |
% \end{macrocode} |
| 2922 |
% \end{macro} |
| 2923 |
% \begin{macro}{\@DEGREESTAN} |
| 2924 |
% \cs{@DEGREESTAN} computes the tangent in sexagesimal \emph{degrees}. |
| 2925 |
% \begin{macrocode} |
| 2926 |
\def\@DEGREESTAN#1#2{% |
| 2927 |
\begingroup |
| 2928 |
\ifdim #1\p@=-90\p@ |
| 2929 |
\cctr@Warninftan{#1} |
| 2930 |
\let#2\undefined |
| 2931 |
\else |
| 2932 |
\ifdim #1\p@=90\p@ |
| 2933 |
\cctr@Warninftan{#1} |
| 2934 |
\let#2\undefined |
| 2935 |
\else |
| 2936 |
\ifdim #1\p@<-90\p@ |
| 2937 |
\ADD{#1}{180}{\cctr@tempb} \DEGREESTAN{\cctr@tempb}{#2} |
| 2938 |
\else |
| 2939 |
\ifdim #1\p@<90\p@ |
| 2940 |
\DEGtoRAD{#1}{\cctr@tempb} |
| 2941 |
\@BASICTAN{\cctr@tempb}{#2} |
| 2942 |
\else |
| 2943 |
\SUBTRACT{#1}{180}{\cctr@tempb} |
| 2944 |
\DEGREESTAN{\cctr@tempb}{#2} |
| 2945 |
\fi\fi\fi\fi\@OUTPUTSOL{#2}} |
| 2946 |
% \end{macrocode} |
| 2947 |
% \end{macro} |
| 2948 |
% \begin{macro}{\@DEGREESCOT} |
| 2949 |
% \cs{@DEGREESCOT} computes the cotangent in sexagesimal \emph{degrees}. |
| 2950 |
% \begin{macrocode} |
| 2951 |
\def\@DEGREESCOT#1#2{% |
| 2952 |
\begingroup |
| 2953 |
\DEGREESCOS{#1}{#2} |
| 2954 |
\ifdim #2\p@ = \z@ |
| 2955 |
\COPY{0}{#2} |
| 2956 |
\else |
| 2957 |
\DEGREESTAN{#1}{#2} |
| 2958 |
\ifdim #2\p@ = \z@ |
| 2959 |
\cctr@Warninfcotan{#1} |
| 2960 |
\let#2\undefined |
| 2961 |
\else |
| 2962 |
\DIVIDE{1}{#2}{#2} |
| 2963 |
\fi\fi\@OUTPUTSOL{#2}} |
| 2964 |
% \end{macrocode} |
| 2965 |
% \end{macro} |
| 2966 |
% For an arbitrary number of \emph{degrees}, we normalise |
| 2967 |
% to $360$ degrees and, then, call the former functions. |
| 2968 |
% \begin{macro}{\@@DEGREESSIN} |
| 2969 |
% \cs{@@DEGREESSIN} computes the sine. |
| 2970 |
% A circle has \textit{\#1} \emph{degrees}. |
| 2971 |
% \begin{macrocode} |
| 2972 |
\def\@@DEGREESSIN[#1]#2#3{\@CONVERTDEG{#1}{#2} |
| 2973 |
\@DEGREESSIN{\@DEGREES}{#3}} |
| 2974 |
% \end{macrocode} |
| 2975 |
% \end{macro} |
| 2976 |
% \begin{macro}{\@@DEGREESCOS} |
| 2977 |
% \cs{@@DEGREESCOS} computes the sine. |
| 2978 |
% A circle has \textit{\#1} \emph{degrees}. |
| 2979 |
% \begin{macrocode} |
| 2980 |
\def\@@DEGREESCOS[#1]#2#3{\@CONVERTDEG{#1}{#2} |
| 2981 |
\DEGREESCOS{\@DEGREES}{#3}} |
| 2982 |
% \end{macrocode} |
| 2983 |
% \end{macro} |
| 2984 |
% \begin{macro}{\@@DEGREESTAN} |
| 2985 |
% \cs{@@DEGREESTAN} computes the sine. |
| 2986 |
% A circle has \textit{\#1} \emph{degrees}. |
| 2987 |
% \begin{macrocode} |
| 2988 |
\def\@@DEGREESTAN[#1]#2#3{\@CONVERTDEG{#1}{#2} |
| 2989 |
\DEGREESTAN{\@DEGREES}{#3}} |
| 2990 |
% \end{macrocode} |
| 2991 |
% \end{macro} |
| 2992 |
% \begin{macro}{\@@DEGREESCOT} |
| 2993 |
% \cs{@@DEGREESCOT} computes the sine. |
| 2994 |
% A circle has \textit{\#1} \emph{degrees}. |
| 2995 |
% \begin{macrocode} |
| 2996 |
\def\@@DEGREESCOT[#1]#2#3{\@CONVERTDEG{#1}{#2} |
| 2997 |
\DEGREESCOT{\@DEGREES}{#3}} |
| 2998 |
% \end{macrocode} |
| 2999 |
% \end{macro} |
| 3000 |
% \begin{macro}{\@CONVERTDEG} |
| 3001 |
% \cs{@CONVERTDEG} normalises to sexagesimal degrees. |
| 3002 |
% \begin{macrocode} |
| 3003 |
\def\@CONVERTDEG#1#2{\DIVIDE{#2}{#1}{\@DEGREES} |
| 3004 |
\MULTIPLY{\@DEGREES}{360}{\@DEGREES}} |
| 3005 |
% \end{macrocode} |
| 3006 |
% \end{macro} |
| 3007 |
% \paragraph*{Exponential functions} |
| 3008 |
% \begin{macro}{\EXP} |
| 3009 |
% \cs{EXP}\oarg{\#1}\marg{\#2}\marg{\#3} computes |
| 3010 |
% the exponential $\textit{\#3}=\textit{\#1}^{\textit{\#2}}$. |
| 3011 |
% Default for \textit{\#1} is number $\mathrm e$. |
| 3012 |
% \begin{macrocode} |
| 3013 |
\def\EXP{\@ifnextchar[\@@EXP\@EXP} |
| 3014 |
% \end{macrocode} |
| 3015 |
% \end{macro} |
| 3016 |
% \begin{macro}{\@@EXP} \cs{@@EXP}\oarg{\textit{\#1}}\marg{\#2}\marg{\#3} |
| 3017 |
% computes $\textit{\#3}=\textit{\#1}^{\textit{\#2}}$ |
| 3018 |
% \begin{macrocode} |
| 3019 |
\def\@@EXP[#1]#2#3{% |
| 3020 |
\begingroup |
| 3021 |
% \end{macrocode} |
| 3022 |
% \#1 must be a positive number. |
| 3023 |
% \begin{macrocode} |
| 3024 |
\ifdim #1\p@<\cctr@epsilon |
| 3025 |
\cctr@Warninfexpb{#1}{#2} |
| 3026 |
\let#3\undefined |
| 3027 |
\else |
| 3028 |
% \end{macrocode} |
| 3029 |
% $a^b=\exp(b\log a)$. |
| 3030 |
% \begin{macrocode} |
| 3031 |
\LOG{#1}{\cctr@log} |
| 3032 |
\MULTIPLY{#2}{\cctr@log}{\cctr@log} |
| 3033 |
\@EXP{\cctr@log}{#3} |
| 3034 |
\fi\@OUTPUTSOL{#3}} |
| 3035 |
% \end{macrocode} |
| 3036 |
% \end{macro} |
| 3037 |
% \begin{macro}{\@EXP} \cs{@EXP}\marg{\#1}\marg{\#2} |
| 3038 |
% computes $\textit{\#3}=\mathrm{e}^{\textit{\#2}}$ |
| 3039 |
% \begin{macrocode} |
| 3040 |
\def\@EXP#1#2{% |
| 3041 |
\begingroup |
| 3042 |
\ABSVALUE{#1}{\cctr@absval} |
| 3043 |
% \end{macrocode} |
| 3044 |
% If $\left\vert t\right\vert$ is greater than \cs{cctr@logmaxnum} |
| 3045 |
% then $\exp t$ is too large. |
| 3046 |
% \begin{macrocode} |
| 3047 |
\ifdim \cctr@absval\p@>\cctr@logmaxnum\p@ |
| 3048 |
\cctr@Warninfexp{#1} |
| 3049 |
\let#2\undefined |
| 3050 |
\else |
| 3051 |
\ifdim #1\p@ < \z@ |
| 3052 |
% \end{macrocode} |
| 3053 |
% We call \cs{@BASICEXP} when $t\in [{-}6,3]$. |
| 3054 |
% Otherwise we use the equality $\exp t=\left(\exp t/2\right)^2$. |
| 3055 |
% \begin{macrocode} |
| 3056 |
\ifdim #1\p@ > -6.00002\p@ |
| 3057 |
\@BASICEXP{#1}{#2} |
| 3058 |
\else |
| 3059 |
\DIVIDE{#1}{2}{\cctr@expt} |
| 3060 |
\@EXP{\cctr@expt}{\cctr@expy} |
| 3061 |
\SQUARE{\cctr@expy}{#2} |
| 3062 |
\fi |
| 3063 |
\else |
| 3064 |
\ifdim #1\p@ < 3.00002\p@ |
| 3065 |
\@BASICEXP{#1}{#2} |
| 3066 |
\else |
| 3067 |
\DIVIDE{#1}{2}{\cctr@expt} |
| 3068 |
\@EXP{\cctr@expt}{\cctr@expy} |
| 3069 |
\SQUARE{\cctr@expy}{#2} |
| 3070 |
\fi |
| 3071 |
\fi\fi\@OUTPUTSOL{#2}} |
| 3072 |
% \end{macrocode} |
| 3073 |
% \end{macro} |
| 3074 |
% \begin{macro}{\@BASICEXP} |
| 3075 |
% \cs{@BASICEXP}\marg{\#1}\marg{\#2} applies this approximation: |
| 3076 |
% \[ |
| 3077 |
% \exp x \approx 1+\frac{2x}{ |
| 3078 |
% 2-x+\displaystyle\frac{x^2/6}{ |
| 3079 |
% 1+\displaystyle\frac{x^2/60}{ |
| 3080 |
% 1+\displaystyle\frac{x^2/140}{ |
| 3081 |
% 1+\displaystyle\frac{x^2/256}{ |
| 3082 |
% 1+\displaystyle\frac{x^2}{396 |
| 3083 |
% } |
| 3084 |
% } |
| 3085 |
% } |
| 3086 |
% } |
| 3087 |
% } |
| 3088 |
% } |
| 3089 |
% \] |
| 3090 |
% \begin{macrocode} |
| 3091 |
\def\@BASICEXP#1#2{% |
| 3092 |
\begingroup |
| 3093 |
\SQUARE{#1}\cctr@tempa |
| 3094 |
\DIVIDE{\cctr@tempa}{396}{#2} |
| 3095 |
\ADD{1}{#2}{#2} |
| 3096 |
\DIVIDE\cctr@tempa{#2}{#2} |
| 3097 |
\DIVIDE{#2}{256}{#2} |
| 3098 |
\ADD{1}{#2}{#2} |
| 3099 |
\DIVIDE\cctr@tempa{#2}{#2} |
| 3100 |
\DIVIDE{#2}{140}{#2} |
| 3101 |
\ADD{1}{#2}{#2} |
| 3102 |
\DIVIDE\cctr@tempa{#2}{#2} |
| 3103 |
\DIVIDE{#2}{60}{#2} |
| 3104 |
\ADD{1}{#2}{#2} |
| 3105 |
\DIVIDE\cctr@tempa{#2}{#2} |
| 3106 |
\DIVIDE{#2}{6}{#2} |
| 3107 |
\ADD{2}{#2}{#2} |
| 3108 |
\SUBTRACT{#2}{#1}{#2} |
| 3109 |
\DIVIDE{#1}{#2}{#2} |
| 3110 |
\MULTIPLY{2}{#2}{#2} |
| 3111 |
\ADD{1}{#2}{#2}\@OUTPUTSOL{#2}} |
| 3112 |
% \end{macrocode} |
| 3113 |
% \end{macro} |
| 3114 |
% \paragraph*{Hyperbolic functions} |
| 3115 |
% \begin{macro}{\COSH} |
| 3116 |
% \cs{COSH}. Hyperbolic cosine: $\cosh t=(\exp t+\exp(-t))/2$. |
| 3117 |
% \begin{macrocode} |
| 3118 |
\def\COSH#1#2{% |
| 3119 |
\begingroup |
| 3120 |
\ABSVALUE{#1}{\cctr@absval} |
| 3121 |
\ifdim \cctr@absval\p@>\cctr@logmaxnum\p@ |
| 3122 |
\cctr@Warninfexp{#1} |
| 3123 |
\let#2\undefined |
| 3124 |
\else |
| 3125 |
\EXP{#1}{\cctr@expx} |
| 3126 |
\MULTIPLY{-1}{#1}{\cctr@minust} |
| 3127 |
\EXP{\cctr@minust}{\cctr@expminusx} |
| 3128 |
\ADD{\cctr@expx}{\cctr@expminusx}{#2} |
| 3129 |
\DIVIDE{#2}{2}{#2} |
| 3130 |
\fi\@OUTPUTSOL{#2}} |
| 3131 |
% \end{macrocode} |
| 3132 |
% \end{macro} |
| 3133 |
% \begin{macro}{\SINH} |
| 3134 |
% \cs{SINH}. Hyperbolic sine: $\sinh t=(\exp t-\exp(-t))/2$. |
| 3135 |
% \begin{macrocode} |
| 3136 |
\def\SINH#1#2{% |
| 3137 |
\begingroup |
| 3138 |
\ABSVALUE{#1}{\cctr@absval} |
| 3139 |
\ifdim \cctr@absval\p@>\cctr@logmaxnum\p@ |
| 3140 |
\cctr@Warninfexp{#1} |
| 3141 |
\let#2\undefined |
| 3142 |
\else |
| 3143 |
\EXP{#1}{\cctr@expx} |
| 3144 |
\MULTIPLY{-1}{#1}{\cctr@minust} |
| 3145 |
\EXP{\cctr@minust}{\cctr@expminusx} |
| 3146 |
\SUBTRACT{\cctr@expx}{\cctr@expminusx}{#2} |
| 3147 |
\DIVIDE{#2}{2}{#2} |
| 3148 |
\fi\@OUTPUTSOL{#2}} |
| 3149 |
% \end{macrocode} |
| 3150 |
% \end{macro} |
| 3151 |
% \begin{macro}{\TANH} |
| 3152 |
% \cs{TANH}. Hyperbolic tangent: $\tanh t=\sinh t/{\cosh t}$. |
| 3153 |
% \begin{macrocode} |
| 3154 |
\def\TANH#1#2{% |
| 3155 |
\begingroup |
| 3156 |
\ABSVALUE{#1}{\cctr@absval} |
| 3157 |
\ifdim \cctr@absval\p@>\cctr@logmaxnum\p@ |
| 3158 |
\cctr@Warninfexp{#1} |
| 3159 |
\let#2\undefined |
| 3160 |
\else |
| 3161 |
\SINH{#1}{\cctr@tanhnum} |
| 3162 |
\COSH{#1}{\cctr@tanhden} |
| 3163 |
\DIVIDE{\cctr@tanhnum}{\cctr@tanhden}{#2} |
| 3164 |
\fi\@OUTPUTSOL{#2}} |
| 3165 |
% \end{macrocode} |
| 3166 |
% \end{macro} |
| 3167 |
% \begin{macro}{\COTH} |
| 3168 |
% \cs{COTH}. Hyperbolic cotangent $\coth t=\cosh t/{\sinh t}$. |
| 3169 |
% \begin{macrocode} |
| 3170 |
\def\COTH#1#2{% |
| 3171 |
\begingroup |
| 3172 |
\ABSVALUE{#1}{\cctr@absval} |
| 3173 |
\ifdim \cctr@absval\p@>\cctr@logmaxnum\p@ |
| 3174 |
\cctr@Warninfexp{#1} |
| 3175 |
\let#2\undefined |
| 3176 |
\else |
| 3177 |
\SINH{#1}{\cctr@tanhden} |
| 3178 |
\COSH{#1}{\cctr@tanhnum} |
| 3179 |
\DIVIDE\cctr@tanhnum\cctr@tanhden{#2} |
| 3180 |
\fi\@OUTPUTSOL{#2}} |
| 3181 |
% \end{macrocode} |
| 3182 |
% \end{macro} |
| 3183 |
% \paragraph*{Logarithm} |
| 3184 |
% \begin{macro}{\LOG} |
| 3185 |
% \cs{LOG}\oarg{\#1}\marg{\#2}\marg{\#3} computes |
| 3186 |
% the logarithm $\textit{\#3}=\log_{\textit{\#1}}{\textit{\#2}}$. |
| 3187 |
% Default for \textit{\#1} is number $\mathrm e$. |
| 3188 |
% \begin{macrocode} |
| 3189 |
\def\LOG{\@ifnextchar[\@@LOG\@LOG} |
| 3190 |
% \end{macrocode} |
| 3191 |
% \end{macro} |
| 3192 |
% \begin{macro}{\@LOG} \cs{@LOG}\marg{\textit{\#1}}\marg{\#2} |
| 3193 |
% computes $\textit{\#2}=\log\textit{\#1}$ |
| 3194 |
% \begin{macrocode} |
| 3195 |
\def\@LOG#1#2{% |
| 3196 |
\begingroup |
| 3197 |
% \end{macrocode} |
| 3198 |
% The argument $t$ must be positive. |
| 3199 |
% \begin{macrocode} |
| 3200 |
\ifdim #1\p@<\cctr@epsilon |
| 3201 |
\cctr@Warninflog{#1} |
| 3202 |
\let#2\undefined |
| 3203 |
\else |
| 3204 |
\ifdim #1\p@ > \numberETWO\p@ |
| 3205 |
% \end{macrocode} |
| 3206 |
% If $t>\mathrm{e}^2$, $\log t=\log\mathrm{e}+\log(t/{\mathrm{e}})=1+\log(t/{\mathrm{e}})$ |
| 3207 |
% \begin{macrocode} |
| 3208 |
\DIVIDE{#1}{\numberE}{\cctr@ae} |
| 3209 |
\@LOG{\cctr@ae}{#2} |
| 3210 |
\ADD{1}{#2}{#2} |
| 3211 |
\else |
| 3212 |
\ifdim #1\p@ < 1\p@ |
| 3213 |
% \end{macrocode} |
| 3214 |
% If $t<1$, $\log t=\log(1/\mathrm{e})+\log(t\mathrm{e})=-1+\log(t\mathrm{e})$ |
| 3215 |
% \begin{macrocode} |
| 3216 |
\MULTIPLY{\numberE}{#1}{\cctr@ae} |
| 3217 |
\LOG{\cctr@ae}{#2} |
| 3218 |
\SUBTRACT{#2}{1}{#2} |
| 3219 |
\else |
| 3220 |
% \end{macrocode} |
| 3221 |
% For $t\in[1,\mathrm{e}^2]$ we call \cs{@@BASICLOG}. |
| 3222 |
% \begin{macrocode} |
| 3223 |
\@BASICLOG{#1}{#2} |
| 3224 |
\fi\fi\fi\@OUTPUTSOL{#2}} |
| 3225 |
% \end{macrocode} |
| 3226 |
% \end{macro} |
| 3227 |
% \begin{macro}{\@@LOG} \cs{@@LOG}\oarg{\textit{\#1}}\marg{\#2}\marg{\#3} |
| 3228 |
% computes $\textit{\#3}=\log_\textit{\#1}\textit{\#2} |
| 3229 |
% =\log(\textit{\#2})/\log(\textit{\#1})$ |
| 3230 |
% \begin{macrocode} |
| 3231 |
\def\@@LOG[#1]#2#3{\begingroup |
| 3232 |
\@LOG{#1}{\cctr@loga} |
| 3233 |
\@LOG{#2}{\cctr@logx} |
| 3234 |
\DIVIDE{\cctr@logx}{\cctr@loga}{#3}\@OUTPUTSOL{#3}} |
| 3235 |
% \end{macrocode} |
| 3236 |
% \end{macro} |
| 3237 |
% \begin{macro}{\@BASICLOG} \cs{@BASICLOG}\marg{\textit{\#1}}\marg{\#2} |
| 3238 |
% applies the Newton's method to calculate $x=\log t$: |
| 3239 |
% \[x_{n+1}=x_n+\frac{t}{\mathrm{e}^{x_n}}-1\] |
| 3240 |
% \begin{macrocode} |
| 3241 |
\def\@BASICLOG#1#2{\begingroup |
| 3242 |
% We take $\textit{\#1}-1$ as the initial approximation. |
| 3243 |
% \begin{macrocode} |
| 3244 |
\SUBTRACT{#1}{1}{\cctr@tempw} |
| 3245 |
% \end{macrocode} |
| 3246 |
% |
| 3247 |
% We start with |\cctr@lengthb=5\p@| to ensure almost one iteration. |
| 3248 |
% \changes{v2.1}{2022/09/15}{Changed stop criterion on iterations to 2sp} |
| 3249 |
% \begin{macrocode} |
| 3250 |
\cctr@lengthb=5\p@% |
| 3251 |
\cctr@epsilon=2\cctr@epsilon% |
| 3252 |
% \end{macrocode} |
| 3253 |
% Successive iterations |
| 3254 |
% \begin{macrocode} |
| 3255 |
\@whilenum \cctr@lengthb>\cctr@epsilon \do {% |
| 3256 |
\COPY{\cctr@tempw}{\cctr@tempoldw} |
| 3257 |
\EXP{\cctr@tempw}{\cctr@tempxw} |
| 3258 |
\DIVIDE{#1}{\cctr@tempxw}{\cctr@tempxw} |
| 3259 |
\ADD{\cctr@tempw}{\cctr@tempxw}{\cctr@tempw} |
| 3260 |
\SUBTRACT{\cctr@tempw}{1}{\cctr@tempw} |
| 3261 |
\SUBTRACT{\cctr@tempw}{\cctr@tempoldw}{\cctr@tempdif} |
| 3262 |
\cctr@lengthb=\cctr@tempdif\p@% |
| 3263 |
\ifnum |
| 3264 |
\cctr@lengthb<\z@ \cctr@lengthb=-\cctr@lengthb |
| 3265 |
\fi}% |
| 3266 |
\COPY{\cctr@tempw}{#2}\@OUTPUTSOL{#2}} |
| 3267 |
% \end{macrocode} |
| 3268 |
% \end{macro} |
| 3269 |
% \paragraph*{Inverse trigonometric functions} |
| 3270 |
% \changes{v2.0}{2014/02/13}{New commands: \cs{ARCSIN}, |
| 3271 |
% \cs{ARCCOS}, \cs{ARCTAN}, |
| 3272 |
% \cs{ARCCOT}} |
| 3273 |
% \begin{macro}{\ARCSIN} |
| 3274 |
% \cs{ARCSIN}\marg{\#1}\marg{\#2} |
| 3275 |
% defines \textit{\#2} as the arcsin of \textit{\#1}, |
| 3276 |
% using the Newton's method: $x_{n+1}=x_n-(\sin x_n-\textit{\#1})/(\cos x_n)$. |
| 3277 |
% \begin{macrocode} |
| 3278 |
\def\ARCSIN#1#2{% |
| 3279 |
\begingroup |
| 3280 |
\ifdim #1\p@ = \z@ |
| 3281 |
\COPY{0}{#2} |
| 3282 |
\else |
| 3283 |
\ifdim #1\p@ = 1\p@ |
| 3284 |
\COPY{\numberHALFPI}{#2} |
| 3285 |
\else |
| 3286 |
\ifdim #1\p@ = -1\p@ |
| 3287 |
\COPY{-\numberHALFPI}{#2} |
| 3288 |
\else |
| 3289 |
\ifdim #1\p@ > 1\p@ |
| 3290 |
\let#2\undefined |
| 3291 |
\cctr@Warnbigarcsin{#1} |
| 3292 |
\else |
| 3293 |
\ifdim #1\p@ < -1\p@ |
| 3294 |
\let#2\undefined |
| 3295 |
\cctr@Warnbigarcsin{#1} |
| 3296 |
\else |
| 3297 |
% \end{macrocode} |
| 3298 |
% If $x$ is close to $1$ we use $\arcsin x=\pi/2-2\arcsin\sqrt{(1-x)/2}$ |
| 3299 |
% \begin{macrocode} |
| 3300 |
\ifdim #1\p@ >0.89\p@ |
| 3301 |
\SUBTRACT{1}{#1}{\cctr@tempx} |
| 3302 |
\DIVIDE{\cctr@tempx}{2}{\cctr@tempx} |
| 3303 |
\SQRT{\cctr@tempx}{\cctr@tempxx} |
| 3304 |
\ARCSIN{\cctr@tempxx}{#2} |
| 3305 |
\MULTIPLY{2}{#2}{#2} |
| 3306 |
\SUBTRACT{\numberHALFPI}{#2}{#2} |
| 3307 |
\else |
| 3308 |
% \end{macrocode} |
| 3309 |
% Symmetrically, for $x$ close to $-1$, $\arcsin x=-\pi/2+2\arcsin\sqrt{(1+x)/2}$ |
| 3310 |
% \begin{macrocode} |
| 3311 |
\ifdim #1\p@ <-0.89\p@ |
| 3312 |
\ADD{1}{#1}{\cctr@tempx} |
| 3313 |
\DIVIDE{\cctr@tempx}{2}{\cctr@tempx} |
| 3314 |
\SQRT{\cctr@tempx}{\cctr@tempxx} |
| 3315 |
\ARCSIN{\cctr@tempxx}{#2} |
| 3316 |
\MULTIPLY{2}{#2}{#2} |
| 3317 |
\SUBTRACT{#2}{\numberHALFPI}{#2} |
| 3318 |
\else |
| 3319 |
% \end{macrocode} |
| 3320 |
% We take \textit{\#1} as the initial approximation. |
| 3321 |
% \begin{macrocode} |
| 3322 |
\COPY{#1}{#2} |
| 3323 |
% \end{macrocode} |
| 3324 |
% If $-0.4\leq t\leq 0.4$ then $\arcsin x\approx x$ is a good approximation. |
| 3325 |
% Else, we apply the Newton method |
| 3326 |
% \begin{macrocode} |
| 3327 |
\ABSVALUE{#1}{\cctr@tempy} |
| 3328 |
\ifdim \cctr@tempy\p@ < 0.04\p@ |
| 3329 |
\else |
| 3330 |
% \end{macrocode} |
| 3331 |
% \cs{cctr@lengthb} will be the difference of two successive iterations, and |
| 3332 |
% \cs{cctr@tempoldy}, \cs{cctr@tempy} will be the two last iterations. |
| 3333 |
% |
| 3334 |
% We start with |\cctr@lengthb=5\p@| and |\cctr@tempy=16383| to ensure almost one iteration. |
| 3335 |
% \begin{macrocode} |
| 3336 |
\cctr@lengthb=5\p@ |
| 3337 |
\COPY{16383}{\cctr@tempy} |
| 3338 |
% \end{macrocode} |
| 3339 |
% Successive iterations |
| 3340 |
% \begin{macrocode} |
| 3341 |
\@whilenum \cctr@lengthb>\cctr@epsilon \do {% |
| 3342 |
% \end{macrocode} |
| 3343 |
% Copy the actual approximation to \cs{cctr@tempw} |
| 3344 |
% \begin{macrocode} |
| 3345 |
\COPY{#2}{\cctr@tempw} |
| 3346 |
\COPY{\cctr@tempy}{\cctr@tempoldy} |
| 3347 |
\SIN{\cctr@tempw}{\cctr@tempz} |
| 3348 |
\SUBTRACT{\cctr@tempz}{#1}{\cctr@tempz} |
| 3349 |
\COS{\cctr@tempw}{\cctr@tempy} |
| 3350 |
\DIVIDE{\cctr@tempz}{\cctr@tempy}{\cctr@tempz} |
| 3351 |
\SUBTRACT{\cctr@tempw}{\cctr@tempz}{\cctr@tempz} |
| 3352 |
% \end{macrocode} |
| 3353 |
% Now, \cs{cctr@tempz} is the new approximation. |
| 3354 |
% \begin{macrocode} |
| 3355 |
\COPY{\cctr@tempz}{#2} |
| 3356 |
% \end{macrocode} |
| 3357 |
% Finally, we store in \cs{cctr@lengthb} the difference |
| 3358 |
% of the two last approximations, finishing the loop. |
| 3359 |
% \begin{macrocode} |
| 3360 |
\SUBTRACT{#2}{\cctr@tempw}{\cctr@tempy} |
| 3361 |
\ABSVALUE{\cctr@tempy}{\cctr@tempy} |
| 3362 |
\cctr@lengthb=\cctr@tempy\p@% |
| 3363 |
\ifdim\cctr@tempy\p@=\cctr@tempoldy\p@ |
| 3364 |
\cctr@lengthb=\z@ |
| 3365 |
\fi}\fi\fi\fi\fi\fi\fi\fi\fi\@OUTPUTSOL{#2}} |
| 3366 |
% \end{macrocode} |
| 3367 |
% \end{macro} |
| 3368 |
% \begin{macro}{\ARCCOS} |
| 3369 |
% \cs{ARCCOS}\marg{\#1}\marg{\#2} |
| 3370 |
% defines \textit{\#2} as the arccos of \textit{\#1}, |
| 3371 |
% using the well know relation $\arccos x=\pi/2-\arcsin x$. |
| 3372 |
% \begin{macrocode} |
| 3373 |
\def\ARCCOS#1#2{% |
| 3374 |
\begingroup |
| 3375 |
\ifdim #1\p@ = \z@ |
| 3376 |
\COPY{\numberHALFPI}{#2} |
| 3377 |
\else |
| 3378 |
\ifdim #1\p@ = 1\p@ |
| 3379 |
\COPY{0}{#2} |
| 3380 |
\else |
| 3381 |
\ifdim #1\p@ = -1\p@ |
| 3382 |
\COPY{\numberPI}{#2} |
| 3383 |
\else |
| 3384 |
\ifdim #1\p@ > 1\p@ |
| 3385 |
\let#2\undefined |
| 3386 |
\cctr@Warnbigarccos{#1} |
| 3387 |
\else |
| 3388 |
\ifdim #1\p@ < -1\p@ |
| 3389 |
\let#2\undefined |
| 3390 |
\cctr@Warnbigarccos{#1} |
| 3391 |
\else |
| 3392 |
\ARCSIN{#1}{#2} |
| 3393 |
\SUBTRACT{\numberHALFPI}{#2}{#2} |
| 3394 |
\fi\fi\fi\fi\fi\@OUTPUTSOL{#2}} |
| 3395 |
% \end{macrocode} |
| 3396 |
% \end{macro} |
| 3397 |
% \begin{macro}{\ARCTAN} |
| 3398 |
% \cs{ARCTAN}\marg{\#1}\marg{\#2}. arctan of \textit{\#1}. |
| 3399 |
% \begin{macrocode} |
| 3400 |
\def\ARCTAN#1#2{% |
| 3401 |
\begingroup |
| 3402 |
% \end{macrocode} |
| 3403 |
% If $\left\vert t \right\vert>1$, compute $\arctan x$ using |
| 3404 |
% $\arctan x=sign(x)\pi/2-\arctan(1/x)$. |
| 3405 |
% \begin{macrocode} |
| 3406 |
\ifdim#1\p@<-1\p@ |
| 3407 |
\DIVIDE{1}{#1}{\cctr@tempb} |
| 3408 |
\ARCTAN{\cctr@tempb}{#2} |
| 3409 |
\SUBTRACT{-\numberHALFPI}{#2}{#2} |
| 3410 |
\else |
| 3411 |
\ifdim#1\p@>1\p@ |
| 3412 |
\DIVIDE{1}{#1}{\cctr@tempb} |
| 3413 |
\ARCTAN{\cctr@tempb}{#2} |
| 3414 |
\SUBTRACT{\numberHALFPI}{#2}{#2} |
| 3415 |
\else |
| 3416 |
% \end{macrocode} |
| 3417 |
% For $-1\leq x\leq 1$ call \cs{@BASICARCTAN}. |
| 3418 |
% \begin{macrocode} |
| 3419 |
\@BASICARCTAN{#1}{#2} |
| 3420 |
\fi |
| 3421 |
\fi\@OUTPUTSOL{#2}} |
| 3422 |
% \end{macrocode} |
| 3423 |
% \end{macro} |
| 3424 |
% \begin{macro}{\@BASICARCTAN} |
| 3425 |
% \cs{@BASICARCTAN}\marg{\#1}\marg{\#2} applies this approximation: |
| 3426 |
% \[ |
| 3427 |
% \arctan x = \frac{x}{ |
| 3428 |
% 1+\displaystyle\frac{x^2}{ |
| 3429 |
% 3+\displaystyle\frac{(2x)^2}{ |
| 3430 |
% 5+\displaystyle\frac{(3x)^2}{ |
| 3431 |
% 7+\displaystyle\frac{(4x)^2}{ |
| 3432 |
% 9+\cdots |
| 3433 |
% } |
| 3434 |
% } |
| 3435 |
% } |
| 3436 |
% } |
| 3437 |
% } |
| 3438 |
% \] |
| 3439 |
% \begin{macrocode} |
| 3440 |
\def\@BASICARCTAN#1#2{% |
| 3441 |
\begingroup |
| 3442 |
% \end{macrocode} |
| 3443 |
% Exact arctan of zero |
| 3444 |
% \begin{macrocode} |
| 3445 |
\ifdim#1\p@=\z@ \COPY{0}{#2} |
| 3446 |
\else |
| 3447 |
% \end{macrocode} |
| 3448 |
% Compute the continued fraction. |
| 3449 |
% \begin{macrocode} |
| 3450 |
\SQUARE{#1}{\cctr@tempa} |
| 3451 |
\MULTIPLY{64}{\cctr@tempa}{#2} |
| 3452 |
\ADD{15}{#2}{#2} |
| 3453 |
\DIVIDE{\cctr@tempa}{#2}{#2} |
| 3454 |
\MULTIPLY{49}{#2}{#2} |
| 3455 |
\ADD{13}{#2}{#2} |
| 3456 |
\DIVIDE{\cctr@tempa}{#2}{#2} |
| 3457 |
\MULTIPLY{36}{#2}{#2} |
| 3458 |
\ADD{11}{#2}{#2} |
| 3459 |
\DIVIDE{\cctr@tempa}{#2}{#2} |
| 3460 |
\MULTIPLY{25}{#2}{#2} |
| 3461 |
\ADD{9}{#2}{#2} |
| 3462 |
\DIVIDE{\cctr@tempa}{#2}{#2} |
| 3463 |
\MULTIPLY{16}{#2}{#2} |
| 3464 |
\ADD{7}{#2}{#2} |
| 3465 |
\DIVIDE{\cctr@tempa}{#2}{#2} |
| 3466 |
\MULTIPLY{9}{#2}{#2} |
| 3467 |
\ADD{5}{#2}{#2} |
| 3468 |
\DIVIDE{\cctr@tempa}{#2}{#2} |
| 3469 |
\MULTIPLY{4}{#2}{#2} |
| 3470 |
\ADD{3}{#2}{#2} |
| 3471 |
\DIVIDE{\cctr@tempa}{#2}{#2} |
| 3472 |
\ADD{1}{#2}{#2} |
| 3473 |
\DIVIDE{#1}{#2}{#2} |
| 3474 |
\fi\@OUTPUTSOL{#2}} |
| 3475 |
% \end{macrocode} |
| 3476 |
% \end{macro} |
| 3477 |
% \begin{macro}{\ARCCOT} |
| 3478 |
% \cs{ARCCOT}\marg{\#1}\marg{\#2} |
| 3479 |
% defines \textit{\#2} as the arccot of \textit{\#1}, |
| 3480 |
% using the well know relation $\operatorname{arccot} x=\pi/2-\arctan x$. |
| 3481 |
% \begin{macrocode} |
| 3482 |
\def\ARCCOT#1#2{% |
| 3483 |
\begingroup |
| 3484 |
\ARCTAN{#1}{#2} |
| 3485 |
\SUBTRACT{\numberHALFPI}{#2}{#2} |
| 3486 |
\@OUTPUTSOL{#2}} |
| 3487 |
% \end{macrocode} |
| 3488 |
% \end{macro} |
| 3489 |
% \paragraph*{Inverse hyperbolic functions} |
| 3490 |
% \changes{v2.0}{2014/02/13}{New commands: \cs{ARSINH}, |
| 3491 |
% \cs{ARCOSH}, \cs{ARTANH}, |
| 3492 |
% \cs{ARCOTH}} |
| 3493 |
% \begin{macro}{\ARSINH} |
| 3494 |
% \cs{ARSINH}\marg{\#1}\marg{\#2}. Inverse hyperbolic sine of \textit{\#1}: |
| 3495 |
% $\arsinh x = \log\left(x+\sqrt{1+x^2}\right)$ |
| 3496 |
% \begin{macrocode} |
| 3497 |
\def\ARSINH#1#2{% |
| 3498 |
\begingroup |
| 3499 |
\SQUARE{#1}{\cctr@tempa} |
| 3500 |
\ADD{1}{\cctr@tempa}{\cctr@tempa} |
| 3501 |
\SQRT{\cctr@tempa}{\cctr@tempb} |
| 3502 |
\ADD{#1}{\cctr@tempb}{\cctr@tempb} |
| 3503 |
\LOG\cctr@tempb{#2} |
| 3504 |
\@OUTPUTSOL{#2}} |
| 3505 |
% \end{macrocode} |
| 3506 |
% \end{macro} |
| 3507 |
|
| 3508 |
% \begin{macro}{\ARCOSH} |
| 3509 |
% \cs{ARCOSH}\marg{\#1}\marg{\#2}. Inverse hyperbolic sine of \textit{\#1}: |
| 3510 |
% $\arcosh x = \log\left(x+\sqrt{x^2-1}\right)$ |
| 3511 |
% \begin{macrocode} |
| 3512 |
\def\ARCOSH#1#2{% |
| 3513 |
\begingroup |
| 3514 |
% \end{macrocode} |
| 3515 |
% If $x<1$, this function is no defined |
| 3516 |
% \begin{macrocode} |
| 3517 |
\ifdim#1\p@<1\p@ |
| 3518 |
\let#2\undefined |
| 3519 |
\cctr@Warnsmallarcosh{#1} |
| 3520 |
\else |
| 3521 |
\SQUARE{#1}{\cctr@tempa} |
| 3522 |
\SUBTRACT{\cctr@tempa}{1}{\cctr@tempa} |
| 3523 |
\SQRT{\cctr@tempa}{\cctr@tempb} |
| 3524 |
\ADD{#1}{\cctr@tempb}{\cctr@tempb} |
| 3525 |
\LOG\cctr@tempb{#2} |
| 3526 |
\fi\@OUTPUTSOL{#2}} |
| 3527 |
% \end{macrocode} |
| 3528 |
% \end{macro} |
| 3529 |
% \begin{macro}{\ARTANH} |
| 3530 |
% \cs{ARTANH}\marg{\#1}\marg{\#2}. Inverse hyperbolic tangent of \textit{\#1}: |
| 3531 |
% $\artanh x = \frac12\log \left((1+x)-\log(1-x)\right)$ |
| 3532 |
% \begin{macrocode} |
| 3533 |
\def\ARTANH#1#2{% |
| 3534 |
\begingroup |
| 3535 |
% \end{macrocode} |
| 3536 |
% If $\left\vert x \right\vert\geq1$, this function is no defined |
| 3537 |
% \begin{macrocode} |
| 3538 |
\ifdim#1\p@<-0.99998\p@ |
| 3539 |
\let#2\undefined |
| 3540 |
\cctr@Warnbigartanh{#1} |
| 3541 |
\else |
| 3542 |
\ifdim#1\p@>0.99998\p@ |
| 3543 |
\let#2\undefined |
| 3544 |
\cctr@Warnbigartanh{#1} |
| 3545 |
\else |
| 3546 |
\COPY{#1}{\cctr@tempa} |
| 3547 |
\ADD1\cctr@tempa\cctr@tempb |
| 3548 |
\SUBTRACT1\cctr@tempa\cctr@tempc |
| 3549 |
\LOG\cctr@tempb\cctr@tempB |
| 3550 |
\LOG\cctr@tempc\cctr@tempC |
| 3551 |
\SUBTRACT\cctr@tempB\cctr@tempC{#2} |
| 3552 |
\DIVIDE{#2}{2}{#2} |
| 3553 |
\fi |
| 3554 |
\fi\@OUTPUTSOL{#2}} |
| 3555 |
% \end{macrocode} |
| 3556 |
% \end{macro} |
| 3557 |
% \begin{macro}{\ARCOTH} |
| 3558 |
% \cs{ARCOTH}\marg{\#1}\marg{\#2}. Inverse hyperbolic cotangent of \textit{\#1}: |
| 3559 |
% |
| 3560 |
% $\arcoth x = sign(x)\frac12\log \left((x+1)-\log(x-1)\right)$ |
| 3561 |
% \begin{macrocode} |
| 3562 |
\def\ARCOTH#1#2{% |
| 3563 |
\begingroup |
| 3564 |
% \end{macrocode} |
| 3565 |
% If $\left\vert x \right\vert\leq1$, this function is no defined |
| 3566 |
% \begin{macrocode} |
| 3567 |
\ifdim#1\p@>-0.99998\p@ |
| 3568 |
\ifdim#1\p@<0.99998\p@ |
| 3569 |
\let#2\undefined |
| 3570 |
\cctr@Warnsmallarcoth{#1} |
| 3571 |
\else |
| 3572 |
\ifdim#1\p@>\p@ |
| 3573 |
% \end{macrocode} |
| 3574 |
% For $x>1$, calcule $\arcoth x = \frac12\log \left((x+1)-\log(x-1)\right)$ |
| 3575 |
% \begin{macrocode} |
| 3576 |
\COPY{#1}{\cctr@tempa} |
| 3577 |
\ADD1\cctr@tempa\cctr@tempb |
| 3578 |
\SUBTRACT\cctr@tempa1\cctr@tempc |
| 3579 |
\LOG\cctr@tempb\cctr@tempB |
| 3580 |
\LOG\cctr@tempc\cctr@tempC |
| 3581 |
\SUBTRACT\cctr@tempB\cctr@tempC{#2} |
| 3582 |
\DIVIDE{#2}{2}{#2} |
| 3583 |
\else |
| 3584 |
\fi |
| 3585 |
\fi |
| 3586 |
\else |
| 3587 |
% \end{macrocode} |
| 3588 |
% For $x<-1$, calcule $-\artanh(-x)$ |
| 3589 |
% \begin{macrocode} |
| 3590 |
\MULTIPLY{-1}{#1}{\cctr@tempa} |
| 3591 |
\ARCOTH{\cctr@tempa}{#2} |
| 3592 |
\COPY{-#2}{#2} |
| 3593 |
\fi\@OUTPUTSOL{#2}} |
| 3594 |
% \end{macrocode} |
| 3595 |
% \end{macro} |
| 3596 |
% |
| 3597 |
% \subsection{Matrix arithmetics} |
| 3598 |
% \subsubsection*{Vector operations} |
| 3599 |
% \begin{macro}{\VECTORSIZE} |
| 3600 |
% The \emph{size} of a vector is $2$ or $3$. |
| 3601 |
% \cs{VECTORSIZE}\parg{\#1}\marg{\#2} stores in \textit{\#2} the |
| 3602 |
% size of \parg{\#1}. |
| 3603 |
% |
| 3604 |
% Almost all vector commands needs to know the vector size. |
| 3605 |
% \begin{macrocode} |
| 3606 |
\def\VECTORSIZE(#1)#2{\expandafter\@VECTORSIZE(#1,,){#2}} |
| 3607 |
\def\@VECTORSIZE(#1,#2,#3,#4)#5{\ifx$#3$\COPY{2}{#5} |
| 3608 |
\else\COPY{3}{#5}\fi\ignorespaces} |
| 3609 |
% \end{macrocode} |
| 3610 |
% \end{macro} |
| 3611 |
% \begin{macro}{\VECTORCOPY} |
| 3612 |
% \cs{VECTORCOPY}\parg{\#1,\#2}\parg{\#3,\#4} |
| 3613 |
% stores \textit{\#1} and \textit{\#2} |
| 3614 |
% in \textit{\#3} and \textit{\#4}. |
| 3615 |
% |
| 3616 |
% \noindent\cs{VECTORCOPY}\parg{\#1,\#2,\#3}\parg{\#4,\#5\#6} |
| 3617 |
% stores \textit{\#1}, \textit{\#2} and \textit{\#3} |
| 3618 |
% in \textit{\#4} and \textit{\#5} and \textit{\#6}. |
| 3619 |
% \begin{macrocode} |
| 3620 |
\def\@@VECTORCOPY(#1,#2)(#3,#4){% |
| 3621 |
\COPY{#1}{#3}\COPY{#2}{#4}} |
| 3622 |
|
| 3623 |
\def\@@@VECTORCOPY(#1,#2,#3)(#4,#5,#6){% |
| 3624 |
\COPY{#1}{#4}\COPY{#2}{#5}\COPY{#3}{#6}} |
| 3625 |
|
| 3626 |
\def\VECTORCOPY(#1)(#2){% |
| 3627 |
\VECTORSIZE(#1){\cctr@size} |
| 3628 |
\ifnum\cctr@size=2 |
| 3629 |
\@@VECTORCOPY(#1)(#2) |
| 3630 |
\else \@@@VECTORCOPY(#1)(#2)\fi} |
| 3631 |
% \end{macrocode} |
| 3632 |
% \end{macro} |
| 3633 |
% \begin{macro}{\VECTORGLOBALCOPY} |
| 3634 |
% \cs{VECTORGLOBALCOPY} is the global version of \cs{VECTORCOPY} |
| 3635 |
% \begin{macrocode} |
| 3636 |
\def\@@VECTORGLOBALCOPY(#1,#2)(#3,#4){% |
| 3637 |
\GLOBALCOPY{#1}{#3}\GLOBALCOPY{#2}{#4}} |
| 3638 |
|
| 3639 |
\def\@@@VECTORGLOBALCOPY(#1,#2,#3)(#4,#5,#6){% |
| 3640 |
\GLOBALCOPY{#1}{#4}\GLOBALCOPY{#2}{#5}\GLOBALCOPY{#3}{#6}} |
| 3641 |
|
| 3642 |
\def\VECTORGLOBALCOPY(#1)(#2){% |
| 3643 |
\VECTORSIZE(#1){\cctr@size} |
| 3644 |
\ifnum\cctr@size=2 |
| 3645 |
\@@VECTORGLOBALCOPY(#1)(#2) |
| 3646 |
\else \@@@VECTORGLOBALCOPY(#1)(#2)\fi} |
| 3647 |
% \end{macrocode} |
| 3648 |
% \end{macro} |
| 3649 |
% \begin{macro}{\@OUTPUTVECTOR} |
| 3650 |
% \begin{macrocode} |
| 3651 |
\def\@@OUTPUTVECTOR(#1,#2){% |
| 3652 |
\VECTORGLOBALCOPY(#1,#2)(\cctr@outa,\cctr@outb) |
| 3653 |
\endgroup\VECTORCOPY(\cctr@outa,\cctr@outb)(#1,#2)} |
| 3654 |
|
| 3655 |
\def\@@@OUTPUTVECTOR(#1,#2,#3){% |
| 3656 |
\VECTORGLOBALCOPY(#1,#2,#3)(\cctr@outa,\cctr@outb,\cctr@outc) |
| 3657 |
\endgroup\VECTORCOPY(\cctr@outa,\cctr@outb,\cctr@outc)(#1,#2,#3)} |
| 3658 |
|
| 3659 |
\def\@OUTPUTVECTOR(#1){\VECTORSIZE(#1){\cctr@size} |
| 3660 |
\ifnum\cctr@size=2 |
| 3661 |
\@@OUTPUTVECTOR(#1) |
| 3662 |
\else \@@@OUTPUTVECTOR(#1)\fi} |
| 3663 |
% \end{macrocode} |
| 3664 |
% \end{macro} |
| 3665 |
% \begin{macro}{\SCALARPRODUCT} |
| 3666 |
% Scalar product of two vectors. |
| 3667 |
% \begin{macrocode} |
| 3668 |
\def\@@SCALARPRODUCT(#1,#2)(#3,#4)#5{% |
| 3669 |
\MULTIPLY{#1}{#3}{#5} |
| 3670 |
\MULTIPLY{#2}{#4}\cctr@tempa |
| 3671 |
\ADD{#5}{\cctr@tempa}{#5}} |
| 3672 |
|
| 3673 |
\def\@@@SCALARPRODUCT(#1,#2,#3)(#4,#5,#6)#7{% |
| 3674 |
\MULTIPLY{#1}{#4}{#7} |
| 3675 |
\MULTIPLY{#2}{#5}\cctr@tempa |
| 3676 |
\ADD{#7}{\cctr@tempa}{#7} |
| 3677 |
\MULTIPLY{#3}{#6}\cctr@tempa |
| 3678 |
\ADD{#7}{\cctr@tempa}{#7}} |
| 3679 |
|
| 3680 |
\def\SCALARPRODUCT(#1)(#2)#3{% |
| 3681 |
\begingroup |
| 3682 |
\VECTORSIZE(#1){\cctr@size} |
| 3683 |
\ifnum\cctr@size=2 |
| 3684 |
\@@SCALARPRODUCT(#1)(#2){#3} |
| 3685 |
\else \@@@SCALARPRODUCT(#1)(#2){#3}\fi\@OUTPUTSOL{#3}} |
| 3686 |
% \end{macrocode} |
| 3687 |
% \end{macro} |
| 3688 |
|
| 3689 |
% \changes{v2.0}{2013/07/10}{New commands: \cs{DOTPRODUCT}, |
| 3690 |
% \cs{VECTORPRODUCT}, \cs{CROSSPRODUCT}} |
| 3691 |
% \begin{macro}{\DOTPRODUCT} |
| 3692 |
% \cs{DOTPRODUCT} is an alias for \cs{SCALARPRODUCT}. |
| 3693 |
% \begin{macrocode} |
| 3694 |
\let\DOTPRODUCT\SCALARPRODUCT |
| 3695 |
% \end{macrocode} |
| 3696 |
% \end{macro} |
| 3697 |
|
| 3698 |
% \begin{macro}{\VECTORPRODUCT} |
| 3699 |
% Vector product of two (three dimensional) vectors. |
| 3700 |
% \begin{macrocode} |
| 3701 |
\def\@@VECTORPRODUCT(#1)(#2)(#3,#4){% |
| 3702 |
\let#3\undefined |
| 3703 |
\let#4\undefined |
| 3704 |
\cctr@Warncrossprod(#1)(#2)} |
| 3705 |
|
| 3706 |
\def\@@@VECTORPRODUCT(#1,#2,#3)(#4,#5,#6)(#7,#8,#9){% |
| 3707 |
\DETERMINANT(#2,#3;#5,#6){#7} |
| 3708 |
\DETERMINANT(#3,#1;#6,#4){#8} |
| 3709 |
\DETERMINANT(#1,#2;#4,#5){#9}} |
| 3710 |
|
| 3711 |
\def\VECTORPRODUCT(#1)(#2)(#3){% |
| 3712 |
\begingroup |
| 3713 |
\VECTORSIZE(#1){\cctr@size} |
| 3714 |
\ifnum\cctr@size=2 |
| 3715 |
\@@VECTORPRODUCT(#1)(#2)(#3) |
| 3716 |
\else \@@@VECTORPRODUCT(#1)(#2)(#3)\fi\@OUTPUTSOL{#3}} |
| 3717 |
% \end{macrocode} |
| 3718 |
% \end{macro} |
| 3719 |
|
| 3720 |
% \begin{macro}{\CROSSPRODUCT} |
| 3721 |
% \cs{CROSSPRODUCT} is an alias for \cs{VECTORPRODUCT}. |
| 3722 |
% \begin{macrocode} |
| 3723 |
\let\CROSSPRODUCT\VECTORPRODUCT |
| 3724 |
% \end{macrocode} |
| 3725 |
% \end{macro} |
| 3726 |
|
| 3727 |
% \begin{macro}{\VECTORADD} |
| 3728 |
% Sum of two vectors. |
| 3729 |
% \begin{macrocode} |
| 3730 |
\def\@@VECTORADD(#1,#2)(#3,#4)(#5,#6){% |
| 3731 |
\ADD{#1}{#3}{#5} |
| 3732 |
\ADD{#2}{#4}{#6}} |
| 3733 |
|
| 3734 |
\def\@@@VECTORADD(#1,#2,#3)(#4,#5,#6)(#7,#8,#9){% |
| 3735 |
\ADD{#1}{#4}{#7} |
| 3736 |
\ADD{#2}{#5}{#8} |
| 3737 |
\ADD{#3}{#6}{#9}} |
| 3738 |
|
| 3739 |
\def\VECTORADD(#1)(#2)(#3){% |
| 3740 |
\VECTORSIZE(#1){\cctr@size} |
| 3741 |
\ifnum\cctr@size=2 |
| 3742 |
\@@VECTORADD(#1)(#2)(#3) |
| 3743 |
\else \@@@VECTORADD(#1)(#2)(#3)\fi} |
| 3744 |
% \end{macrocode} |
| 3745 |
% \end{macro} |
| 3746 |
% \begin{macro}{\VECTORSUB} |
| 3747 |
% Difference of two vectors. |
| 3748 |
% \begin{macrocode} |
| 3749 |
\def\@@VECTORSUB(#1,#2)(#3,#4)(#5,#6){% |
| 3750 |
\VECTORADD(#1,#2)(-#3,-#4)(#5,#6)} |
| 3751 |
|
| 3752 |
\def\@@@VECTORSUB(#1,#2,#3)(#4,#5,#6)(#7,#8,#9){% |
| 3753 |
\VECTORADD(#1,#2,#3)(-#4,-#5,-#6)(#7,#8,#9)} |
| 3754 |
|
| 3755 |
\def\VECTORSUB(#1)(#2)(#3){% |
| 3756 |
\VECTORSIZE(#1){\cctr@size} |
| 3757 |
\ifnum\cctr@size=2 |
| 3758 |
\@@VECTORSUB(#1)(#2)(#3) |
| 3759 |
\else \@@@VECTORSUB(#1)(#2)(#3)\fi} |
| 3760 |
% \end{macrocode} |
| 3761 |
% \end{macro} |
| 3762 |
% \begin{macro}{\VECTORABSVALUE} |
| 3763 |
% Absolute value of a each entry of a vector. |
| 3764 |
% \begin{macrocode} |
| 3765 |
\def\@@VECTORABSVALUE(#1,#2)(#3,#4){% |
| 3766 |
\ABSVALUE{#1}{#3}\ABSVALUE{#2}{#4}} |
| 3767 |
|
| 3768 |
\def\@@@VECTORABSVALUE(#1,#2,#3)(#4,#5,#6){% |
| 3769 |
\ABSVALUE{#1}{#4}\ABSVALUE{#2}{#5}\ABSVALUE{#3}{#6}} |
| 3770 |
|
| 3771 |
\def\VECTORABSVALUE(#1)(#2){% |
| 3772 |
\VECTORSIZE(#1){\cctr@size} |
| 3773 |
\ifnum\cctr@size=2 |
| 3774 |
\@@VECTORABSVALUE(#1)(#2) |
| 3775 |
\else \@@@VECTORABSVALUE(#1)(#2)\fi} |
| 3776 |
% \end{macrocode} |
| 3777 |
% \end{macro} |
| 3778 |
% \begin{macro}{\SCALARVECTORPRODUCT} |
| 3779 |
% Scalar-vector product. |
| 3780 |
% \begin{macrocode} |
| 3781 |
\def\@@SCALARVECTORPRODUCT#1(#2,#3)(#4,#5){% |
| 3782 |
\MULTIPLY{#1}{#2}{#4} |
| 3783 |
\MULTIPLY{#1}{#3}{#5}} |
| 3784 |
|
| 3785 |
\def\@@@SCALARVECTORPRODUCT#1(#2,#3,#4)(#5,#6,#7){% |
| 3786 |
\MULTIPLY{#1}{#2}{#5} |
| 3787 |
\MULTIPLY{#1}{#3}{#6} |
| 3788 |
\MULTIPLY{#1}{#4}{#7}} |
| 3789 |
|
| 3790 |
\def\SCALARVECTORPRODUCT#1(#2)(#3){% |
| 3791 |
\VECTORSIZE(#2){\cctr@size} |
| 3792 |
\ifnum\cctr@size=2 |
| 3793 |
\@@SCALARVECTORPRODUCT{#1}(#2)(#3) |
| 3794 |
\else \@@@SCALARVECTORPRODUCT{#1}(#2)(#3)\fi} |
| 3795 |
% \end{macrocode} |
| 3796 |
% \end{macro} |
| 3797 |
% \begin{macro}{\VECTORNORM} |
| 3798 |
% Euclidean norm of a vector. |
| 3799 |
% \begin{macrocode} |
| 3800 |
\def\VECTORNORM(#1)#2{% |
| 3801 |
\begingroup |
| 3802 |
\SCALARPRODUCT(#1)(#1){\cctr@temp} |
| 3803 |
\SQUAREROOT{\cctr@temp}{#2}\@OUTPUTSOL{#2}} |
| 3804 |
% \end{macrocode} |
| 3805 |
% \end{macro} |
| 3806 |
% \begin{macro}{\UNITVECTOR} |
| 3807 |
% Unitary vector parallel to a given vector. |
| 3808 |
% \begin{macrocode} |
| 3809 |
\def\UNITVECTOR(#1)(#2){% |
| 3810 |
\begingroup |
| 3811 |
\VECTORNORM(#1){\cctr@tempa} |
| 3812 |
\DIVIDE{1}{\cctr@tempa}{\cctr@tempa} |
| 3813 |
\SCALARVECTORPRODUCT{\cctr@tempa}(#1)(#2)\@OUTPUTVECTOR(#2)} |
| 3814 |
% \end{macrocode} |
| 3815 |
% \end{macro} |
| 3816 |
% \begin{macro}{\TWOVECTORSANGLE} |
| 3817 |
% Angle between two vectors. |
| 3818 |
% \begin{macrocode} |
| 3819 |
\def\TWOVECTORSANGLE(#1)(#2)#3{% |
| 3820 |
\begingroup |
| 3821 |
\VECTORNORM(#1){\cctr@tempa} |
| 3822 |
\VECTORNORM(#2){\cctr@tempb} |
| 3823 |
\SCALARPRODUCT(#1)(#2){\cctr@tempc} |
| 3824 |
\ifdim \cctr@tempa\p@ =\z@ |
| 3825 |
\let#3\undefined |
| 3826 |
\cctr@Warnnoangle(#1)(#2) |
| 3827 |
\else |
| 3828 |
\ifdim \cctr@tempb\p@ =\z@ |
| 3829 |
\let#3\undefined |
| 3830 |
\cctr@Warnnoangle(#1)(#2) |
| 3831 |
\else |
| 3832 |
\DIVIDE{\cctr@tempc}{\cctr@tempa}{\cctr@tempc} |
| 3833 |
\DIVIDE{\cctr@tempc}{\cctr@tempb}{\cctr@tempc} |
| 3834 |
\ARCCOS{\cctr@tempc}{#3} |
| 3835 |
\fi\fi\@OUTPUTSOL{#3}} |
| 3836 |
% \end{macrocode} |
| 3837 |
% \end{macro} |
| 3838 |
% \subsubsection*{Matrix operations} |
| 3839 |
% Here, we need to define some internal macros |
| 3840 |
% to simulate commands with more than nine arguments. |
| 3841 |
% \begin{macro}{\@TDMATRIXCOPY} |
| 3842 |
% This command copies a $3\times3$ matrix to the commands |
| 3843 |
% \cs{cctr@solAA}, \cs{cctr@solAB}, \dots, \cs{cctr@solCC}. |
| 3844 |
% \begin{macrocode} |
| 3845 |
\def\@TDMATRIXCOPY(#1,#2,#3;#4,#5,#6;#7,#8,#9){% |
| 3846 |
\COPY{#1}{\cctr@solAA} |
| 3847 |
\COPY{#2}{\cctr@solAB} |
| 3848 |
\COPY{#3}{\cctr@solAC} |
| 3849 |
\COPY{#4}{\cctr@solBA} |
| 3850 |
\COPY{#5}{\cctr@solBB} |
| 3851 |
\COPY{#6}{\cctr@solBC} |
| 3852 |
\COPY{#7}{\cctr@solCA} |
| 3853 |
\COPY{#8}{\cctr@solCB} |
| 3854 |
\COPY{#9}{\cctr@solCC}} |
| 3855 |
% \end{macrocode} |
| 3856 |
% \end{macro} |
| 3857 |
% \begin{macro}{\@TDMATRIXSOL} |
| 3858 |
% This command copies the commands |
| 3859 |
% \cs{cctr@solAA}, \cs{cctr@solAB}, \dots, \cs{cctr@solCC} |
| 3860 |
% to a $3\times3$ matrix. |
| 3861 |
% This macro is used to store the results of a matrix operation. |
| 3862 |
% \begin{macrocode} |
| 3863 |
\def\@TDMATRIXSOL(#1,#2,#3;#4,#5,#6;#7,#8,#9){% |
| 3864 |
\COPY{\cctr@solAA}{#1} |
| 3865 |
\COPY{\cctr@solAB}{#2} |
| 3866 |
\COPY{\cctr@solAC}{#3} |
| 3867 |
\COPY{\cctr@solBA}{#4} |
| 3868 |
\COPY{\cctr@solBB}{#5} |
| 3869 |
\COPY{\cctr@solBC}{#6} |
| 3870 |
\COPY{\cctr@solCA}{#7} |
| 3871 |
\COPY{\cctr@solCB}{#8} |
| 3872 |
\COPY{\cctr@solCC}{#9}} |
| 3873 |
% \end{macrocode} |
| 3874 |
% \end{macro} |
| 3875 |
% \begin{macro}{\@TDMATRIXGLOBALSOL} |
| 3876 |
% |
| 3877 |
% \begin{macrocode} |
| 3878 |
\def\@TDMATRIXGLOBALSOL(#1,#2,#3;#4,#5,#6;#7,#8,#9){% |
| 3879 |
\GLOBALCOPY{\cctr@solAA}{#1} |
| 3880 |
\GLOBALCOPY{\cctr@solAB}{#2} |
| 3881 |
\GLOBALCOPY{\cctr@solAC}{#3} |
| 3882 |
\GLOBALCOPY{\cctr@solBA}{#4} |
| 3883 |
\GLOBALCOPY{\cctr@solBB}{#5} |
| 3884 |
\GLOBALCOPY{\cctr@solBC}{#6} |
| 3885 |
\GLOBALCOPY{\cctr@solCA}{#7} |
| 3886 |
\GLOBALCOPY{\cctr@solCB}{#8} |
| 3887 |
\GLOBALCOPY{\cctr@solCC}{#9}} |
| 3888 |
% \end{macrocode} |
| 3889 |
% \end{macro} |
| 3890 |
% \begin{macro}{\@TDMATRIXNOSOL} |
| 3891 |
% This command undefines a $3\times3$ matrix |
| 3892 |
% when a matrix problem has no solution. |
| 3893 |
% \begin{macrocode} |
| 3894 |
\def\@TDMATRIXNOSOL(#1,#2,#3;#4,#5,#6;#7,#8,#9){% |
| 3895 |
\let#1\undefined |
| 3896 |
\let#2\undefined |
| 3897 |
\let#3\undefined |
| 3898 |
\let#4\undefined |
| 3899 |
\let#5\undefined |
| 3900 |
\let#6\undefined |
| 3901 |
\let#7\undefined |
| 3902 |
\let#8\undefined |
| 3903 |
\let#9\undefined |
| 3904 |
} |
| 3905 |
% \end{macrocode} |
| 3906 |
% \end{macro} |
| 3907 |
% \begin{macro}{\@@TDMATRIXSOL} |
| 3908 |
% This command stores or undefines the solution. |
| 3909 |
% \begin{macrocode} |
| 3910 |
\def\@@TDMATRIXSOL(#1,#2,#3;#4,#5,#6;#7,#8,#9){% |
| 3911 |
\ifx\cctr@solAA\undefined |
| 3912 |
\@TDMATRIXNOSOL(#1,#2,#3;#4,#5,#6;#7,#8,#9)% |
| 3913 |
\else |
| 3914 |
\@TDMATRIXSOL(#1,#2,#3;#4,#5,#6;#7,#8,#9)\fi} |
| 3915 |
% \end{macrocode} |
| 3916 |
% \end{macro} |
| 3917 |
% \begin{macro}{\@NUMBERSOL} |
| 3918 |
% This command stores the scalar solution of a matrix operation. |
| 3919 |
% \begin{macrocode} |
| 3920 |
\def\@NUMBERSOL#1{\COPY{\cctr@sol}{#1}} |
| 3921 |
% \end{macrocode} |
| 3922 |
% \end{macro} |
| 3923 |
% \begin{macro}{\MATRIXSIZE} |
| 3924 |
% Size ($2$ or $3$) of a matrix. |
| 3925 |
% \begin{macrocode} |
| 3926 |
\def\MATRIXSIZE(#1)#2{\expandafter\@MATRIXSIZE(#1;;){#2}} |
| 3927 |
\def\@MATRIXSIZE(#1;#2;#3;#4)#5{\ifx$#3$\COPY{2}{#5} |
| 3928 |
\else\COPY{3}{#5}\fi\ignorespaces} |
| 3929 |
% \end{macrocode} |
| 3930 |
% \end{macro} |
| 3931 |
% \begin{macro}{\MATRIXCOPY} |
| 3932 |
% Store a matrix in 4 or 9 commands. |
| 3933 |
% \begin{macrocode} |
| 3934 |
\def\@@MATRIXCOPY(#1,#2;#3,#4)(#5,#6;#7,#8){% |
| 3935 |
\COPY{#1}{#5}\COPY{#2}{#6}\COPY{#3}{#7}\COPY{#4}{#8}} |
| 3936 |
|
| 3937 |
\def\@@@MATRIXCOPY(#1,#2,#3;#4,#5,#6;#7,#8,#9){% |
| 3938 |
\@TDMATRIXCOPY(#1,#2,#3;#4,#5,#6;#7,#8,#9) |
| 3939 |
\@TDMATRIXSOL} |
| 3940 |
|
| 3941 |
\def\MATRIXCOPY(#1)(#2){% |
| 3942 |
\MATRIXSIZE(#1){\cctr@size} |
| 3943 |
\ifnum\cctr@size=2 |
| 3944 |
\@@MATRIXCOPY(#1)(#2) |
| 3945 |
\else \@@@MATRIXCOPY(#1)(#2)\fi} |
| 3946 |
% \end{macrocode} |
| 3947 |
% \end{macro} |
| 3948 |
% \begin{macro}{\MATRIXGLOBALCOPY} |
| 3949 |
% Global version of \cs{MATRIXCOPY}. |
| 3950 |
% \begin{macrocode} |
| 3951 |
\def\@@MATRIXGLOBALCOPY(#1,#2;#3,#4)(#5,#6;#7,#8){% |
| 3952 |
\GLOBALCOPY{#1}{#5}\GLOBALCOPY{#2}{#6}\GLOBALCOPY{#3}{#7}\GLOBALCOPY{#4}{#8}} |
| 3953 |
|
| 3954 |
\def\@@@MATRIXGLOBALCOPY(#1,#2,#3;#4,#5,#6;#7,#8,#9){% |
| 3955 |
\@TDMATRIXCOPY(#1,#2,#3;#4,#5,#6;#7,#8,#9) |
| 3956 |
\@TDMATRIXGLOBALSOL} |
| 3957 |
|
| 3958 |
\def\MATRIXGLOBALCOPY(#1)(#2){% |
| 3959 |
\MATRIXSIZE(#1){\cctr@size} |
| 3960 |
\ifnum\cctr@size=2 |
| 3961 |
\@@MATRIXGLOBALCOPY(#1)(#2) |
| 3962 |
\else \@@@MATRIXGLOBALCOPY(#1)(#2)\fi} |
| 3963 |
% \end{macrocode} |
| 3964 |
% \end{macro} |
| 3965 |
% \begin{macro}{\@OUTPUTMATRIX} |
| 3966 |
% \begin{macrocode} |
| 3967 |
\def\@@OUTPUTMATRIX(#1,#2;#3,#4){% |
| 3968 |
\MATRIXGLOBALCOPY(#1,#2;#3,#4)(\cctr@outa,\cctr@outb;\cctr@outc,\cctr@outd) |
| 3969 |
\endgroup\MATRIXCOPY(\cctr@outa,\cctr@outb;\cctr@outc,\cctr@outd)(#1,#2;#3,#4)} |
| 3970 |
|
| 3971 |
\def\@@@OUTPUTMATRIX(#1,#2,#3;#4,#5,#6;#7,#8,#9){% |
| 3972 |
\MATRIXGLOBALCOPY(#1,#2,#3;#4,#5,#6;#7,#8,#9)(% |
| 3973 |
\cctr@outa,\cctr@outb,\cctr@outc; |
| 3974 |
\cctr@outd,\cctr@oute,\cctr@outf; |
| 3975 |
\cctr@outg,\cctr@outh,\cctr@outi) |
| 3976 |
\endgroup\MATRIXCOPY(% |
| 3977 |
\cctr@outa,\cctr@outb,\cctr@outc; |
| 3978 |
\cctr@outd,\cctr@oute,\cctr@outf; |
| 3979 |
\cctr@outg,\cctr@outh,\cctr@outi)(#1,#2,#3;#4,#5,#6;#7,#8,#9)} |
| 3980 |
|
| 3981 |
\def\@OUTPUTMATRIX(#1){\MATRIXSIZE(#1){\cctr@size} |
| 3982 |
\ifnum\cctr@size=2 |
| 3983 |
\@@OUTPUTMATRIX(#1) |
| 3984 |
\else \@@@OUTPUTMATRIX(#1)\fi} |
| 3985 |
% \end{macrocode} |
| 3986 |
% \end{macro} |
| 3987 |
% \begin{macro}{\TRANSPOSEMATRIX} |
| 3988 |
% Matrix transposition. |
| 3989 |
% \begin{macrocode} |
| 3990 |
\def\@@TRANSPOSEMATRIX(#1,#2;#3,#4)(#5,#6;#7,#8){% |
| 3991 |
\COPY{#1}{#5}\COPY{#3}{#6}\COPY{#2}{#7}\COPY{#4}{#8}} |
| 3992 |
|
| 3993 |
\def\@@@TRANSPOSEMATRIX(#1,#2,#3;#4,#5,#6;#7,#8,#9){% |
| 3994 |
\@TDMATRIXCOPY(#1,#4,#7;#2,#5,#8;#3,#6,#9) |
| 3995 |
\@TDMATRIXSOL} |
| 3996 |
|
| 3997 |
\def\TRANSPOSEMATRIX(#1)(#2){% |
| 3998 |
\begingroup |
| 3999 |
\MATRIXSIZE(#1){\cctr@size} |
| 4000 |
\ifnum\cctr@size=2 |
| 4001 |
\@@TRANSPOSEMATRIX(#1)(#2) |
| 4002 |
\else \@@@TRANSPOSEMATRIX(#1)(#2)\fi\@OUTPUTMATRIX(#2)} |
| 4003 |
% \end{macrocode} |
| 4004 |
% \end{macro} |
| 4005 |
% \begin{macro}{\MATRIXADD} |
| 4006 |
% Sum of two matrices. |
| 4007 |
% \begin{macrocode} |
| 4008 |
\def\@@MATRIXADD(#1;#2)(#3;#4)(#5,#6;#7,#8){% |
| 4009 |
\VECTORADD(#1)(#3)(#5,#6) |
| 4010 |
\VECTORADD(#2)(#4)(#7,#8)} |
| 4011 |
|
| 4012 |
\def\@@@MATRIXADD(#1;#2;#3)(#4;#5;#6){% |
| 4013 |
\VECTORADD(#1)(#4)(\cctr@solAA,\cctr@solAB,\cctr@solAC) |
| 4014 |
\VECTORADD(#2)(#5)(\cctr@solBA,\cctr@solBB,\cctr@solBC) |
| 4015 |
\VECTORADD(#3)(#6)(\cctr@solCA,\cctr@solCB,\cctr@solCC) |
| 4016 |
\@TDMATRIXSOL} |
| 4017 |
|
| 4018 |
\def\MATRIXADD(#1)(#2)(#3){% |
| 4019 |
\begingroup |
| 4020 |
\MATRIXSIZE(#1){\cctr@size} |
| 4021 |
\ifnum\cctr@size=2 |
| 4022 |
\@@MATRIXADD(#1)(#2)(#3) |
| 4023 |
\else \@@@MATRIXADD(#1)(#2)(#3)\fi\@OUTPUTMATRIX(#3)} |
| 4024 |
% \end{macrocode} |
| 4025 |
% \end{macro} |
| 4026 |
% \begin{macro}{\MATRIXSUB} |
| 4027 |
% Difference of two matrices. |
| 4028 |
% \begin{macrocode} |
| 4029 |
\def\@@MATRIXSUB(#1;#2)(#3;#4)(#5,#6;#7,#8){% |
| 4030 |
\VECTORSUB(#1)(#3)(#5,#6) |
| 4031 |
\VECTORSUB(#2)(#4)(#7,#8)} |
| 4032 |
|
| 4033 |
\def\@@@MATRIXSUB(#1;#2;#3)(#4;#5;#6){% |
| 4034 |
\VECTORSUB(#1)(#4)(\cctr@solAA,\cctr@solAB,\cctr@solAC) |
| 4035 |
\VECTORSUB(#2)(#5)(\cctr@solBA,\cctr@solBB,\cctr@solBC) |
| 4036 |
\VECTORSUB(#3)(#6)(\cctr@solCA,\cctr@solCB,\cctr@solCC) |
| 4037 |
\@TDMATRIXSOL} |
| 4038 |
|
| 4039 |
\def\MATRIXSUB(#1)(#2)(#3){% |
| 4040 |
\begingroup |
| 4041 |
\MATRIXSIZE(#1){\cctr@size} |
| 4042 |
\ifnum\cctr@size=2 |
| 4043 |
\@@MATRIXSUB(#1)(#2)(#3) |
| 4044 |
\else \@@@MATRIXSUB(#1)(#2)(#3)\fi\@OUTPUTMATRIX(#3)} |
| 4045 |
% \end{macrocode} |
| 4046 |
% \end{macro} |
| 4047 |
% \begin{macro}{\MATRIXABSVALUE} |
| 4048 |
% Absolute value (of each entry) of a matrix. |
| 4049 |
% \begin{macrocode} |
| 4050 |
\def\@@MATRIXABSVALUE(#1;#2)(#3;#4){% |
| 4051 |
\VECTORABSVALUE(#1)(#3)\VECTORABSVALUE(#2)(#4)} |
| 4052 |
|
| 4053 |
\def\@@@MATRIXABSVALUE(#1;#2;#3)(#4;#5;#6){% |
| 4054 |
\VECTORABSVALUE(#1)(#4)\VECTORABSVALUE(#2)(#5)\VECTORABSVALUE(#3)(#6)} |
| 4055 |
|
| 4056 |
\def\MATRIXABSVALUE(#1)(#2){% |
| 4057 |
\begingroup |
| 4058 |
\MATRIXSIZE(#1){\cctr@size} |
| 4059 |
\ifnum\cctr@size=2 |
| 4060 |
\@@MATRIXABSVALUE(#1)(#2) |
| 4061 |
\else \@@@MATRIXABSVALUE(#1)(#2)\fi\@OUTPUTMATRIX(#2)} |
| 4062 |
% \end{macrocode} |
| 4063 |
% \end{macro} |
| 4064 |
|
| 4065 |
% \begin{macro}{\MATRIXVECTORPRODUCT} |
| 4066 |
% Matrix-vector product. |
| 4067 |
% \begin{macrocode} |
| 4068 |
\def\@@MATRIXVECTORPRODUCT(#1;#2)(#3)(#4,#5){% |
| 4069 |
\SCALARPRODUCT(#1)(#3){#4} |
| 4070 |
\SCALARPRODUCT(#2)(#3){#5}} |
| 4071 |
|
| 4072 |
\def\@@@MATRIXVECTORPRODUCT(#1;#2;#3)(#4)(#5,#6,#7){% |
| 4073 |
\SCALARPRODUCT(#1)(#4){#5} |
| 4074 |
\SCALARPRODUCT(#2)(#4){#6} |
| 4075 |
\SCALARPRODUCT(#3)(#4){#7}} |
| 4076 |
|
| 4077 |
\def\MATRIXVECTORPRODUCT(#1)(#2)(#3){% |
| 4078 |
\begingroup |
| 4079 |
\MATRIXSIZE(#1){\cctr@size} |
| 4080 |
\ifnum\cctr@size=2 |
| 4081 |
\@@MATRIXVECTORPRODUCT(#1)(#2)(#3) |
| 4082 |
\else \@@@MATRIXVECTORPRODUCT(#1)(#2)(#3)\fi\@OUTPUTVECTOR(#3)} |
| 4083 |
% \end{macrocode} |
| 4084 |
% \end{macro} |
| 4085 |
|
| 4086 |
|
| 4087 |
% \begin{macro}{\VECTORMATRIXPRODUCT} |
| 4088 |
% Vector-matrix product. |
| 4089 |
% \begin{macrocode} |
| 4090 |
\def\@@VECTORMATRIXPRODUCT(#1)(#2,#3;#4,#5)(#6,#7){% |
| 4091 |
\SCALARPRODUCT(#1)(#2,#4){#6} |
| 4092 |
\SCALARPRODUCT(#1)(#3,#5){#7}} |
| 4093 |
|
| 4094 |
\def\@@@VECTORMATRIXPRODUCT(#1,#2,#3)(#4;#5;#6)(#7){% |
| 4095 |
\SCALARVECTORPRODUCT{#1}(#4)(#7) |
| 4096 |
\SCALARVECTORPRODUCT{#2}(#5)(\cctr@tempa,\cctr@tempb,\cctr@tempc) |
| 4097 |
\VECTORADD(#7)(\cctr@tempa,\cctr@tempb,\cctr@tempc)(#7) |
| 4098 |
\SCALARVECTORPRODUCT{#3}(#6)(\cctr@tempa,\cctr@tempb,\cctr@tempc) |
| 4099 |
\VECTORADD(#7)(\cctr@tempa,\cctr@tempb,\cctr@tempc)(#7)} |
| 4100 |
|
| 4101 |
\def\VECTORMATRIXPRODUCT(#1)(#2)(#3){% |
| 4102 |
\begingroup |
| 4103 |
\VECTORSIZE(#1){\cctr@size} |
| 4104 |
\ifnum\cctr@size=2 |
| 4105 |
\@@VECTORMATRIXPRODUCT(#1)(#2)(#3) |
| 4106 |
\else \@@@VECTORMATRIXPRODUCT(#1)(#2)(#3)\fi\@OUTPUTVECTOR(#3)} |
| 4107 |
% \end{macrocode} |
| 4108 |
% \end{macro} |
| 4109 |
|
| 4110 |
|
| 4111 |
% \begin{macro}{\SCALARMATRIXPRODUCT} |
| 4112 |
% Scalar-matrix product. |
| 4113 |
% \begin{macrocode} |
| 4114 |
\def\@@SCALARMATRIXPRODUCT#1(#2;#3)(#4,#5;#6,#7){% |
| 4115 |
\SCALARVECTORPRODUCT{#1}(#2)(#4,#5) |
| 4116 |
\SCALARVECTORPRODUCT{#1}(#3)(#6,#7)} |
| 4117 |
|
| 4118 |
\def\@@@SCALARMATRIXPRODUCT#1(#2;#3;#4){% |
| 4119 |
\SCALARVECTORPRODUCT{#1}(#2)(\cctr@solAA,\cctr@solAB,\cctr@solAC) |
| 4120 |
\SCALARVECTORPRODUCT{#1}(#3)(\cctr@solBA,\cctr@solBB,\cctr@solBC) |
| 4121 |
\SCALARVECTORPRODUCT{#1}(#4)(\cctr@solCA,\cctr@solCB,\cctr@solCC) |
| 4122 |
\@TDMATRIXSOL} |
| 4123 |
|
| 4124 |
\def\SCALARMATRIXPRODUCT#1(#2)(#3){% |
| 4125 |
\begingroup |
| 4126 |
\MATRIXSIZE(#2){\cctr@size} |
| 4127 |
\ifnum\cctr@size=2 |
| 4128 |
\@@SCALARMATRIXPRODUCT{#1}(#2)(#3) |
| 4129 |
\else \@@@SCALARMATRIXPRODUCT{#1}(#2)(#3)\fi\@OUTPUTMATRIX(#3)} |
| 4130 |
% \end{macrocode} |
| 4131 |
% \end{macro} |
| 4132 |
% \begin{macro}{\MATRIXPRODUCT} |
| 4133 |
% Product of two matrices. |
| 4134 |
% \begin{macrocode} |
| 4135 |
\def\@@MATRIXPRODUCT(#1)(#2,#3;#4,#5)(#6,#7;#8,#9){% |
| 4136 |
\MATRIXVECTORPRODUCT(#1)(#2,#4)(#6,#8) |
| 4137 |
\MATRIXVECTORPRODUCT(#1)(#3,#5)(#7,#9)} |
| 4138 |
|
| 4139 |
\def\@@@MATRIXPRODUCT(#1;#2;#3)(#4){% |
| 4140 |
\VECTORMATRIXPRODUCT(#1)(#4)(\cctr@solAA,\cctr@solAB,\cctr@solAC) |
| 4141 |
\VECTORMATRIXPRODUCT(#2)(#4)(\cctr@solBA,\cctr@solBB,\cctr@solBC) |
| 4142 |
\VECTORMATRIXPRODUCT(#3)(#4)(\cctr@solCA,\cctr@solCB,\cctr@solCC) |
| 4143 |
\@TDMATRIXSOL} |
| 4144 |
|
| 4145 |
\def\MATRIXPRODUCT(#1)(#2)(#3){% |
| 4146 |
\begingroup |
| 4147 |
\MATRIXSIZE(#1){\cctr@size} |
| 4148 |
\ifnum\cctr@size=2 |
| 4149 |
\@@MATRIXPRODUCT(#1)(#2)(#3) |
| 4150 |
\else \@@@MATRIXPRODUCT(#1)(#2)(#3)\fi\@OUTPUTMATRIX(#3)} |
| 4151 |
% \end{macrocode} |
| 4152 |
% \end{macro} |
| 4153 |
% \begin{macro}{\DETERMINANT} |
| 4154 |
% Determinant of a matrix. |
| 4155 |
% \begin{macrocode} |
| 4156 |
\def\@@DETERMINANT(#1,#2;#3,#4)#5{% |
| 4157 |
\MULTIPLY{#1}{#4}{#5} |
| 4158 |
\MULTIPLY{#2}{#3}{\cctr@tempa} |
| 4159 |
\SUBTRACT{#5}{\cctr@tempa}{#5}} |
| 4160 |
|
| 4161 |
\def\@@@DETERMINANT(#1,#2,#3;#4,#5,#6;#7,#8,#9){% |
| 4162 |
\DETERMINANT(#5,#6;#8,#9){\cctr@det}\MULTIPLY{#1}{\cctr@det}{\cctr@sol} |
| 4163 |
\DETERMINANT(#6,#4;#9,#7){\cctr@det}\MULTIPLY{#2}{\cctr@det}{\cctr@det} |
| 4164 |
\ADD{\cctr@sol}{\cctr@det}{\cctr@sol} |
| 4165 |
\DETERMINANT(#4,#5;#7,#8){\cctr@det}\MULTIPLY{#3}{\cctr@det}{\cctr@det} |
| 4166 |
\ADD{\cctr@sol}{\cctr@det}{\cctr@sol} |
| 4167 |
\@NUMBERSOL} |
| 4168 |
|
| 4169 |
\def\DETERMINANT(#1)#2{% |
| 4170 |
\begingroup |
| 4171 |
\MATRIXSIZE(#1){\cctr@size} |
| 4172 |
\ifnum\cctr@size=2 |
| 4173 |
\@@DETERMINANT(#1){#2} |
| 4174 |
\else \@@@DETERMINANT(#1){#2}\fi\@OUTPUTSOL{#2}} |
| 4175 |
% \end{macrocode} |
| 4176 |
% \end{macro} |
| 4177 |
% \begin{macro}{\INVERSEMATRIX} |
| 4178 |
% Inverse of a matrix. |
| 4179 |
% \begin{macrocode} |
| 4180 |
\def\@@INVERSEMATRIX(#1,#2;#3,#4)(#5,#6;#7,#8){% |
| 4181 |
\ifdim \cctr@@det\p@ <\cctr@epsilon % Matrix is singular |
| 4182 |
\let#5\undefined |
| 4183 |
\let#6\undefined |
| 4184 |
\let#7\undefined |
| 4185 |
\let#8\undefined |
| 4186 |
\cctr@Warnsingmatrix{#1}{#2}{#3}{#4}% |
| 4187 |
\else \COPY{#1}{#8} |
| 4188 |
\COPY{#4}{#5} |
| 4189 |
\MULTIPLY{-1}{#3}{#7} |
| 4190 |
\MULTIPLY{-1}{#2}{#6} |
| 4191 |
\DIVIDE{1}{\cctr@det}{\cctr@det} |
| 4192 |
\SCALARMATRIXPRODUCT{\cctr@det}(#5,#6;#7,#8)(#5,#6;#7,#8) |
| 4193 |
\fi} |
| 4194 |
|
| 4195 |
\def\@@@INVERSEMATRIX(#1,#2,#3;#4,#5,#6;#7,#8,#9){% |
| 4196 |
\ifdim \cctr@@det\p@ <\cctr@epsilon % Matrix is singular |
| 4197 |
\@TDMATRIXNOSOL(\cctr@solAA,\cctr@solAB,\cctr@solAC; |
| 4198 |
\cctr@solBA,\cctr@solBB,\cctr@solBC; |
| 4199 |
\cctr@solCA,\cctr@solCB,\cctr@solCC) |
| 4200 |
\cctr@WarnsingTDmatrix{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}{#9}% |
| 4201 |
\else |
| 4202 |
\@ADJMATRIX(#1,#2,#3;#4,#5,#6;#7,#8,#9) |
| 4203 |
\@SCLRDIVVECT{\cctr@det}(\cctr@solAA,\cctr@solAB,\cctr@solAC)(% |
| 4204 |
\cctr@solAA,\cctr@solAB,\cctr@solAC) |
| 4205 |
\@SCLRDIVVECT{\cctr@det}(\cctr@solBA,\cctr@solBB,\cctr@solBC)(% |
| 4206 |
\cctr@solBA,\cctr@solBB,\cctr@solBC) |
| 4207 |
\@SCLRDIVVECT{\cctr@det}(\cctr@solCA,\cctr@solCB,\cctr@solCC)(% |
| 4208 |
\cctr@solCA,\cctr@solCB,\cctr@solCC) |
| 4209 |
\fi |
| 4210 |
\@@TDMATRIXSOL} |
| 4211 |
|
| 4212 |
\def\@SCLRDIVVECT#1(#2,#3,#4)(#5,#6,#7){% |
| 4213 |
\DIVIDE{#2}{#1}{#5}\DIVIDE{#3}{#1}{#6}\DIVIDE{#4}{#1}{#7}} |
| 4214 |
|
| 4215 |
\def\@ADJMATRIX(#1,#2,#3;#4,#5,#6;#7,#8,#9){% |
| 4216 |
\DETERMINANT(#5,#6;#8,#9){\cctr@solAA} |
| 4217 |
\DETERMINANT(#6,#4;#9,#7){\cctr@solBA} |
| 4218 |
\DETERMINANT(#4,#5;#7,#8){\cctr@solCA} |
| 4219 |
\DETERMINANT(#8,#9;#2,#3){\cctr@solAB} |
| 4220 |
\DETERMINANT(#1,#3;#7,#9){\cctr@solBB} |
| 4221 |
\DETERMINANT(#2,#1;#8,#7){\cctr@solCB} |
| 4222 |
\DETERMINANT(#2,#3;#5,#6){\cctr@solAC} |
| 4223 |
\DETERMINANT(#3,#1;#6,#4){\cctr@solBC} |
| 4224 |
\DETERMINANT(#1,#2;#4,#5){\cctr@solCC}} |
| 4225 |
|
| 4226 |
\def\INVERSEMATRIX(#1)(#2){% |
| 4227 |
\begingroup |
| 4228 |
\DETERMINANT(#1){\cctr@det} |
| 4229 |
\ABSVALUE{\cctr@det}{\cctr@@det} |
| 4230 |
\MATRIXSIZE(#1){\cctr@size} |
| 4231 |
\ifnum\cctr@size=2 |
| 4232 |
\@@INVERSEMATRIX(#1)(#2) |
| 4233 |
\else |
| 4234 |
\@@@INVERSEMATRIX(#1)(#2)\fi\@OUTPUTMATRIX(#2)} |
| 4235 |
% \end{macrocode} |
| 4236 |
% \end{macro} |
| 4237 |
% \begin{macro}{\SOLVELINEARSYSTEM} |
| 4238 |
% Solving a linear system (two equations and two unknowns |
| 4239 |
% or three equations and three unknowns). |
| 4240 |
% \begin{macrocode} |
| 4241 |
\def\@INCSYS#1#2{\cctr@WarnIncLinSys |
| 4242 |
\let#1\undefined\let#2\undefined} |
| 4243 |
|
| 4244 |
\def\@SOLPART#1#2#3#4{\cctr@WarnIndLinSys |
| 4245 |
\DIVIDE{#1}{#2}{#3} |
| 4246 |
\COPY{0}{#4}} |
| 4247 |
|
| 4248 |
\def\@TDINCSYS(#1,#2,#3){\cctr@WarnIncTDLinSys |
| 4249 |
\let#1\undefined |
| 4250 |
\let#2\undefined |
| 4251 |
\let#3\undefined} |
| 4252 |
|
| 4253 |
\def\@@SOLVELINEARSYSTEM(#1,#2;#3,#4)(#5,#6)(#7,#8){% |
| 4254 |
\DETERMINANT(#1,#2;#3,#4)\cctr@deta |
| 4255 |
\DETERMINANT(#5,#2;#6,#4)\cctr@detb |
| 4256 |
\DETERMINANT(#1,#5;#3,#6)\cctr@detc |
| 4257 |
\ABSVALUE{\cctr@deta}{\cctr@@deta} |
| 4258 |
\ABSVALUE{\cctr@detb}{\cctr@@detb} |
| 4259 |
\ABSVALUE{\cctr@detc}{\cctr@@detc} |
| 4260 |
\ifdim \cctr@@deta\p@>\cctr@epsilon% Regular matrix. Determinate system |
| 4261 |
\DIVIDE{\cctr@detb}{\cctr@deta}{#7} |
| 4262 |
\DIVIDE{\cctr@detc}{\cctr@deta}{#8} |
| 4263 |
\else % Singular matrix \cctr@deta=0 |
| 4264 |
\ifdim \cctr@@detb\p@>\cctr@epsilon% Incompatible system |
| 4265 |
\@INCSYS#7#8 |
| 4266 |
\else |
| 4267 |
\ifdim \cctr@@detc\p@>\cctr@epsilon% Incompatible system |
| 4268 |
\@INCSYS#7#8 |
| 4269 |
\else |
| 4270 |
\MATRIXABSVALUE(#1,#2;#3,#4)(\cctr@tempa,\cctr@tempb; |
| 4271 |
\cctr@tempc,\cctr@tempd) |
| 4272 |
\ifdim \cctr@tempa\p@ > \cctr@epsilon |
| 4273 |
% Indeterminate system |
| 4274 |
\@SOLPART{#5}{#1}{#7}{#8} |
| 4275 |
\else |
| 4276 |
\ifdim \cctr@tempb\p@ > \cctr@epsilon |
| 4277 |
% Indeterminate system |
| 4278 |
\@SOLPART{#5}{#2}{#8}{#7} |
| 4279 |
\else |
| 4280 |
\ifdim \cctr@tempc\p@ > \cctr@epsilon |
| 4281 |
% Indeterminate system |
| 4282 |
\@SOLPART{#6}{#3}{#7}{#8} |
| 4283 |
\else |
| 4284 |
\ifdim \cctr@tempd\p@ > \cctr@epsilon |
| 4285 |
% Indeterminate system |
| 4286 |
\@SOLPART{#6}{#4}{#8}{#7} |
| 4287 |
\else |
| 4288 |
\VECTORNORM(#5,#6){\cctr@tempa} |
| 4289 |
\ifdim \cctr@tempa\p@ > \cctr@epsilon |
| 4290 |
% Incompatible system |
| 4291 |
\@INCSYS#7#8 |
| 4292 |
\else |
| 4293 |
\cctr@WarnZeroLinSys |
| 4294 |
\COPY{0}{#7}\COPY{0}{#8} |
| 4295 |
% 0x=0 Indeterminate system |
| 4296 |
\fi\fi\fi\fi\fi\fi\fi\fi} |
| 4297 |
|
| 4298 |
\def\@@@SOLVELINEARSYSTEM(#1)(#2)(#3){% |
| 4299 |
\DETERMINANT(#1){\cctr@det} |
| 4300 |
\ABSVALUE{\cctr@det}{\cctr@@det} |
| 4301 |
\ifdim\cctr@@det\p@<\cctr@epsilon |
| 4302 |
\@TDINCSYS(#3) |
| 4303 |
\else |
| 4304 |
\@ADJMATRIX(#1) |
| 4305 |
\MATRIXVECTORPRODUCT(\cctr@solAA,\cctr@solAB,\cctr@solAC; |
| 4306 |
\cctr@solBA,\cctr@solBB,\cctr@solBC; |
| 4307 |
\cctr@solCA,\cctr@solCB,\cctr@solCC)(#2)(#3) |
| 4308 |
\@SCLRDIVVECT{\cctr@det}(#3)(#3) |
| 4309 |
\fi} |
| 4310 |
|
| 4311 |
\def\SOLVELINEARSYSTEM(#1)(#2)(#3){% |
| 4312 |
\begingroup |
| 4313 |
\MATRIXSIZE(#1){\cctr@size} |
| 4314 |
\ifnum\cctr@size=2 |
| 4315 |
\@@SOLVELINEARSYSTEM(#1)(#2)(#3) |
| 4316 |
\else |
| 4317 |
\@@@SOLVELINEARSYSTEM(#1)(#2)(#3) |
| 4318 |
\fi\@OUTPUTVECTOR(#3)} |
| 4319 |
% \end{macrocode} |
| 4320 |
% \end{macro} |
| 4321 |
% \subsection*{Predefined numbers} |
| 4322 |
% \begin{macro}{\numberPI} |
| 4323 |
% The number $\pi$ |
| 4324 |
% \begin{macrocode} |
| 4325 |
\def\numberPI{3.14159} |
| 4326 |
% \end{macrocode} |
| 4327 |
% \end{macro} |
| 4328 |
% \begin{macro}{\numberTWOPI} |
| 4329 |
% $2\pi$ |
| 4330 |
% \begin{macrocode} |
| 4331 |
\MULTIPLY{\numberPI}{2}{\numberTWOPI} |
| 4332 |
% \end{macrocode} |
| 4333 |
% \end{macro} |
| 4334 |
% \begin{macro}{\numberHALFPI} |
| 4335 |
% $\pi/2$ |
| 4336 |
% \begin{macrocode} |
| 4337 |
\DIVIDE{\numberPI}{2}{\numberHALFPI} |
| 4338 |
% \end{macrocode} |
| 4339 |
% \end{macro} |
| 4340 |
% \begin{macro}{\numberTHREEHALFPI} |
| 4341 |
% $3\pi/2$ |
| 4342 |
% \begin{macrocode} |
| 4343 |
\MULTIPLY{\numberPI}{1.5}{\numberTHREEHALFPI} |
| 4344 |
% \end{macrocode} |
| 4345 |
% \end{macro} |
| 4346 |
% \begin{macro}{\numberTHIRDPI} |
| 4347 |
% $\pi/3$ |
| 4348 |
% \begin{macrocode} |
| 4349 |
\DIVIDE{\numberPI}{3}{\numberTHIRDPI} |
| 4350 |
% \end{macrocode} |
| 4351 |
% \end{macro} |
| 4352 |
% \begin{macro}{\numberQUARTERPI} |
| 4353 |
% $\pi/4$ |
| 4354 |
% \begin{macrocode} |
| 4355 |
\DIVIDE{\numberPI}{4}{\numberQUARTERPI} |
| 4356 |
% \end{macrocode} |
| 4357 |
% \end{macro} |
| 4358 |
% \begin{macro}{\numberFIFTHPI} |
| 4359 |
% $\pi/5$ |
| 4360 |
% \begin{macrocode} |
| 4361 |
\DIVIDE{\numberPI}{5}{\numberFIFTHPI} |
| 4362 |
% \end{macrocode} |
| 4363 |
% \end{macro} |
| 4364 |
% \begin{macro}{\numberSIXTHPI} |
| 4365 |
% $\pi/6$ |
| 4366 |
% \begin{macrocode} |
| 4367 |
\DIVIDE{\numberPI}{6}{\numberSIXTHPI} |
| 4368 |
% \end{macrocode} |
| 4369 |
% \end{macro} |
| 4370 |
% \begin{macro}{\numberE} |
| 4371 |
% The number $\mathrm e$ |
| 4372 |
% \begin{macrocode} |
| 4373 |
\def\numberE{2.71828} |
| 4374 |
% \end{macrocode} |
| 4375 |
% \end{macro} |
| 4376 |
% \begin{macro}{\numberINVE} |
| 4377 |
% $1/{\mathrm e}$ |
| 4378 |
% \begin{macrocode} |
| 4379 |
\DIVIDE{1}{\numberE}{\numberINVE} |
| 4380 |
% \end{macrocode} |
| 4381 |
% \end{macro} |
| 4382 |
% \begin{macro}{\numberETWO} |
| 4383 |
% $\mathrm e^2$ |
| 4384 |
% \begin{macrocode} |
| 4385 |
\SQUARE{\numberE}{\numberETWO} |
| 4386 |
% \end{macrocode} |
| 4387 |
% \end{macro} |
| 4388 |
% \begin{macro}{\numberINVETWO} |
| 4389 |
% $1/{\mathrm e^2}$ |
| 4390 |
% \begin{macrocode} |
| 4391 |
\SQUARE{\numberINVE}{\numberINVETWO} |
| 4392 |
% \end{macrocode} |
| 4393 |
% \end{macro} |
| 4394 |
% \begin{macro}{\numberLOGTEN} |
| 4395 |
% $\log 10$ |
| 4396 |
% \begin{macrocode} |
| 4397 |
\def\numberLOGTEN{2.30258} |
| 4398 |
% \end{macrocode} |
| 4399 |
% \end{macro} |
| 4400 |
% \begin{macro}{\numberGOLD} |
| 4401 |
% The golden ratio $\phi$ |
| 4402 |
% \begin{macrocode} |
| 4403 |
\def\numberGOLD{1.61803} |
| 4404 |
% \end{macrocode} |
| 4405 |
% \end{macro} |
| 4406 |
% \begin{macro}{\numberINVGOLD} |
| 4407 |
% $1/\phi$ |
| 4408 |
% \begin{macrocode} |
| 4409 |
\def\numberINVGOLD{0.61803} |
| 4410 |
% \end{macrocode} |
| 4411 |
% \end{macro} |
| 4412 |
% \begin{macro}{\numberSQRTTWO} |
| 4413 |
% $\sqrt 2$ |
| 4414 |
% \begin{macrocode} |
| 4415 |
\def\numberSQRTTWO{1.41421} |
| 4416 |
% \end{macrocode} |
| 4417 |
% \end{macro} |
| 4418 |
% \begin{macro}{\numberSQRTTHREE} |
| 4419 |
% $\sqrt 3$ |
| 4420 |
% \begin{macrocode} |
| 4421 |
\def\numberSQRTTHREE{1.73205} |
| 4422 |
% \end{macrocode} |
| 4423 |
% \end{macro} |
| 4424 |
% \begin{macro}{\numberSQRTFIVE} |
| 4425 |
% $\sqrt 5$ |
| 4426 |
% \begin{macrocode} |
| 4427 |
\def\numberSQRTFIVE{2.23607} |
| 4428 |
% \end{macrocode} |
| 4429 |
% \end{macro} |
| 4430 |
% \begin{macro}{\numberCOSXLV} |
| 4431 |
% $\cos 45^{\mathrm o}$ (or $\cos \pi/4$) |
| 4432 |
% \begin{macrocode} |
| 4433 |
\def\numberCOSXLV{0.70711} |
| 4434 |
% \end{macrocode} |
| 4435 |
% \end{macro} |
| 4436 |
% \begin{macro}{\numberCOSXXX} |
| 4437 |
% $\cos 30^{\mathrm o}$ (or $\cos \pi/6$) |
| 4438 |
% \begin{macrocode} |
| 4439 |
\def\numberCOSXXX{0.86603} |
| 4440 |
% \end{macrocode} |
| 4441 |
% \end{macro} |
| 4442 |
% \begin{macrocode} |
| 4443 |
%</calculator> |
| 4444 |
% \end{macrocode} |
| 4445 |
% |
| 4446 |
% \section{\textsf{calculus}} |
| 4447 |
% \changes{v2.0}{2013/07/10}{Trivial error in documentation corrected} |
| 4448 |
% \begin{macrocode} |
| 4449 |
%<*calculus> |
| 4450 |
\NeedsTeXFormat{LaTeX2e} |
| 4451 |
\ProvidesPackage{calculus}[2014/02/20 v.2.0] |
| 4452 |
% \end{macrocode} |
| 4453 |
% This package requires the calculator package. |
| 4454 |
% \begin{macrocode} |
| 4455 |
\RequirePackage{calculator} |
| 4456 |
% \end{macrocode} |
| 4457 |
% \subsection{Error and info messages} |
| 4458 |
% \subsubsection*{For scalar functions} |
| 4459 |
% |
| 4460 |
% Error message to be issued when you attempt to define, with \cs{newfunction}, |
| 4461 |
% an already defined command: |
| 4462 |
% \begin{macrocode} |
| 4463 |
\def\ccls@ErrorFuncDef#1{% |
| 4464 |
\PackageError{calculus}% |
| 4465 |
{\noexpand#1 command already defined} |
| 4466 |
{The \noexpand#1 control sequence is already defined\MessageBreak |
| 4467 |
If you want to redefine the \noexpand#1 command as a |
| 4468 |
function\MessageBreak |
| 4469 |
please, use the \noexpand\renewfunction command}} |
| 4470 |
% \end{macrocode} |
| 4471 |
% Error message to be issued when you attempt to redefine, |
| 4472 |
% with \cs{renewfunction}, an undefined command: |
| 4473 |
% \begin{macrocode} |
| 4474 |
\def\ccls@ErrorFuncUnDef#1{% |
| 4475 |
\PackageError{calculus}% |
| 4476 |
{\noexpand#1 command undefined} |
| 4477 |
{The \noexpand#1 control sequence is not currently defined\MessageBreak |
| 4478 |
If you want to define the \noexpand#1 command as a function\MessageBreak |
| 4479 |
please, use the \noexpand\newfunction command}} |
| 4480 |
% \end{macrocode} |
| 4481 |
% Info message to be issued when \cs{ensurefunction} does not changes |
| 4482 |
% an already defined command: |
| 4483 |
% \begin{macrocode} |
| 4484 |
\def\ccls@InfoFuncEns#1{% |
| 4485 |
\PackageInfo{calculus}% |
| 4486 |
{\noexpand#1 command already defined\MessageBreak |
| 4487 |
the \noexpand\ensurefunction command will not redefine it}} |
| 4488 |
% \end{macrocode} |
| 4489 |
% \subsubsection*{For polar functions} |
| 4490 |
% \begin{macrocode} |
| 4491 |
\def\ccls@ErrorPFuncDef#1{% |
| 4492 |
\PackageError{calculus}% |
| 4493 |
{\noexpand#1 command already defined} |
| 4494 |
{The \noexpand#1 control sequence is already defined\MessageBreak |
| 4495 |
If you want to redefine the \noexpand#1 |
| 4496 |
command as a polar function\MessageBreak |
| 4497 |
please, use the \noexpand\renewpolarfunction command}} |
| 4498 |
|
| 4499 |
\def\ccls@ErrorPFuncUnDef#1{% |
| 4500 |
\PackageError{calculus}% |
| 4501 |
{\noexpand#1 command undefined} |
| 4502 |
{The \noexpand#1 control sequence |
| 4503 |
is not currently defined.\MessageBreak |
| 4504 |
If you want to define the \noexpand#1 command as a polar |
| 4505 |
function\MessageBreak |
| 4506 |
please, use the \noexpand\newpolarfunction command}} |
| 4507 |
|
| 4508 |
\def\ccls@InfoPFuncEns#1{% |
| 4509 |
\PackageInfo{calculus}% |
| 4510 |
{\noexpand#1 command already defined\MessageBreak |
| 4511 |
the \noexpand\ensurepolarfunction command does not redefine it}} |
| 4512 |
% \end{macrocode} |
| 4513 |
% \subsubsection*{For vector functions} |
| 4514 |
% \begin{macrocode} |
| 4515 |
\def\ccls@ErrorVFuncDef#1{% |
| 4516 |
\PackageError{calculus}% |
| 4517 |
{\noexpand#1 command already defined} |
| 4518 |
{The \noexpand#1 control sequence is already defined\MessageBreak |
| 4519 |
If you want to redefine the \noexpand#1 command as a vector |
| 4520 |
function\MessageBreak |
| 4521 |
please, use the \noexpand\renewvectorfunction command}} |
| 4522 |
|
| 4523 |
\def\ccls@ErrorVFuncUnDef#1{% |
| 4524 |
\PackageError{calculus}% |
| 4525 |
{\noexpand#1 command undefined} |
| 4526 |
{The \noexpand#1 control sequence is not currently |
| 4527 |
defined.\MessageBreak |
| 4528 |
If you want to define the \noexpand#1 command as a vector |
| 4529 |
function\MessageBreak |
| 4530 |
please, use the \noexpand\newvectorfunction command}} |
| 4531 |
|
| 4532 |
\def\ccls@InfoVFuncEns#1{% |
| 4533 |
\PackageInfo{calculus}% |
| 4534 |
{\noexpand#1 command already defined\MessageBreak |
| 4535 |
the \noexpand\ensurevectorfunction command does not redefine it}} |
| 4536 |
% \end{macrocode} |
| 4537 |
% \subsection{New functions} |
| 4538 |
% \subsubsection*{New scalar functions} |
| 4539 |
% |
| 4540 |
% \begin{macro}{\newfunction} |
| 4541 |
% The \cs{newfunction\{\#1\}\{\#2\}} instruction defines |
| 4542 |
% a new function called \#1. |
| 4543 |
% \#2 is the list of instructions to calculate the function |
| 4544 |
% \cs{y} and his derivative \cs{Dy} from the \cs{t} variable. |
| 4545 |
% \begin{macrocode} |
| 4546 |
\def\newfunction#1#2{% |
| 4547 |
\ifx #1\undefined |
| 4548 |
\ccls@deffunction{#1}{#2} |
| 4549 |
\else |
| 4550 |
\ccls@ErrorFuncDef{#1} |
| 4551 |
\fi} |
| 4552 |
% \end{macrocode} |
| 4553 |
% \end{macro} |
| 4554 |
% \begin{macro}{\renewfunction} |
| 4555 |
% \cs{renewfunction} redefines \#1, as a new function, |
| 4556 |
% if this command is already defined. |
| 4557 |
% \begin{macrocode} |
| 4558 |
\def\renewfunction#1#2{% |
| 4559 |
\ifx #1\undefined |
| 4560 |
\ccls@ErrorFuncUnDef{#1} |
| 4561 |
\else |
| 4562 |
\ccls@deffunction{#1}{#2} |
| 4563 |
\fi} |
| 4564 |
% \end{macrocode} |
| 4565 |
% \end{macro} |
| 4566 |
% \begin{macro}{\ensurefunction} |
| 4567 |
% \cs{ensurefunction} defines the new function \#1 |
| 4568 |
% (only if this macro is undefined). |
| 4569 |
% \begin{macrocode} |
| 4570 |
\def\ensurefunction#1#2{% |
| 4571 |
\ifx #1\undefined\ccls@deffunction{#1}{#2} |
| 4572 |
\else |
| 4573 |
\ccls@InfoFuncEns{#1} |
| 4574 |
\fi} |
| 4575 |
% \end{macrocode} |
| 4576 |
% \end{macro} |
| 4577 |
% \begin{macro}{\forcefunction} |
| 4578 |
% \cs{forcefunction} defines (if undefined) or redefines (if defined) |
| 4579 |
% the new function \#1. |
| 4580 |
% \begin{macrocode} |
| 4581 |
\def\forcefunction#1#2{% |
| 4582 |
\ccls@deffunction{#1}{#2}} |
| 4583 |
% \end{macrocode} |
| 4584 |
% \end{macro} |
| 4585 |
% \begin{macro}{\ccls@deffunction} |
| 4586 |
% The private \cs{ccls@deffunction} command makes the real work. |
| 4587 |
% The new functions will have three arguments: |
| 4588 |
% \#\#1, a number, \#\#2, the value of the new function in that number, |
| 4589 |
% and \#\#3, the derivative. |
| 4590 |
% \begin{macrocode} |
| 4591 |
\def\ccls@deffunction#1#2{% |
| 4592 |
\def#1##1##2##3{% |
| 4593 |
\begingroup |
| 4594 |
\def\t{##1}% |
| 4595 |
#2 |
| 4596 |
\xdef##2{\y}% |
| 4597 |
\xdef##3{\Dy}% |
| 4598 |
\endgroup}\ignorespaces} |
| 4599 |
% \end{macrocode} |
| 4600 |
% \end{macro} |
| 4601 |
% \subsubsection*{New polar functions} |
| 4602 |
% |
| 4603 |
% \begin{macro}{\newpolarfunction} |
| 4604 |
% The \cs{newpolarfunction\{\#1\}\{\#2\}} instruction defines |
| 4605 |
% a new polar function called \#1. |
| 4606 |
% \#2 is the list of instructions to calculate the radius \cs{r} |
| 4607 |
% and his derivative \cs{Dr} from the \cs{t} arc variable. |
| 4608 |
% \begin{macrocode} |
| 4609 |
\def\newpolarfunction#1#2{% |
| 4610 |
\ifx #1\undefined |
| 4611 |
\ccls@defpolarfunction{#1}{#2} |
| 4612 |
\else |
| 4613 |
\ccls@ErrorPFuncDef{#1} |
| 4614 |
\fi} |
| 4615 |
% \end{macrocode} |
| 4616 |
% \end{macro} |
| 4617 |
% \begin{macro}{\renewpolarfunction} |
| 4618 |
% \cs{renewpolarfunction} redefines \#1 if already defined. |
| 4619 |
% \begin{macrocode} |
| 4620 |
\def\renewpolarfunction#1#2{% |
| 4621 |
\ifx #1\undefined |
| 4622 |
\ccls@ErrorPFuncUnDef{#1} |
| 4623 |
\else |
| 4624 |
\ccls@defpolarfunction{#1}{#2} |
| 4625 |
\fi} |
| 4626 |
% \end{macrocode} |
| 4627 |
% \end{macro} |
| 4628 |
% \begin{macro}{\ensurepolarfunction} |
| 4629 |
% \cs{ensurepolarfunction} defines (only if undefined) \#1. |
| 4630 |
% \begin{macrocode} |
| 4631 |
\def\ensurepolarfunction#1#2{% |
| 4632 |
\ifx #1\undefined\ccls@defpolarfunction{#1}{#2} |
| 4633 |
\else |
| 4634 |
\ccls@InfoPFuncEns{#1} |
| 4635 |
\fi} |
| 4636 |
% \end{macrocode} |
| 4637 |
% \end{macro} |
| 4638 |
% \begin{macro}{\forcepolarfunction} |
| 4639 |
% \cs{forcepolarfunction} defines (if undefined) or redefines (if defined) \#1. |
| 4640 |
% \begin{macrocode} |
| 4641 |
\def\forcepolarfunction#1#2{% |
| 4642 |
\ccls@defpolarfunction{#1}{#2}} |
| 4643 |
% \end{macrocode} |
| 4644 |
% \end{macro} |
| 4645 |
% \begin{macro}{\ccls@defpolarfunction} |
| 4646 |
% The private \cs{ccls@defpolarfunction} command makes the real work. |
| 4647 |
% The new functions will have three arguments: |
| 4648 |
% \#\#1, a number (the polar radius), |
| 4649 |
% \#\#2, \#\#3, \#\#4, and \#\#5, the x and y component functions and |
| 4650 |
% its derivatives at \#\#1. |
| 4651 |
% \begin{macrocode} |
| 4652 |
\def\ccls@defpolarfunction#1#2{% |
| 4653 |
\def#1##1##2##3##4##5{% |
| 4654 |
\begingroup |
| 4655 |
\def\t{##1} |
| 4656 |
#2 |
| 4657 |
\COS{\t}\ccls@cost |
| 4658 |
\MULTIPLY\r\ccls@cost{\x} |
| 4659 |
\SIN{\t}\ccls@sint |
| 4660 |
\MULTIPLY\r\ccls@sint{\y} |
| 4661 |
\MULTIPLY\ccls@cost\Dr\Dx |
| 4662 |
\SUBTRACT{\Dx}{\y}{\Dx} |
| 4663 |
\MULTIPLY\ccls@sint\Dr\Dy |
| 4664 |
\ADD{\Dy}{\x}{\Dy} |
| 4665 |
\xdef##2{\x} |
| 4666 |
\xdef##3{\Dx} |
| 4667 |
\xdef##4{\y} |
| 4668 |
\xdef##5{\Dy} |
| 4669 |
\endgroup}\ignorespaces} |
| 4670 |
% \end{macrocode} |
| 4671 |
% \end{macro} |
| 4672 |
% \subsubsection*{New vector functions} |
| 4673 |
% |
| 4674 |
% \begin{macro}{\newvectorfunction} |
| 4675 |
% The \cs{newvectorfunction\{\#1\}\{\#2\}} instruction defines |
| 4676 |
% a new vector (parametric) function called \#1. |
| 4677 |
% \#2 is the list of instructions to calculate |
| 4678 |
% \cs{x}, \cs{y}, \cs{Dx} and \cs{Dy} from the \cs{t} arc variable. |
| 4679 |
% \begin{macrocode} |
| 4680 |
\def\newvectorfunction#1#2{% |
| 4681 |
\ifx #1\undefined |
| 4682 |
\ccls@defvectorfunction{#1}{#2} |
| 4683 |
\else |
| 4684 |
\ccls@ErrorVFuncDef{#1} |
| 4685 |
\fi} |
| 4686 |
% \end{macrocode} |
| 4687 |
% \end{macro} |
| 4688 |
% \begin{macro}{\renewvectorfunction} |
| 4689 |
% \cs{renewvectorfunction} redefines \#1 if already defined. |
| 4690 |
% \begin{macrocode} |
| 4691 |
\def\renewvectorfunction#1#2{% |
| 4692 |
\ifx #1\undefined |
| 4693 |
\ccls@ErrorVFuncUnDef{#1} |
| 4694 |
\else |
| 4695 |
\ccls@defvectorfunction{#1}{#2} |
| 4696 |
\fi} |
| 4697 |
% \end{macrocode} |
| 4698 |
% \end{macro} |
| 4699 |
% \begin{macro}{\ensurevectorfunction} |
| 4700 |
% \cs{ensurevectorfunction} defines (only if undefined) \#1. |
| 4701 |
% \begin{macrocode} |
| 4702 |
\def\ensurevectorfunction#1#2{% |
| 4703 |
\ifx #1\undefined\ccls@defvectorfunction{#1}{#2} |
| 4704 |
\else |
| 4705 |
\ccls@InfoVFuncEns{#1} |
| 4706 |
\fi} |
| 4707 |
% \end{macrocode} |
| 4708 |
% \end{macro} |
| 4709 |
% \begin{macro}{\forcevectorfunction} |
| 4710 |
% \cs{forcevectorfunction} defines (if undefined) |
| 4711 |
% or redefines (if defined) \#1. |
| 4712 |
% \begin{macrocode} |
| 4713 |
\def\forcevectorfunction#1#2{% |
| 4714 |
\ccls@defvectorfunction{#1}{#2}} |
| 4715 |
% \end{macrocode} |
| 4716 |
% \end{macro} |
| 4717 |
% \begin{macro}{\ccls@defvectorfunction} |
| 4718 |
% The private \cs{ccls@defvectorfunction} command makes the real work. |
| 4719 |
% The new functions will have three arguments: |
| 4720 |
% \#\#1, a number, |
| 4721 |
% \#\#2, \#\#3, \#\#4, and \#\#5, the x and y component functions |
| 4722 |
% and its derivatives at \#\#1. |
| 4723 |
% \begin{macrocode} |
| 4724 |
\def\ccls@defvectorfunction#1#2{% |
| 4725 |
\def#1##1##2##3##4##5{% |
| 4726 |
\begingroup |
| 4727 |
\def\t{##1} |
| 4728 |
#2 |
| 4729 |
\xdef##2{\x} |
| 4730 |
\xdef##3{\Dx} |
| 4731 |
\xdef##4{\y} |
| 4732 |
\xdef##5{\Dy} |
| 4733 |
\endgroup}\ignorespaces} |
| 4734 |
% \end{macrocode} |
| 4735 |
% \end{macro} |
| 4736 |
% \subsection{Polynomials} |
| 4737 |
% \subsubsection*{Linear (first degreee) polynomials} |
| 4738 |
% |
| 4739 |
% \begin{macro}{\newlpoly} |
| 4740 |
% The \cs{newlpoly\{\#1\}\{\#2\}\{\#3\}} instruction defines |
| 4741 |
% the linear polynomial |
| 4742 |
% |
| 4743 |
% $\#1=\#2+\#3t$. |
| 4744 |
% \begin{macrocode} |
| 4745 |
\def\newlpoly#1#2#3{% |
| 4746 |
\newfunction{#1}{% |
| 4747 |
\ccls@lpoly{#2}{#3}}} |
| 4748 |
% \end{macrocode} |
| 4749 |
% \end{macro} |
| 4750 |
% \begin{macro}{\renewlpoly} |
| 4751 |
% We define also the \cs{renewlpoly}, \cs{ensurelpoly} |
| 4752 |
% and \cs{forcelpoly} variants. |
| 4753 |
% \begin{macrocode} |
| 4754 |
\def\renewlpoly#1#2#3{% |
| 4755 |
\renewfunction{#1}{% |
| 4756 |
\ccls@lpoly{#2}{#3}}} |
| 4757 |
% \end{macrocode} |
| 4758 |
% \end{macro} |
| 4759 |
% \begin{macro}{\ensurelpoly} |
| 4760 |
% \begin{macrocode} |
| 4761 |
\def\ensurelpoly#1#2#3{% |
| 4762 |
\ensurefunction{#1}{% |
| 4763 |
\ccls@lpoly{#2}{#3}}} |
| 4764 |
% \end{macrocode} |
| 4765 |
% \end{macro} |
| 4766 |
% \begin{macro}{\forcelpoly} |
| 4767 |
% \begin{macrocode} |
| 4768 |
\def\forcelpoly#1#2#3{% |
| 4769 |
\forcefunction{#1}{% |
| 4770 |
\ccls@lpoly{#2}{#3}}} |
| 4771 |
% \end{macrocode} |
| 4772 |
% \end{macro} |
| 4773 |
% \begin{macro}{\ccls@lpoly} |
| 4774 |
% The \cs{ccls@lpoly\{\#1\}\{\#2\}} macro defines the new polynomial function. |
| 4775 |
% \begin{macrocode} |
| 4776 |
\def\ccls@lpoly#1#2{% |
| 4777 |
\MULTIPLY{#2}{\t}{\y} |
| 4778 |
\ADD{\y}{#1}{\y} |
| 4779 |
\COPY{#2}{\Dy}} |
| 4780 |
% \end{macrocode} |
| 4781 |
% \end{macro} |
| 4782 |
% \subsubsection*{Quadratic polynomials} |
| 4783 |
% |
| 4784 |
% \begin{macro}{\newqpoly} |
| 4785 |
% The \cs{newqpoly\{\#1\}\{\#2\}\{\#3\}\{\#4\}} |
| 4786 |
% instruction defines the quadratic polynomial |
| 4787 |
% |
| 4788 |
% $\#1=\#2+\#3t+\#4t^2$. |
| 4789 |
% \begin{macrocode} |
| 4790 |
\def\newqpoly#1#2#3#4{% |
| 4791 |
\newfunction{#1}{% |
| 4792 |
\ccls@qpoly{#2}{#3}{#4}}} |
| 4793 |
% \end{macrocode} |
| 4794 |
% \end{macro} |
| 4795 |
% \begin{macro}{\renewqpoly} |
| 4796 |
% \begin{macrocode} |
| 4797 |
\def\renewqpoly#1#2#3#4{% |
| 4798 |
\renewfunction{#1}{% |
| 4799 |
\ccls@qpoly{#2}{#3}{#4}}} |
| 4800 |
% \end{macrocode} |
| 4801 |
% \end{macro} |
| 4802 |
% \begin{macro}{\ensureqpoly} |
| 4803 |
% \begin{macrocode} |
| 4804 |
\def\ensureqpoly#1#2#3#4{% |
| 4805 |
\ensurefunction{#1}{% |
| 4806 |
\ccls@qpoly{#2}{#3}{#4}}} |
| 4807 |
% \end{macrocode} |
| 4808 |
% \end{macro} |
| 4809 |
% \begin{macro}{\forceqpoly} |
| 4810 |
% \begin{macrocode} |
| 4811 |
\def\forceqpoly#1#2#3#4{% |
| 4812 |
\forcefunction{#1}{% |
| 4813 |
\ccls@qpoly{#2}{#3}{#4}}} |
| 4814 |
% \end{macrocode} |
| 4815 |
% \end{macro} |
| 4816 |
% \begin{macro}{\ccls@qpoly} |
| 4817 |
% The \cs{ccls@qpoly\{\#1\}\{\#2\}} macro defines the new polynomial function. |
| 4818 |
% \begin{macrocode} |
| 4819 |
\def\ccls@qpoly#1#2#3{% |
| 4820 |
\MULTIPLY{\t}{#3}{\y} |
| 4821 |
\MULTIPLY{2}{\y}{\Dy} |
| 4822 |
\ADD{#2}{\Dy}{\Dy} |
| 4823 |
\ADD{#2}{\y}{\y} |
| 4824 |
\MULTIPLY{\t}{\y}{\y} |
| 4825 |
\ADD{#1}{\y}{\y}} |
| 4826 |
% \end{macrocode} |
| 4827 |
% \end{macro} |
| 4828 |
% \subsubsection*{Cubic polynomials} |
| 4829 |
% |
| 4830 |
% \begin{macro}{\newcpoly} |
| 4831 |
% The \cs{newcpoly\{\#1\}\{\#2\}\{\#3\}\{\#4\}\{\#5\}} |
| 4832 |
% instruction defines the cubic polynomial |
| 4833 |
% |
| 4834 |
% $\#1=\#2+\#3t+\#4t^2+\#5t^3$. |
| 4835 |
% \begin{macrocode} |
| 4836 |
\def\newcpoly#1#2#3#4#5{% |
| 4837 |
\newfunction{#1}{% |
| 4838 |
\ccls@cpoly{#2}{#3}{#4}{#5}}} |
| 4839 |
% \end{macrocode} |
| 4840 |
% \end{macro} |
| 4841 |
% \begin{macro}{\renewcpoly} |
| 4842 |
% \begin{macrocode} |
| 4843 |
\def\renewcpoly#1#2#3#4#5{% |
| 4844 |
\renewfunction{#1}{% |
| 4845 |
\ccls@cpoly{#2}{#3}{#4}{#5}}} |
| 4846 |
% \end{macrocode} |
| 4847 |
% \end{macro} |
| 4848 |
% \begin{macro}{\ensurecpoly} |
| 4849 |
% \begin{macrocode} |
| 4850 |
\def\ensurecpoly#1#2#3#4#5{% |
| 4851 |
\ensurefunction{#1}{% |
| 4852 |
\ccls@cpoly{#2}{#3}{#4}{#5}}} |
| 4853 |
% \end{macrocode} |
| 4854 |
% \end{macro} |
| 4855 |
% \begin{macro}{\forcecpoly} |
| 4856 |
% \begin{macrocode} |
| 4857 |
\def\forcecpoly#1#2#3#4#5{% |
| 4858 |
\forcefunction{#1}{% |
| 4859 |
\ccls@cpoly{#2}{#3}{#4}{#5}}} |
| 4860 |
% \end{macrocode} |
| 4861 |
% \end{macro} |
| 4862 |
% \begin{macro}{\ccls@cpoly} |
| 4863 |
% The \cs{ccls@cpoly\{\#1\}\{\#2\}} macro defines the new polynomial function. |
| 4864 |
% \begin{macrocode} |
| 4865 |
\def\ccls@cpoly#1#2#3#4{% |
| 4866 |
\MULTIPLY{\t}{#4}{\y} |
| 4867 |
\MULTIPLY{3}{\y}{\Dy} |
| 4868 |
\ADD{#3}{\y}{\y} |
| 4869 |
\MULTIPLY{2}{#3}{\ccls@temp} |
| 4870 |
\ADD{\ccls@temp}{\Dy}{\Dy} |
| 4871 |
\MULTIPLY{\t}{\y}{\y} |
| 4872 |
\MULTIPLY{\t}{\Dy}{\Dy} |
| 4873 |
\ADD{#2}{\y}{\y} |
| 4874 |
\ADD{#2}{\Dy}{\Dy} |
| 4875 |
\MULTIPLY{\t}{\y}{\y} |
| 4876 |
\ADD{#1}{\y}{\y} |
| 4877 |
} |
| 4878 |
% \end{macrocode} |
| 4879 |
% \end{macro} |
| 4880 |
% \subsection{Elementary functions} |
| 4881 |
% \begin{macro}{\ONEfunction} |
| 4882 |
% The \cs{ONEfunction}: $y(t)=1$, $y'(t)=0$ |
| 4883 |
% \begin{macrocode} |
| 4884 |
\newfunction{\ONEfunction}{% |
| 4885 |
\COPY{1}{\y} |
| 4886 |
\COPY{0}{\Dy}} |
| 4887 |
% \end{macrocode} |
| 4888 |
% \end{macro} |
| 4889 |
% \begin{macro}{\ZEROfunction} |
| 4890 |
% The \cs{ZEROfunction}: $y(t)=0$, $y'(t)=0$ |
| 4891 |
% \begin{macrocode} |
| 4892 |
\newfunction{\ZEROfunction}{% |
| 4893 |
\COPY{0}{\y} |
| 4894 |
\COPY{0}{\Dy}} |
| 4895 |
% \end{macrocode} |
| 4896 |
% \end{macro} |
| 4897 |
% \begin{macro}{\IDENTITYfunction} |
| 4898 |
% The \cs{IDENTITYfunction}: $y(t)=t$, $y'(t)=1$ |
| 4899 |
% \begin{macrocode} |
| 4900 |
\newfunction{\IDENTITYfunction}{% |
| 4901 |
\COPY{\t}{\y} |
| 4902 |
\COPY{1}{\Dy}} |
| 4903 |
% \end{macrocode} |
| 4904 |
% \end{macro} |
| 4905 |
% \begin{macro}{\RECIPROCALfunction} |
| 4906 |
% The \cs{RECIPROCALfunction}: $y(t)=1/t$, $y'(t)=-1/t^2$ |
| 4907 |
% \begin{macrocode} |
| 4908 |
\newfunction{\RECIPROCALfunction}{% |
| 4909 |
\DIVIDE{1}{\t}{\y} |
| 4910 |
\SQUARE{\y}{\Dy} |
| 4911 |
\MULTIPLY{-1}{\Dy}{\Dy}} |
| 4912 |
% \end{macrocode} |
| 4913 |
% \end{macro} |
| 4914 |
% \begin{macro}{\SQUAREfunction} |
| 4915 |
% The \cs{SQUAREfunction}: $y(t)=t^2$, $y'(t)=2t$ |
| 4916 |
% \begin{macrocode} |
| 4917 |
\newfunction{\SQUAREfunction}{% |
| 4918 |
\SQUARE{\t}{\y} |
| 4919 |
\MULTIPLY{2}{\t}{\Dy}} |
| 4920 |
% \end{macrocode} |
| 4921 |
% \end{macro} |
| 4922 |
% \begin{macro}{\CUBEfunction} |
| 4923 |
% The \cs{CUBEfunction}: $y(t)=t^3$, $y'(t)=3t^2$ |
| 4924 |
% \begin{macrocode} |
| 4925 |
\newfunction{\CUBEfunction}{% |
| 4926 |
\SQUARE{\t}{\Dy} |
| 4927 |
\MULTIPLY{\t}{\Dy}{\y} |
| 4928 |
\MULTIPLY{3}{\Dy}{\Dy}} |
| 4929 |
% \end{macrocode} |
| 4930 |
% \end{macro} |
| 4931 |
% \begin{macro}{\SQRTfunction} |
| 4932 |
% The \cs{SQRTfunction}: $y(t)=\sqrt t$, $y'(t)=1/(2\sqrt t)$ |
| 4933 |
% \begin{macrocode} |
| 4934 |
\newfunction{\SQRTfunction}{% |
| 4935 |
\SQRT{\t}{\y} |
| 4936 |
\DIVIDE{0.5}{\y}{\Dy}} |
| 4937 |
% \end{macrocode} |
| 4938 |
% \end{macro} |
| 4939 |
% \begin{macro}{\EXPfunction} |
| 4940 |
% The \cs{EXPfunction}: $y(t)=\exp t$, $y'(t)=\exp t$ |
| 4941 |
% \begin{macrocode} |
| 4942 |
\newfunction{\EXPfunction}{% |
| 4943 |
\EXP{\t}{\y} |
| 4944 |
\COPY{\y}{\Dy}} |
| 4945 |
% \end{macrocode} |
| 4946 |
% \end{macro} |
| 4947 |
% \begin{macro}{\COSfunction} |
| 4948 |
% The \cs{COSfunction}: $y(t)=\cos t$, $y'(t)=-\sin t$ |
| 4949 |
% \begin{macrocode} |
| 4950 |
\newfunction{\COSfunction}{% |
| 4951 |
\COS{\t}{\y} |
| 4952 |
\SIN{\t}{\Dy} |
| 4953 |
\MULTIPLY{-1}{\Dy}{\Dy}} |
| 4954 |
% \end{macrocode} |
| 4955 |
% \end{macro} |
| 4956 |
% \begin{macro}{\SINfunction} |
| 4957 |
% The \cs{SINfunction}: $y(t)=\sin t$, $y'(t)=\cos t$ |
| 4958 |
% \begin{macrocode} |
| 4959 |
\newfunction{\SINfunction}{% |
| 4960 |
\SIN{\t}{\y} |
| 4961 |
\COS{\t}{\Dy}} |
| 4962 |
% \end{macrocode} |
| 4963 |
% \end{macro} |
| 4964 |
% \begin{macro}{\TANfunction} |
| 4965 |
% The \cs{TANfunction}: $y(t)=\tan t$, $y'(t)=1/(\cos t)^2$ |
| 4966 |
% \begin{macrocode} |
| 4967 |
\newfunction{\TANfunction}{% |
| 4968 |
\TAN{\t}{\y} |
| 4969 |
\COS{\t}{\Dy} |
| 4970 |
\SQUARE{\Dy}{\Dy} |
| 4971 |
\DIVIDE{1}{\Dy}{\Dy}} |
| 4972 |
% \end{macrocode} |
| 4973 |
% \end{macro} |
| 4974 |
% \begin{macro}{\COTfunction} |
| 4975 |
% The \cs{COTfunction}: $y(t)=\cot t$, $y'(t)=-1/(\sin t)^2$ |
| 4976 |
% \begin{macrocode} |
| 4977 |
\newfunction{\COTfunction}{% |
| 4978 |
\COTAN{\t}{\y} |
| 4979 |
\SIN{\t}{\Dy} |
| 4980 |
\SQUARE{\Dy}{\Dy} |
| 4981 |
\DIVIDE{-1}{\Dy}{\Dy}} |
| 4982 |
% \end{macrocode} |
| 4983 |
% \end{macro} |
| 4984 |
% \begin{macro}{\COSHfunction} |
| 4985 |
% The \cs{COSHfunction}: $y(t)=\cosh t$, $y'(t)=\sinh t$ |
| 4986 |
% \begin{macrocode} |
| 4987 |
\newfunction{\COSHfunction}{% |
| 4988 |
\COSH{\t}{\y} |
| 4989 |
\SINH{\t}{\Dy}} |
| 4990 |
% \end{macrocode} |
| 4991 |
% \end{macro} |
| 4992 |
% \begin{macro}{\SINHfunction} |
| 4993 |
% The \cs{SINHfunction}: $y(t)=\sinh t$, $y'(t)=\cosh t$ |
| 4994 |
% \begin{macrocode} |
| 4995 |
\newfunction{\SINHfunction}{% |
| 4996 |
\SINH{\t}{\y} |
| 4997 |
\COSH{\t}{\Dy}} |
| 4998 |
% \end{macrocode} |
| 4999 |
% \end{macro} |
| 5000 |
% \begin{macro}{\TANHfunction} |
| 5001 |
% The \cs{TANHfunction}: $y(t)=\tanh t$, $y'(t)=1/(\cosh t)^2$ |
| 5002 |
% \begin{macrocode} |
| 5003 |
\newfunction{\TANHfunction}{% |
| 5004 |
\TANH{\t}{\y} |
| 5005 |
\COSH{\t}{\Dy} |
| 5006 |
\SQUARE{\Dy}{\Dy} |
| 5007 |
\DIVIDE{1}{\Dy}{\Dy}} |
| 5008 |
% \end{macrocode} |
| 5009 |
% \end{macro} |
| 5010 |
% \begin{macro}{\COTHfunction} |
| 5011 |
% The \cs{COTHfunction}: $y(t)=\coth t$, $y'(t)=-1/(\sinh t)^2$ |
| 5012 |
% \begin{macrocode} |
| 5013 |
\newfunction{\COTHfunction}{% |
| 5014 |
\COTANH{\t}{\y} |
| 5015 |
\SINH{\t}{\Dy} |
| 5016 |
\SQUARE{\Dy}{\Dy} |
| 5017 |
\DIVIDE{-1}{\Dy}{\Dy}} |
| 5018 |
% \end{macrocode} |
| 5019 |
% \end{macro} |
| 5020 |
% \begin{macro}{\LOGfunction} |
| 5021 |
% The \cs{LOGfunction}: $y(t)=\log t$, $y'(t)=1/t$ |
| 5022 |
% \begin{macrocode} |
| 5023 |
\newfunction{\LOGfunction}{% |
| 5024 |
\LOG{\t}{\y} |
| 5025 |
\DIVIDE{1}{\t}{\Dy}} |
| 5026 |
% \end{macrocode} |
| 5027 |
% \end{macro} |
| 5028 |
% \begin{macro}{\HEAVISIDEfunction} |
| 5029 |
% The \cs{HEAVISIDEfunction}: |
| 5030 |
% $y(t)=\begin{cases} |
| 5031 |
% 0 & \text{if } t<0 \\ |
| 5032 |
% 1 & \text{if } t\geq 0 |
| 5033 |
% \end{cases}$, |
| 5034 |
% $y'(t)=0$ |
| 5035 |
% \begin{macrocode} |
| 5036 |
\newfunction{\HEAVISIDEfunction}{% |
| 5037 |
\ifdim \t\p@<\z@ \COPY{0}{\y}\else\COPY{1}{\y}\fi |
| 5038 |
\COPY{0}{\Dy}} |
| 5039 |
% \end{macrocode} |
| 5040 |
% \end{macro} |
| 5041 |
% \changes{v2.0}{2014/02/13}{New commands: \cs{ARCSINfunction}, |
| 5042 |
% \cs{ARCCOSfunction}, \cs{ARCTANfunction}, |
| 5043 |
% \cs{ARCCOTfunction}} |
| 5044 |
% \begin{macro}{\ARCSINfunction} |
| 5045 |
% The \cs{ARCSINfunction}: $y(t)=\arcsin t$, $y'(t)=1/\sqrt{1-t^2}$ |
| 5046 |
% \begin{macrocode} |
| 5047 |
\newfunction{\ARCSINfunction}{% |
| 5048 |
\ARCSIN{\t}{\y} |
| 5049 |
\SQUARE{\t}{\yy} |
| 5050 |
\SUBTRACT{1}{\yy}{\yy} |
| 5051 |
\SQRT{\yy}{\Dy} |
| 5052 |
\DIVIDE{1}{\Dy}{\Dy}} |
| 5053 |
% \end{macrocode} |
| 5054 |
% \end{macro} |
| 5055 |
% \begin{macro}{\ARCCOSfunction} |
| 5056 |
% The \cs{ARCCOSfunction}: $y(t)=\arccos t$, $y'(t)=-1/\sqrt{1-t^2}$ |
| 5057 |
% \begin{macrocode} |
| 5058 |
\newfunction{\ARCCOSfunction}{% |
| 5059 |
\ARCCOS{\t}{\y} |
| 5060 |
\SQUARE{\t}{\yy} |
| 5061 |
\SUBTRACT{1}{\yy}{\yy} |
| 5062 |
\SQRT{\yy}{\Dy} |
| 5063 |
\DIVIDE{-1}{\Dy}{\Dy}} |
| 5064 |
% \end{macrocode} |
| 5065 |
% \end{macro} |
| 5066 |
% \begin{macro}{\ARCTANfunction} |
| 5067 |
% The \cs{ARCTANfunction}: $y(t)=\arctan t$, $y'(t)=1/(1+t^2)$ |
| 5068 |
% \begin{macrocode} |
| 5069 |
\newfunction{\ARCTANfunction}{% |
| 5070 |
\ARCTAN{\t}{\y} |
| 5071 |
\SQUARE{\t}{\yy} |
| 5072 |
\ADD{1}{\yy}{\yy} |
| 5073 |
\DIVIDE{1}{\yy}{\Dy}} |
| 5074 |
% \end{macrocode} |
| 5075 |
% \end{macro} |
| 5076 |
% \begin{macro}{\ARCCOTfunction} |
| 5077 |
% The \cs{ARCCOTfunction}: $y(t)=\arccot t$, $y'(t)=-1/(1+t^2)$ |
| 5078 |
% \begin{macrocode} |
| 5079 |
\newfunction{\ARCCOTfunction}{% |
| 5080 |
\ARCCOT{\t}{\y} |
| 5081 |
\SQUARE{\t}{\yy} |
| 5082 |
\ADD{1}{\yy}{\yy} |
| 5083 |
\DIVIDE{-1}{\yy}{\Dy}} |
| 5084 |
% \end{macrocode} |
| 5085 |
% \end{macro} |
| 5086 |
% \changes{v2.0}{2014/02/13}{New commands: \cs{ARSINHfunction}, |
| 5087 |
% \cs{ARCOSHfunction}, \cs{ARTANHfunction}, |
| 5088 |
% \cs{ARCOTHfunction}} |
| 5089 |
% \begin{macro}{\ARSINHfunction} |
| 5090 |
% The \cs{ARSINHfunction}: $y(t)=\arsinh t$, $y'(t)=1/\sqrt{1+t^2}$ |
| 5091 |
% \begin{macrocode} |
| 5092 |
\newfunction{\ARSINHfunction}{% |
| 5093 |
\ARSINH{\t}{\y} |
| 5094 |
\SQUARE{\t}{\yy} |
| 5095 |
\ADD{1}{\yy}{\yy} |
| 5096 |
\SQRT{\yy}{\Dy} |
| 5097 |
\DIVIDE{1}{\Dy}{\Dy}} |
| 5098 |
% \end{macrocode} |
| 5099 |
% \end{macro} |
| 5100 |
% \begin{macro}{\ARCOSHfunction} |
| 5101 |
% The \cs{ARSINHfunction}: $y(t)=\arcosh t$, $y'(t)=1/\sqrt{t^2-1}$ |
| 5102 |
% \begin{macrocode} |
| 5103 |
\newfunction{\ARCOSHfunction}{% |
| 5104 |
\ARCOSH{\t}{\y} |
| 5105 |
\SQUARE{\t}{\yy} |
| 5106 |
\SUBTRACT{\yy}{1}{\yy} |
| 5107 |
\SQRT{\yy}{\Dy} |
| 5108 |
\DIVIDE{1}{\Dy}{\Dy}} |
| 5109 |
% \end{macrocode} |
| 5110 |
% \end{macro} |
| 5111 |
% \begin{macro}{\ARTANHfunction} |
| 5112 |
% The \cs{ARTANHfunction}: $y(t)=\artanh t$, $y'(t)=1/(t^2-1)$ |
| 5113 |
% \begin{macrocode} |
| 5114 |
\newfunction{\ARTANHfunction}{% |
| 5115 |
\ARTANH{\t}{\y} |
| 5116 |
\SQUARE{\t}{\yy} |
| 5117 |
\SUBTRACT{1}{\yy}{\yy} |
| 5118 |
\DIVIDE{1}{\yy}{\Dy}} |
| 5119 |
% \end{macrocode} |
| 5120 |
% \end{macro} |
| 5121 |
% \begin{macro}{\ARCOTHfunction} |
| 5122 |
% The \cs{ARCOTHfunction}: $y(t)=\arcoth t$, $y'(t)=1/(t^2-1)$ |
| 5123 |
% \begin{macrocode} |
| 5124 |
\newfunction{\ARCOTHfunction}{% |
| 5125 |
\ARCOTH{\t}{\y} |
| 5126 |
\SQUARE{\t}{\yy} |
| 5127 |
\SUBTRACT{1}{\yy}{\yy} |
| 5128 |
\DIVIDE{1}{\yy}{\Dy}} |
| 5129 |
% \end{macrocode} |
| 5130 |
% \end{macro} |
| 5131 |
% \subsection{Operations with functions} |
| 5132 |
% \begin{macro}{\CONSTANTfunction} |
| 5133 |
% \cs{CONSTANTfunction} defines \#2 as the constant function $f(t)=\#1$. |
| 5134 |
% \begin{macrocode} |
| 5135 |
\def\CONSTANTfunction#1#2{% |
| 5136 |
\def#2##1##2##3{% |
| 5137 |
\xdef##2{#1}% |
| 5138 |
\xdef##3{0}}} |
| 5139 |
% \end{macrocode} |
| 5140 |
% \end{macro} |
| 5141 |
% \begin{macro}{\SUMfunction} |
| 5142 |
% \cs{SUMfunction} defines \#3 as the sum of functions \#1 and \#2. |
| 5143 |
% \begin{macrocode} |
| 5144 |
\def\SUMfunction#1#2#3{% |
| 5145 |
\def#3##1##2##3{% |
| 5146 |
\begingroup |
| 5147 |
#1{##1}{\ccls@SUMf}{\ccls@SUMDf}% |
| 5148 |
#2{##1}{\ccls@SUMg}{\ccls@SUMDg}% |
| 5149 |
\ADD{\ccls@SUMf}{\ccls@SUMg}{\ccls@SUMfg} |
| 5150 |
\ADD{\ccls@SUMDf}{\ccls@SUMDg}{\ccls@SUMDfg} |
| 5151 |
\xdef##2{\ccls@SUMfg}% |
| 5152 |
\xdef##3{\ccls@SUMDfg}% |
| 5153 |
\endgroup}\ignorespaces} |
| 5154 |
% \end{macrocode} |
| 5155 |
% \end{macro} |
| 5156 |
% \begin{macro}{\SUBTRACTfunction} |
| 5157 |
% \cs{SUBTRACTfunction} defines \#3 as the difference of functions \#1 and \#2. |
| 5158 |
% \begin{macrocode} |
| 5159 |
\def\SUBTRACTfunction#1#2#3{% |
| 5160 |
\def#3##1##2##3{% |
| 5161 |
\begingroup |
| 5162 |
#1{##1}{\ccls@SUBf}{\ccls@SUBDf}% |
| 5163 |
#2{##1}{\ccls@SUBg}{\ccls@SUBDg}% |
| 5164 |
\SUBTRACT{\ccls@SUBf}{\ccls@SUBg}{\ccls@SUBfg} |
| 5165 |
\SUBTRACT{\ccls@SUBDf}{\ccls@SUBDg}{\ccls@SUBDfg} |
| 5166 |
\xdef##2{\ccls@SUBfg}% |
| 5167 |
\xdef##3{\ccls@SUBDfg}% |
| 5168 |
\endgroup}\ignorespaces} |
| 5169 |
% \end{macrocode} |
| 5170 |
% \end{macro} |
| 5171 |
% \begin{macro}{\PRODUCTfunction} |
| 5172 |
% \cs{PRODUCTfunction} defines \#3 as the product of functions \#1 and \#2. |
| 5173 |
% \begin{macrocode} |
| 5174 |
\def\PRODUCTfunction#1#2#3{% |
| 5175 |
\def#3##1##2##3{% |
| 5176 |
\begingroup |
| 5177 |
#1{##1}{\ccls@PROf}{\ccls@PRODf}% |
| 5178 |
#2{##1}{\ccls@PROg}{\ccls@PRODg}% |
| 5179 |
\MULTIPLY{\ccls@PROf}{\ccls@PROg}{\ccls@PROfg} |
| 5180 |
\MULTIPLY{\ccls@PROf}{\ccls@PRODg}{\ccls@PROfDg} |
| 5181 |
\MULTIPLY{\ccls@PRODf}{\ccls@PROg}{\ccls@PRODfg} |
| 5182 |
\ADD{\ccls@PROfDg}{\ccls@PRODfg}{\ccls@PRODfg} |
| 5183 |
\xdef##2{\ccls@PROfg}% |
| 5184 |
\xdef##3{\ccls@PRODfg}% |
| 5185 |
\endgroup}\ignorespaces} |
| 5186 |
% \end{macrocode} |
| 5187 |
% \end{macro} |
| 5188 |
% \begin{macro}{\QUOTIENTfunction} |
| 5189 |
% \cs{QUOTIENTfunction} defines \#3 as the quotient of functions \#1 and \#2. |
| 5190 |
% \begin{macrocode} |
| 5191 |
\def\QUOTIENTfunction#1#2#3{% |
| 5192 |
\def#3##1##2##3{% |
| 5193 |
\begingroup |
| 5194 |
#1{##1}{\ccls@QUOf}{\ccls@QUODf}% |
| 5195 |
#2{##1}{\ccls@QUOg}{\ccls@QUODg}% |
| 5196 |
\DIVIDE{\ccls@QUOf}{\ccls@QUOg}{\ccls@QUOfg} |
| 5197 |
\MULTIPLY{\ccls@QUOf}{\ccls@QUODg}{\ccls@QUOfDg} |
| 5198 |
\MULTIPLY{\ccls@QUODf}{\ccls@QUOg}{\ccls@QUODfg} |
| 5199 |
\SUBTRACT{\ccls@QUODfg}{\ccls@QUOfDg}{\ccls@QUOnum} |
| 5200 |
\SQUARE{\ccls@QUOg}{\ccls@qsquaretempg} |
| 5201 |
\DIVIDE{\ccls@QUOnum}{\ccls@qsquaretempg}{\ccls@QUODfg} |
| 5202 |
\xdef##2{\ccls@QUOfg}% |
| 5203 |
\xdef##3{\ccls@QUODfg}% |
| 5204 |
\endgroup}\ignorespaces} |
| 5205 |
% \end{macrocode} |
| 5206 |
% \end{macro} |
| 5207 |
% \begin{macro}{\COMPOSITIONfunction} |
| 5208 |
% \cs{COMPOSITIONfunction} defines \#3 as the composition |
| 5209 |
% of functions \#1 and \#2. |
| 5210 |
% \begin{macrocode} |
| 5211 |
\def\COMPOSITIONfunction#1#2#3{% #3=#1(#2) |
| 5212 |
\def#3##1##2##3{% |
| 5213 |
\begingroup |
| 5214 |
#2{##1}{\ccls@COMg}{\ccls@COMDg}% |
| 5215 |
#1{\ccls@COMg}{\ccls@COMf}{\ccls@COMDf}% |
| 5216 |
\MULTIPLY{\ccls@COMDg}{\ccls@COMDf}{\ccls@COMDf} |
| 5217 |
\xdef##2{\ccls@COMf}% |
| 5218 |
\xdef##3{\ccls@COMDf}% |
| 5219 |
\endgroup}\ignorespaces} |
| 5220 |
% \end{macrocode} |
| 5221 |
% \end{macro} |
| 5222 |
% \begin{macro}{\SCALEfunction} |
| 5223 |
% \cs{SCALEfunction} defines \#3 as the product of number \#1 and function \#2. |
| 5224 |
% \begin{macrocode} |
| 5225 |
\def\SCALEfunction#1#2#3{% |
| 5226 |
\def#3##1##2##3{% |
| 5227 |
\begingroup |
| 5228 |
#2{##1}{\ccls@SCFf}{\ccls@SCFDf}% |
| 5229 |
\MULTIPLY{#1}{\ccls@SCFf}{\ccls@SCFaf} |
| 5230 |
\MULTIPLY{#1}{\ccls@SCFDf}{\ccls@SCFDaf} |
| 5231 |
\xdef##2{\ccls@SCFaf}% |
| 5232 |
\xdef##3{\ccls@SCFDaf}% |
| 5233 |
\endgroup}\ignorespaces} |
| 5234 |
% \end{macrocode} |
| 5235 |
% \end{macro} |
| 5236 |
% \begin{macro}{\SCALEVARIABLEfunction} |
| 5237 |
% \cs{SCALEVARIABLEfunction} scales the variable by number \#1 |
| 5238 |
% and aplies function \#2. |
| 5239 |
% \begin{macrocode} |
| 5240 |
\def\SCALEVARIABLEfunction#1#2#3{% |
| 5241 |
\def#3##1##2##3{% |
| 5242 |
\begingroup% |
| 5243 |
\MULTIPLY{#1}{##1}{\ccls@SCVat} |
| 5244 |
#2{\ccls@SCVat}{\ccls@SCVf}{\ccls@SCVDf}% |
| 5245 |
\MULTIPLY{#1}{\ccls@SCVDf}{\ccls@SCVDf} |
| 5246 |
\xdef##2{\ccls@SCVf}% |
| 5247 |
\xdef##3{\ccls@SCVDf}% |
| 5248 |
\endgroup}\ignorespaces} |
| 5249 |
% \end{macrocode} |
| 5250 |
% \end{macro} |
| 5251 |
% \begin{macro}{\POWERfunction} |
| 5252 |
% \cs{POWERfunction} defines \#3 as the power of function \#1 to exponent \#2. |
| 5253 |
% \begin{macrocode} |
| 5254 |
\def\POWERfunction#1#2#3{% |
| 5255 |
\def#3##1##2##3{% |
| 5256 |
\begingroup |
| 5257 |
#1{##1}{\ccls@POWf}{\ccls@POWDf}% |
| 5258 |
\POWER{\ccls@POWf}{#2}{\ccls@POWfn} |
| 5259 |
\SUBTRACT{#2}{1}{\ccls@nminusone} |
| 5260 |
\POWER{\ccls@POWf}{\ccls@nminusone}{\ccls@POWDfn} |
| 5261 |
\MULTIPLY{#2}{\ccls@POWDfn}{\ccls@POWDfn} |
| 5262 |
\MULTIPLY{\ccls@POWDfn}{\ccls@POWDf}{\ccls@POWDfn} |
| 5263 |
\xdef##2{\ccls@POWfn}% |
| 5264 |
\xdef##3{\ccls@POWDfn}% |
| 5265 |
\endgroup}\ignorespaces} |
| 5266 |
% \end{macrocode} |
| 5267 |
% \end{macro} |
| 5268 |
% \begin{macro}{\LINEARCOMBINATIONfunction} |
| 5269 |
% \cs{LINEARCOMBINATIONfunction} defines the new function \#5 |
| 5270 |
% as the linear combination \#1\#2+\#3\#4. |
| 5271 |
% \#1 and \#3 are two numbers. \#1 and \#3 are two functions. |
| 5272 |
|
| 5273 |
% \begin{macrocode} |
| 5274 |
\def\LINEARCOMBINATIONfunction#1#2#3#4#5{% |
| 5275 |
\def#5##1##2##3{% |
| 5276 |
\begingroup |
| 5277 |
#2{##1}{\ccls@LINf}{\ccls@LINDf}% |
| 5278 |
#4{##1}{\ccls@LINg}{\ccls@LINDg}% |
| 5279 |
\MULTIPLY{#1}{\ccls@LINf}{\ccls@LINf} |
| 5280 |
\MULTIPLY{#3}{\ccls@LINg}{\ccls@LINg} |
| 5281 |
\MULTIPLY{#1}{\ccls@LINDf}{\ccls@LINDf} |
| 5282 |
\MULTIPLY{#3}{\ccls@LINDg}{\ccls@LINDg} |
| 5283 |
\ADD{\ccls@LINf}{\ccls@LINg}{\ccls@LINafbg} |
| 5284 |
\ADD{\ccls@LINDf}{\ccls@LINDg}{\ccls@LINDafbg} |
| 5285 |
\xdef##2{\ccls@LINafbg}% |
| 5286 |
\xdef##3{\ccls@LINDafbg}% |
| 5287 |
\endgroup}\ignorespaces} |
| 5288 |
% \end{macrocode} |
| 5289 |
% \end{macro} |
| 5290 |
% \begin{macro}{\POLARfunction} |
| 5291 |
% \cs{POLARfunction} defines the polar curve \#2. |
| 5292 |
% \#1 is a previously defined function. |
| 5293 |
% \begin{macrocode} |
| 5294 |
\def\POLARfunction#1#2{% |
| 5295 |
\PRODUCTfunction{#1}{\COSfunction}{\ccls@polarx} |
| 5296 |
\PRODUCTfunction{#1}{\SINfunction}{\ccls@polary} |
| 5297 |
\PARAMETRICfunction{\ccls@polarx}{\ccls@polary}{#2}} |
| 5298 |
% \end{macrocode} |
| 5299 |
% \end{macro} |
| 5300 |
% \begin{macro}{\PARAMETRICfunction} |
| 5301 |
% \cs{PARAMETRICfunction} defines the parametric curve \#3. |
| 5302 |
% \#1 and \#2 are the components functions (two previuosly defined functions). |
| 5303 |
% \begin{macrocode} |
| 5304 |
\def\PARAMETRICfunction#1#2#3{% |
| 5305 |
\def#3##1##2##3##4##5{% |
| 5306 |
#1{##1}{##2}{##3} |
| 5307 |
#2{##1}{##4}{##5}}} |
| 5308 |
% \end{macrocode} |
| 5309 |
% \end{macro} |
| 5310 |
% \begin{macro}{\VECTORfunction} |
| 5311 |
% \cs{VECTORfunction}: an alias of \cs{PARAMETRICfunction}. |
| 5312 |
% \begin{macrocode} |
| 5313 |
\let\VECTORfunction\PARAMETRICfunction |
| 5314 |
% \end{macrocode} |
| 5315 |
% \end{macro} |
| 5316 |
% |
| 5317 |
% |
| 5318 |
% \begin{macrocode} |
| 5319 |
% </calculus> |
| 5320 |
% \end{macrocode} |
| 5321 |
% \Finale |
| 5322 |
% |