Calculator
Calculator
Abstract
The calculator package allows us to use LATEX as a calculator, with which we can perform
many of the common scientific calculations (with the limitation in accuracy imposed by the
TEX arithmetic).
This package introduces several new instructions that allow you to do several calculations
with integer and decimal numbers using LATEX. Apart from add, multiply or divide, we can
calculate powers, square roots, logarithms, trigonometric and hyperbolic functions . . .
In addition, the calculator package supports some elementary calculations with vectors
in two and three dimensions and square 2 2 and 3 3 matrices.
The calculus package adds to the calculator package several utilities to use and define
various functions and their derivatives, including elementary functions, operations with
functions, polar coordinates and vector-valued real functions.
Version 2.0 adds new capabilities to both packages. Specifically, now, calculator and
calculus can evaluate the inverse trigonometric and the inverse hyperbolic functions (so that
we can work with all the classic elementary functions), and also can do some additional
calculation with vectors (such as the cross product and the angle between two vectors).
Contents
1 Introduction
2 Predefined numbers
5
5
6
This
3.3
3.4
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
15
5 Matrix arithmetic
5.1 Vector operations . . . . . . . . . . . . . . . . . . . . . .
5.1.1 Assignments . . . . . . . . . . . . . . . . . . . .
5.1.2 Vector addition and subtraction . . . . . . . . .
5.1.3 Scalar-vector product . . . . . . . . . . . . . . .
5.1.4 Scalar (dot) product and euclidean norm . . . .
5.1.5 Vector (cross) product (new in version 2.0) . . .
5.1.6 Unit vector parallel to a given vector (normalized
5.1.7 Absolute value (in each entry of a given vector) .
5.1.8 Angle between two vectors (new in version 2.0) .
5.2 Matrix operations . . . . . . . . . . . . . . . . . . . . .
5.2.1 Assignments . . . . . . . . . . . . . . . . . . . .
5.2.2 Transposed matrix . . . . . . . . . . . . . . . . .
5.2.3 Matrix addition and subtraction . . . . . . . . .
5.2.4 Scalar-matrix product . . . . . . . . . . . . . . .
5.2.5 Matriu-vector product . . . . . . . . . . . . . . .
5.2.6 Product of two square matrices . . . . . . . . . .
5.2.7 Determinant . . . . . . . . . . . . . . . . . . . .
5.2.8 Inverse matrix . . . . . . . . . . . . . . . . . . .
5.2.9 Absolute value (in each entry) . . . . . . . . . .
5.2.10 Solving a linear system . . . . . . . . . . . . . .
II
6
7
7
8
8
9
10
10
10
10
10
11
13
14
14
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
vector)
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
15
16
16
16
16
17
17
17
18
18
18
18
19
19
20
20
20
21
21
22
22
22
6 What is a function?
23
7 Predefined functions
23
24
9 Polynomial functions
26
27
28
12 Low-level instructions
28
12.1 The \newfunction declaration and its variants . . . . . . . . . . . . . . . . . . . 28
12.2 Vector functions and polar coordinates . . . . . . . . . . . . . . . . . . . . . . . . 29
III
Implementation
30
13 calculator
13.1 Internal lengths and special numbers
13.2 Warning messages . . . . . . . . . .
13.3 Operations with numbers . . . . . .
13.4 Matrix arithmetics . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
30
30
31
33
56
14 calculus
14.1 Error and info messages .
14.2 New functions . . . . . . .
14.3 Polynomials . . . . . . . .
14.4 Elementary functions . . .
14.5 Operations with functions
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
69
69
71
73
76
79
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Introduction
The calculator package defines some instructions which allow us to realize algebraic operations
(and to evaluate elementary functions) in our documents. The operations implemented by the
calculator package include routines of assignment of variables, arithmetical calculations with
real and integer numbers, two and three dimensional vector and matrix arithmetics and the
computation of square roots, trigonometrical, exponential,
logarithmic and hyperbolic functions.
the control sequences that represent special numbers (as \numberPI) does not need any argument.
\tempA=2,5^2
\SQUARE{2.5}{\tempA}
% \tempB=sqrt(12)
\SQUAREROOT{12}{\tempB}
% \tempC=exp(3,4)
\EXP{3.4}{\tempC}
% \divisio=\tempA/tempB
\DIVIDE{\tempA}{\tempB}{\divisio}
% \sol=\divisio+\tempC
\ADD{\divisio}{\tempC}{\sol}
\begin{align*}
\frac{2.5^2}{\sqrt{12}}+\mathrm{e}^{3.4}
&= \frac{\tempA}{\tempB}+\tempC \\
&= \divisio+\tempC \\
&=\sol
\end{align*}
2.52
6.25
+ e3.4 =
+ 29.96432
3.4641
12
= 1.80421 + 29.96432
= 31.76854
Observe that, in this example, we have followed exactly the same steps that we would do to
2.52
calculate
+ e3.4 with a standard calculator: We would calculate the square, the root and
12
the exponential and, finally, we would divide and add the results.
It does not matter if the arguments results are or not predefined. But these commands act
as declarations, so that its scope is local in environments and groups.
Ex. 2
\SQUARE{5}\sol
The \texttt{\textbackslash sol}
command contains the square of $5$:
\[5^2=\sol\]
\begin{center}
\SQUAREROOT{5}\sol
Now, the \texttt{\textbackslash sol}
command is the square root of $5$:
\[\sqrt{5}=\sol\]
\end{center}
On having gone out of the \texttt{center}
environment,
the command recovers its previous value:
\sol
5 = 2.23605
On having gone out of the center environment, the command recovers its previous
value: 25
The calculus package goes a step further and allows us to define and use in a user-friendly
manner various functions and their derivatives.
For exemple, using the calculus package, you can define the f (t) = t2 et cos 2t function as
follows:
%
%
%
\PRODUCTfunction{\SQUAREfunction}{\EXPfunction}{\tempfunctionA}
\SCALEVARIABLEfunction{2}{\COSfunction}{\tempfunctionB}
\SUBTRACTfunction{\tempfunctionA}{\tempfunctionB}{\Ffunction}
Then you cau compute any value of the new function \Ffunction and its derivative: typing
\Ffunction{hnumi}{h\sol i}{h\Dsol i}
the values of f (num) and f 0 (num) will be stored in \sol and \Dsol .
Part I
Predefined numbers
3
3.1
3.14159
4.71237 3/2
0.78539 /4
0.52359 /6
2.71828 e
7.38902 e2
2.30258 log 10
1.61803
1.41421 2
2.23607 5
0.86603 cos /6
\numberHALFPI
\numberTHIRDPI
\numberFIFTHPI
\numberTWOPI
\numberINVE
\numberINVETWO
1.57079 /2
1.0472 /3
0.62831 /5
6.28317 2
0.36787 1/e
0.13533 1/e2
\numberINVGOLD
\numberSQRTTHREE
0.61803 1/
1.73205 3
\numberCOSXLV
0.70711 cos /4
The first command we describe here is used to store a number in a control sequence. The other
two commands in this section determine the maximum and minimum of a pair of numbers.
\COPY{hnumi}{h\cmd i} stores the number num to the command \cmd .
Ex. 3
\COPY{-1.256}{\sol}
\sol
-1.256
\MAX{hnum1 i}{hnum2 i}{h\cmd i} stores in \cmd the maximum of the numbers num1 and
num2 .
Ex. 4
\MAX{1.256}{3.214}{\sol}
\[\max(1.256,3.214)=\sol\]
\MIN{1.256}{3.214}{\sol}
\sol
1.256
3.2
Real arithmetic
3.2.1
\ADD{1.256}{3.214}{\sol}
$1.256+3.214=\sol$
\SUBTRACT{1.256}{3.214}{\sol}
$1.256-3.214=\sol$
\MULTIPLY{1.256}{3.214}{\sol}
$1.256\times3.214=\sol$
\DIVIDE{1.256}{3.214}{\sol}
$1.256/3.214=\sol$
1.256/3.214 = 0.39078
2 This
3.2.2
\SQUARE{-1.256}{\sol}
$(-1.256)^2=\sol$
(1.256)2 = 1.57751
\CUBE{hnumi}{h\cmd i} Cube of num .
Ex. 11
\CUBE{-1.256}{\sol}
$(-1.256)^3=\sol$
(1.256)3 = 1.98134
\POWER{hnumi}{hexpi}{h\cmd i} The exp power of num .
The exponent, exp , must be an integer (if you want to calculate powers with non integer
exponents, use the \EXP command).
Ex. 12
\POWER{-1.256}{-5}{\sola}
\POWER{-1.256}{5}{\solb}
\POWER{-1.256}{0}{\solc}
\[
\begin{aligned}
(-1.256)^{-5}&=\sola
\\
(-1.256)^{5}&=\solb
\\
(-1.256)^{0}&=\solc
\end{aligned}
\]
(1.256)5 = 0.31989
(1.256)5 = 3.1256
(1.256)0 = 1
3.2.3
\ABSVALUE{-1.256}{\sol}
$\left\vert-1.256\right\vert=\sol$
|1.256| = 1.256
\INTEGERPART{hnumi}{h\cmd i} Integer part of num .3
Ex. 14
\INTEGERPART{1.256}{\sola}
\INTEGERPART{-1.256}{\solb}
The integer part of $1.256$ is $\sola$,
but the integer part of $-1.256$ is $\solb$.
\FLOOR{1.256}{\sol}
The integer part of $1.256$ is $\sol$.
\FRACTIONALPART{1.256}{\sol}
\sol
0.256
0.744
3.2.4
\FRACTIONALPART{-1.256}{\sol}
\sol
\TRUNCATE[0]{1.25688}{\sol}
\sol
1
1.25
1.2568
\TRUNCATE[2]{1.25688}{\sol}
\sol
\TRUNCATE[4]{1.25688}{\sol}
\sol
Ex. 18
\ROUND[0]{1.25688}{\sol}
\sol
1
1.26
1.2569
\ROUND[2]{1.25688}{\sol}
\sol
\ROUND[4]{1.25688}{\sol}
\sol
3.3
Integers
The operations described here are subject to the same restrictions as those referring to decimal
numbers. In particular, although TEX does not have this restriction in its integer arithmetic,
the largest integer that can be used is 16383.
4 Note
3.3.1
\INTEGERDIVISION{435}{27}{\sola}{\solb}
$435=27\times\sola+\solb$
435 = 27 16 + 3
27 = 435 0 + 27
435 = 27 (17) + 24
435 = 27 (16) + 3
435 = 27 17 + 24
\INTEGERDIVISION{27}{435}{\sola}{\solb}
$27=435\times\sola+\solb$
\INTEGERDIVISION{-435}{27}{\sola}{\solb}
$-435=27\times(\sola)+\solb$
\INTEGERDIVISION{435}{-27}{\sola}{\solb}
$435=-27\times(\sola)+\solb$
\INTEGERDIVISION{-435}{-27}{\sola}{\solb}
$-435=-27\times\sola+\solb$
\INTEGERQUOTIENT{435}{27}{\sol}
\sol
16
0
-17
\INTEGERQUOTIENT{27}{435}{\sol}
\sol
\INTEGERQUOTIENT{-43.5}{2.7}{\sol}
\sol
\MODULO{hnum1 i}{hnum2 i}{h\cmd i} Remainder of the integer division of num1 and num2 .
Ex. 21
435 3
435 24
\MODULO{435}{27}{\sol}
\[
435 \equiv \sol \pmod{27}
\]
\MODULO{-435}{27}{\sol}
\[
-435 \equiv \sol \pmod{27}
\]
(mod 27)
(mod 27)
5 The scientific computing systems (such as Matlab. Scilab or Mathematica) do not always return a nonnegative residue especially when the divisor is negative. However, the most reasonable definition of integer
quotient is this one: the quotient of the division D/d is the largest number q for which dq D. With this
definition, the remainder r = D qd is a non-negative number.
3.3.2
\GCD{hnum1 i}{hnum2 i}{h\cmd i} Greatest common divisor of the integers num1 and num2 .
Ex. 22
\GCD{435}{27}{\sol}
$\gcd(435,27)=\sol$
gcd(435, 27) = 3
\LCM{hnum1 i}{hnum2 i}{h\cmd i} Least common multiple of num1 and num2 .
Ex. 23
\newcommand{\lcm}{\operatorname{lcm}}
\LCM{435}{27}{\sol}
$\lcm(435,27)=\sol$
3.3.3
Simplifying fractions
\FRACTIONSIMPLIFY{435}{27}{\sola}{\solb}
$435/27=\sola/\solb$
435/27 = 145/9
3.4
3.4.1
Elementary functions
Square roots
\SQUAREROOT{1.44}{\sol}
$\sqrt{1.44}=\sol$
1.44 = 1.2
The \EXP and \LOG commands compute, by default, exponentials and logarithms of the natural
base e. They admit, however, an optional argument to choose another base.
10
\EXP{0.5}{\sol}
$\exp(0.5)=\sol$
exp(0.5) = 1.64871
The argument num must be in the interval [9.704, 9.704].
Moreover, the \EXP command accepts an optional argument, to compute expressions such
as ax :
\EXP [hnum1 i]{hnum2 i}{h\cmd i} Exponential with base num1 of num2 . num1 must be a
positive number.
Ex. 27
\EXP[10]{1.3}{\sol}
$10^{1.3}=\sol$
101.3 = 19.95209
21/3 = 1.25989
\EXP[2]{0.33333}{\sol}
$2^{1/3}=\sol$
\LOG{0.5}{\sol}
$\log 0.5=\sol$
\LOG[10]{0.5}{\sol}
$\log_{10} 0.5=\sol$
3.4.3
Trigonometric functions
The arguments, in functions \SIN, \COS, . . . , are measured in radians. If you measure angles in
degrees (sexagesimal or not), use the \DEGREESSIN, \DEGREESCOS, . . . commands.
\SIN {hnumi}{h\cmd i} Sine of num .
\COS {hnumi}{h\cmd i} Cosine of num .
\TAN {hnumi}{h\cmd i} Tangent of num .
6 9.704
is the logarithm of 16383, the largest number that supports the TEXs arithmetic.
11
\SIN{\numberTHIRDPI}{\sol}
$\sin \pi/3=\sol$
sin /3 = 0.86601
cos /3 = 0.5
tan /3 = 1.73201
cot /3 = 0.57736
\COS{\numberTHIRDPI}{\sol}
$\cos \pi/3=\sol$
\TAN{\numberTHIRDPI}{\sol}
$\tan \pi/3=\sol$
\COT{\numberTHIRDPI}{\sol}
$\cot \pi/3=\sol$
\DEGREESSIN{60}{\sol}
$\sin 60^{\textrm o}=\sol$
\DEGREESCOS{60}{\sol}
$\cos 60^{\textrm o}=\sol$
\DEGREESTAN{60}{\sol}
$\tan 60^{\textrm o}=\sol$
\DEGREESCOT{60}{\sol}
$\cot 60^{\textrm o}=\sol$
The latter commands support an optional argument that allows us to divide the circle in an
arbitrary number of degrees (not necessarily 360).
\DEGREESSIN [hdegreesi]{hnumi}{h\cmd i}
\DEGREESCOS [hdegreesi]{hnumi}{h\cmd i}
\DEGREESTAN [hdegreesi]{hnumi}{h\cmd i}
\DEGREESCOT [hdegreesi]{hnumi}{h\cmd i}
By example, \DEGREESCOS[400]{50} computes the cosine of 50 gradians (a right angle has
100 gradians, the whole circle has 400 gradians), which are equivalent to 45 (sexagesimal) degrees
or /4 radians. Or to 1 degree, if we divide the circle into 8 parts!
12
Ex. 32
\DEGREESCOS[400]{50}{\sol}
\sol
0.70709
0.70709
0.7071
0.70709
\DEGREESCOS{45}{\sol}
\sol
\COS{\numberQUARTERPI}{\sol}
\sol
\DEGREESCOS[8]{1}{\sol}
\sol
\DEGtoRAD{60}{\sol}
\sol
1.0472
and two other commands to reduce arguments to basic intervals:
\REDUCERADIANSANGLE {hnumi}{h\cmd i} Reduces the arc num to the interval ] , ].
\REDUCEDEGREESANGLE {hnumi}{h\cmd i} Reduces the angle num to the interval ] 180, 180].
Ex. 34
\MULTIPLY{\numberTWOPI}{10}{\TWENTYPI}
\ADD{\numberPI}{\TWENTYPI}{\TWENTYONEPI}
\REDUCERADIANSANGLE{\TWENTYONEPI}{\sol}
\sol
3.14159
90
\REDUCEDEGREESANGLE{3690}{\sol}
\sol
3.4.4
Hyperbolic functions
13
Ex. 35
\SINH{1.256}{\sol}
\sol
1.61328
1.89807
0.84995
1.17651
\COSH{1.256}{\sol}
\sol
\TANH{1.256}{\sol}
\sol
\COTH{1.256}{\sol}
\sol
3.4.5
\ARCSIN{0.5}{\sol}
\sol
0.5236
1.04718
1.04718
2.35619
\ARCCOS{0.5}{\sol}
\sol
\ARCTAN{\numberSQRTTHREE}{\sol}
\sol
\ARCCOT{-1}{\sol}
\sol
3.4.6
\ARSINH {hnumi}{h\cmd i} stores in \cmd the arsinh (inverse of hyperbolic sine) of num .
\ARCOSH {hnumi}{h\cmd i} arcosh of num .
\ARTANH {hnumi}{h\cmd i} artanh of num .
\ARCOTH {hnumi}{h\cmd i} arcoth of num .
14
Ex. 37
\ARSINH{1}{\sol}
\sol
0.88138
0
0.5493
0.5493
\ARCOSH{1}{\sol}
\sol
\ARTANH{0.5}{\sol}
\sol
\ARCOTH{2}{\sol}
\sol
\LENGTHDIVIDE{1in}{1cm}{\sol}
One inch equals $\sol$ centimeters.
\newlength{\mylength}
\LENGTHADD{1in}{1cm}{\mylength}
$1in+1cm=\the\mylength$.
\LENGTHSUBTRACT{1in}{1cm}{\mylength}
$1in-1cm=\the\mylength$.
Matrix arithmetic
The calculator package defines the commands described below to operate on vectors and
matrices. We only work with two or three-dimensional vectors and 2 2 and 3 3 matrices. Vectors are represented in the form (a1,a2) or (a1,a2,a3);7 and, in the case
of matrices, columns are separated `
a la matlab by semicolons: (a11,a12;a21,a22) or
(a11,a12,a13;a21,a22,a23;a31,a32,a33).
7 But
15
5.1
5.1.1
Vector operations
Assignments
\VECTORCOPY(hx,y i)(h\cmd1,\cmd2 i) copy the entries of vector (hx,yi) to the \cmd1 and
\cmd2 commands.
\VECTORCOPY(hx,y,z i)(h\cmd1,\cmd2,\cmd3 i) copy the entries of vector (x ,y ,z ) to the
\cmd1 , \cmd2 and \cmd3 commands.
Ex. 40
\VECTORCOPY(1,-1)(\sola,\solb)
$(\sola,\solb)$
(1, 1)
(1, 1, 2)
5.1.2
\VECTORCOPY(1,-1,2)(\sola,\solb,\solc)
$(\sola,\solb,\solc)$
\VECTORADD(1,-1,2)(3,5,-1)(\sola,\solb,\solc)
$(1,-1,2)+(3,5,-1)=(\sola,\solb,\solc)$
5.1.3
\VECTORSUB(1,-1,2)(3,5,-1)(\sola,\solb,\solc)
$(1,-1,2)-(3,5,-1)=(\sola,\solb,\solc)$
Scalar-vector product
\SCALARVECTORPRODUCT{hnumi}(hx,y i) (h\cmd1,\cmd2 i)
\SCALARVECTORPRODUCT{hnumi}(hx,y,z i) (h\cmd1,\cmd2,\cmd3 i)
Ex. 42
\SCALARVECTORPRODUCT{2}(3,5)(\sola,\solb)
$2(3,5)=(\sola,\solb)$
\SCALARVECTORPRODUCT{2}(3,5,-1)(%
\sola,\solb,\solc)
$2(3,5,-1)=(\sola,\solb,\solc)$
16
5.1.4
\SCALARPRODUCT(1,-1)(3,5){\sol}
$(1,-1)\cdot(3,5)=\sol$
(1, 1) (3, 5) = 2
(1, 1, 2) (3, 5, 1) = 4
k(3, 4)k = 5
k(1, 2, 2)k = 3
\DOTPRODUCT(1,-1,2)(3,5,-1){\sol}
$(1,-1,2)\cdot(3,5,-1)=\sol$
\VECTORNORM(3,4)\sol
$\left\|(3,4)\right\|=\sol$
\VECTORNORM(1,2,-2)\sol
$\left\|(1,2,-2)\right\|=\sol$
5.1.5
\CROSSPRODUCT(1,-1,2)(3,5,-1)%
(\sola,\solb,\solc)
$(1,-1,2)\times(3,5,-1)=(\sola,\solb,\solc)$
\VECTORPRODUCT(1,-1,2)(-3,3,-6)%
(\sola,\solb,\solc)
$(1,-1,2)\times(-3,3,-6)=(\sola,\solb,\solc)$
5.1.6
\UNITVECTOR(hx,y i)(h\cmd1,\cmd2 i)
\UNITVECTOR(hx,y,z i)(h\cmd1,\cmd2,\cmd3 i)
Ex. 45
\UNITVECTOR(3,4)(\sola,\solb)
$(\sola,\solb)$
(0.59999, 0.79999)
(0.33333, 0.66666, 0.66666)
\UNITVECTOR(1,2,-2)(\sola,\solb,\solc)
$(\sola,\solb,\solc)$
17
5.1.7
\VECTORABSVALUE(hx,y i)(h\cmd1,\cmd2 i)
\VECTORABSVALUE(hx,y,z i)(h\cmd1,\cmd2,\cmd3 i)
Ex. 46
\VECTORABSVALUE(3,-4)(\sola,\solb)
$(\sola,\solb)$
(3, 4)
(3, 4, 1)
5.1.8
\VECTORABSVALUE(3,-4,-1)(\sola,\solb,\solc)
$(\sola,\solb,\solc)$
\TWOVECTORSANGLE(1,1)(0,1){\sol}
$\sol$ radians
\RADtoDEG{\sol}{\degsol}
(or $\degsol$ degrees)
\TWOVECTORSANGLE(1,0,0)(0,1,0){\sol}
$\sol$
\RADtoDEG{\sol}{\degsol}
(or $\degsol$ degrees)
5.2
5.2.1
Matrix operations
Assignments
1
3
1
1
0
1
\MATRIXCOPY(1, -1, 2;
3, 0, 5;
-1, 1, 4)%
(\sola,\solb,\solc;
\sold,\sole,\solf;
\solg,\solh,\soli)
$\begin{bmatrix}
\sola & \solb & \solc \\
\sold & \sole & \solf \\
\solg & \solh & \soli
\end{bmatrix}$
2
5
4
18
Henceforth, we will present only the syntax for commands operating with 2 2 matrices. In
all cases, the syntax is similar if we work with 3 3 matrices. In the examples, we will work
with either 2 2 or 3 3 matrices.
5.2.2
Transposed matrix
5.2.3
1
0
T
1
=
1
\TRANSPOSEMATRIX(1,-1;3,0)%
(\sola,\solb;\solc,\sold)
$\begin{bmatrix}
1 & -1 \\ 3 & 0
\end{bmatrix}^T=\begin{bmatrix}
\sola & \solb \\ \solc & \sold
\end{bmatrix}$
3
0
1
3
+
0
3
1
3
0
3
\MATRIXADD(1,-1;3,0)(3,5;-3,2)%
(\sola,\solb;\solc,\sold)
$\begin{bmatrix}
1 & -1 \\ 3 & 0
\end{bmatrix}+
\begin{bmatrix}
3 & 5 \\ -3 & 2
\end{bmatrix}=\begin{bmatrix}
\sola & \solb \\ \solc & \sold
\end{bmatrix}$
5
4 4
=
2
0 2
5
2 6
=
2
6 2
\MATRIXSUB(1,-1;3,0)(3,5;-3,2)%
(\sola,\solb;\solc,\sold)
$\begin{bmatrix}
1 & -1 \\ 3 & 0
\end{bmatrix}\begin{bmatrix}
3 & 5 \\ -3 & 2
\end{bmatrix}=\begin{bmatrix}
\sola & \solb \\ \solc & \sold
\end{bmatrix}$
19
5.2.4
Scalar-matrix product
1
3 3
1
5.2.5
1
0
1
2
3
5 = 9
4
3
3
0
3
\SCALARMATRIXPRODUCT{3}(1,-1,2;
3, 0,5;
-1, 1,4)%
(\sola,\solb,\solc;
\sold,\sole,\solf;
\solg,\solh,\soli)
$3\begin{bmatrix}
1 & -1 & 2 \\ 3 & 0 & 5 \\ -1 & 1 & 4
\end{bmatrix}
=\begin{bmatrix}
\sola & \solb & \solc \\
\sold & \sole & \solf \\
\solg & \solh & \soli
\end{bmatrix}$
6
15
12
Matriu-vector product
5.2.6
1
2
\MATRIXVECTORPRODUCT(1,-1;
0, 2)(3,5)(\sola,\solb)
$\begin{bmatrix}
1 & -1 \\ 0 & 2
\end{bmatrix}
\begin{bmatrix}
3 \\ 5
\end{bmatrix}
=\begin{bmatrix}
\sola \\ \solb
\end{bmatrix}$
3
2
=
5
10
20
Ex. 53
1
3
1
5.2.7
1
0
1
\MATRIXPRODUCT(1,-1,2;3,0,5;-1,1,4)%
(3,5,-1;-3,2,-5;1,-2,3)%
(\sola,\solb,\solc;
\sold,\sole,\solf;
\solg,\solh,\soli)
\begin{multline*}
\begin{bmatrix}
1 & -1 & 2 \\ 3 & 0 & 5 \\ -1 & 1 & 4
\end{bmatrix}
\begin{bmatrix}
3 & 5 & -1 \\ -3 & 2 & -5 \\ 1 & -2 & 3
\end{bmatrix}\\
=\begin{bmatrix}
\sola & \solb & \solc \\
\sold & \sole & \solf \\
\solg & \solh & \soli
\end{bmatrix}
\end{multline*}
2
3
5 1
5 3 2 5
4
1 2 3
8
1 10
5
12
= 14
2 11 8
Determinant
5.2.8
1
0
1
\DETERMINANT(1,-1,2;3,0,5;-1,1,4){\sol}
\SpecialUsageIndex{\DETERMINANT}%
$\begin{vmatrix}
1 & -1 & 2 \\ 3 & 0 & 5 \\ -1 & 1 & 4
\end{vmatrix}=\sol$
2
5 = 18
4
Inverse matrix
1
5
1
0.625
=
0.375
0.125
0.125
\INVERSEMATRIX(1,-1;3,5)(%
\sola,\solb;\solc,\sold)
$\begin{bmatrix}
1 & -1 \\ 3 & 5
\end{bmatrix}^{-1}=
\begin{bmatrix}
\sola & \solb \\ \solc & \sold
\end{bmatrix}$
If the given matrix is singular, the calculator package returns a warning message and the
\cmd11 , . . . , commands are marqued as undefined.
21
5.2.9
1
3
1
5.2.10
1
0
1
\MATRIXABSVALUE(1,-1,2;3,0,5;-1,1,4)%
(\sola,\solb,\solc;
\sold,\sole,\solf;
\solg,\solh,\soli)
$\begin{bmatrix}
\sola & \solb & \solc \\
\sold & \sole & \solf \\
\solg & \solh & \soli
\end{bmatrix}$
2
5
4
\SOLVELINEARSYSTEM
(ha11,a12;a21,a22
i)(hb1,b2 i)(h\cmd1,\cmd2 i) solves the linear sys
a11 a12
x
b1
tem
=
and stores the solution in (\cmd1 ,\cmd2 ).
a21 a22
y
b2
Ex. 57
Solving the
1
3
1
\SOLVELINEARSYSTEM(1,-1,2;3,0,5;-1,1,4)%
(-4,4,-2)%
(\sola,\solb,\solc)
Solving the linear system
\[
\begin{bmatrix}
1 & -1 & 2 \\ 3 & 0 & 5 \\ -1 & 1 & 4
\end{bmatrix}\mathsf{X}=\begin{bmatrix}
-4\\4\\-2
\end{bmatrix}
\]
we obtain
$\mathsf{X}=\begin{bmatrix}
\sola \\ \solb\\ \solc
\end{bmatrix}$
linear system
4
1 2
0 5 X = 4
2
1 4
3
we obtain X = 5
1
If the given matrix is singular, the package calculator returns a warning message. When
system is indeterminate, in the bi-dimensional case one of the solutions is computed; if the
system is incompatible, then the \sola, . . . , commands are marqued as undefined. For
three equations systems, only determinate systems are solved.8
8 This
is the only command that does not behave the same way with 2 2 and 3 3 matrices.
22
Part II
What is a function?
From the point of view of this package, a function f is a pair of formulae: the first one calculates
f (t); the other, f 0 (t). Therefore, any function is applied using three arguments: the value of the
variable t, and two command names where f (t) and f 0 (t) will be stored. For example,
\SQUAREfunction{hnumi}{h\sol i}{h\Dsol i}
computes f (t) = t2 and f 0 (t) = 2t (where t =num), and stores the results in the commands \sol
and \Dsol.9
Ex. 58
\SQUAREfunction{3}{\sol}{\Dsol}
If $f(t)=t^2$, then
\[
f(3)=\sol \mbox{ and } f(3)=\Dsol
\]
If f (t) = t2 , then
f (3) = 9 and f 0 (3) = 6
For all functions defined here, you must use the following syntax:
\functionname {hnumi}{h\cmd1 i}{h\cmd2 i}
being num a number (or a command whose value is a number), and \cmd1 and \cmd2 two
control sequence names where the values of the function and its derivative (in this number) will
be stored.
The key difference between this functions and the instructions defined in the calculator package is the inclusion of the derivative; for example, the \SQUARE{3}{\sol} instruction computes,
only, the square power of number 3, while \SQUAREfunction{3}{\sol}{\Dsol} finds, also, the
corresponding derivative.
Predefined functions
The calculus package predefines the most commonly used elementary functions, and includes
several utilities for defining new ones. The predefined functions are the following:
9 Do not spect any control about the existence or differentiability of the function; if the function or the
derivative are not well defined, a TEX error will occur.
23
\ZEROfunction
\IDENTITYfunction
\SQUAREfunction
\SQRTfunction
\EXPfunction
\COSfunction
\TANfunction
\COSHfunction
\TANHfunction
\HEAVISIDEfunction
f (t) = 0
f (t) = t
f (t) = t2
f (t) = t
f (t) = exp t
f (t) = cos t
f (t) = tan t
f (t) = cosh t
f (t) = (
tanh t
0 si t < 0
f (t) =
1 si t 0
\ONEfunction
\RECIPROCALfunction
\CUBEfunction
f (t) = 1
f (t) = 1/t
f (t) = t3
\LOGfunction
\SINfunction
\COTfunction
\SINHfunction
\COTHfunction
f (t) = log t
f (t) = sin t
f (t) = cot t
f (t) = sinh t
f (t) = coth t
The following functions are added in version 2.0 (new in version 2.0)
\ARCCOSfunction
\ARCTANfunction
\ARCOSHfunction
\ARTANHfunction
f (t) = arccos t
f (t) = arctan t
f (t) = arcosh t
f (t) = artanh t
\ARCSINfunction
\ARCCOTfunction
\ARSINHfunction
\ARCOTHfunction
f (t) = arcsin t
f (t) = arccot t
f (t) = arsinh t
f (t) = arcoth t
In the following example, we use the \LOGfunction function to compute a table of the log
function and its derivative.
Ex. 59
x
1
2
3
4
5
6
$\begin{array}{cll}
x & \log x & \log x \\
\LOGfunction{1}{\logx}{\Dlogx}
1 &\logx & \Dlogx\\
\LOGfunction{2}{\logx}{\Dlogx}
2 &\logx & \Dlogx\\
\LOGfunction{3}{\logx}{\Dlogx}
3 &\logx & \Dlogx\\
\LOGfunction{4}{\logx}{\Dlogx}
4 &\logx & \Dlogx\\
\LOGfunction{5}{\logx}{\Dlogx}
5 &\logx & \Dlogx\\
\LOGfunction{6}{\logx}{\Dlogx}
6 &\logx & \Dlogx
\end{array}$
log x
log0 x
0
1
0.69315 0.5
1.0986
0.33333
1.38629 0.25
1.60942 0.2
1.79176 0.16666
We can define new functions using the following operations (the last argument is the name of
the new function):
\CONSTANTfunction{hnumi}{h\Functioni} defines \Function as the constant function num.
Example. Definition of the F (t) = 5 function:
\CONSTANTfunction{5}{\F}
24
25
% exp(-t)
\SCALEVARIABLEfunction
{-1}{\EXPfunction}
{\NEGEXPfunction}
If
f (t) = 3t2 2et cos t
then
% exp(-t)cos(t)
\PRODUCTfunction
{\NEGEXPfunction}
{\COSfunction}
{\NEGEXPCOSfunction}
f (5) = 74.99619
f 0 (5) = 29.99084
% 3t^2-2exp(-t)cos(t)
\LINEARCOMBINATIONfunction
{3}{\SQUAREfunction}
{-2}{\NEGEXPCOSfunction}
{\myfunction}
\myfunction{5}{\sol}{\Dsol}
If
\[
f(t)=3t^2-2\mathrm{e}^{-t}\cos t
\]
then
\[
\begin{gathered}
f(5)=\sol\\
f(5)=\Dsol
\end{gathered}
\]
Polynomial functions
Although polynomial functions can be defined using linear combinations of power functions, to
facilitate our work, the calculus package includes the following commands to define more easily
the polynomials of 1, 2, and 3 degrees: \newlpoly (new linear polynomial), \newqpoly (new
quadratic polynomial), and \newcpoly (new cubic polynomial):
\newlpoly{h\Functioni}{hai}{hbi} stores the p(t) = a + b t function in the \Function command.
26
% \mypoly=1-x^2+x^3
\newcpoly{\mypoly}{1}{0}{-1}{1}
\mypoly{2}{\sol}{\Dsol}
$p(2)=\Dsol$
p0 (2) = 8
These declarations behave similarly to to the declaration \newcommand: If the name you want to
assign to the new function is that of an already defined command, the calculus package returns
an error message and do not redefines this command. To obtain any alternative behavior, our
package includes three other sets of declarations:
\renewlpoly, \renewqpoly, \renewcpoly redefine the already existing command \Function .
If this command does not exist, then it is not defined and an error message occurs.
\ensurelpoly, \ensureqpoly, \ensurecpoly define a new function. If the command \Function
already exists, it is not redefined.
\forcelpoly, \forceqpoly, \forcecpoly define a new function. If the command \Function
already exists, it is redefined.
10
The instruction
\PARAMETRICfunction{h\Xfunctioni}{h\Yfunctioni} {h\myvectorfunctioni}
defines the new vector-valued function f (t) = (x(t), y(t)).
The first and second arguments are a pair of functions already defined and, the third, the
name of the new function we define. Once we have defined them, the new vector functions
requires five arguments:
\myvectorfunction {hnumi}{h\cmd1 i} {h\cmd2 i}{h\cmd3 i}{h\cmd4 i}
where
num is a number t,
\cmd1 and \cmd2 are two command names where the values of the x(t) function and its
derivative x0 (t) will be stored, and
\cmd3 and \cmd4 will store y(t) and y 0 (t).
27
\F{4}{\solx}{\Dsolx}{\soly}{\Dsoly}
0
11
12
Low-level instructions
Probably, many users of the package will not be interested in the implementation of the commands this package includes. If this is your case, you can ignore this section.
12.1
All the functions predefined by this package use the \newfunction declaration. This control
sequence works as follows:
\newfunction{h\Functioni}{hInstructions to compute \y and \Dy from \t i}
where the second argument is the list of the instructions you need to run to calculate the value
of the function \y and the derivative \Dy in the \t point.
For example, if you want to define the f (t) = t2 + et cos t function, whose derivative is
0
f (t) = 2t + et (cos t sin t), using the high-level instructions we defined earlier, you can write
the following instructions:
\PRODUCTfunction{\EXPfunction}{\COSfunction}{\ffunction}
\SUMfunction{\SQUAREfunction}{\ffunction}{\Ffunction}
But you can also define this function using the \newfunction command as follows:
28
\newfunction{\Ffunction}{%
\SQUARE{\t}{\tempA}
\EXP{\t}{\tempB}
\COS{\t}{\tempC}
\SIN{\t}{\tempD}
\MULTIPLY{2}{\t}{\tempE}
\MULTIPLY{\tempB}{\tempC}{\tempC}
\MULTIPLY{\tempB}{\tempD}{\tempD}
\ADD{\tempA}{\tempC}{\y}
\ADD{\tempE}{\tempC}{\tempC}
\SUBTRACT{\tempC}{\tempD}{\Dy}
}
%
%
%
%
%
%
%
A=t^2
B=e^t
C=cos(t)
D=sin(t)
E=2t
C=e^t cos(t)
D=e^t sin(t)
% y=t^2 + e^t cos(t)
% C=t^2 + e^t cos(t)
% y=t^2 + e^t cos(t) - e^t sin(t)
It must be said, however, that the \newfunction declaration behaves similarly to \newcommand
or \newlpoly: If the name you want to assign to the new function is that of an already defined command, the calculus package returns an error message and does not redefines this command. To obtain any alternative behavior, our package includes three other versions of the
\newfunction declarations: the \renewfunction, \ensurefunction and \forcefunction declarations. Each of these declarations behaves differently:
\newfunction defines a new function. If the command \Function already exists, it is not
redefined and an error message occurs.
\renewfunction redefines the already existing command \Function . If this command does
not exists, then it is not defined and an error message occurs.
\ensurefunction defines a new function. If the command \Function already exists, it is not
redefined.
\forcefunction defines a new function. If the command \Function already exists, it is redefined.
12.2
You can (re)define a vector function f (t) = (x(t), y(t)) using the \newvectorfunction
declaration or any of its variants \renewvectorfunction, \ensurevectorfunction and
\forcevectorfunction:
\newvectorfunction{h\Functioni}{hInstructions to compute \x, \Dx, \y and \Dy from \t i}
For example, you can define the function f (t) = (t2 , t3 ) in the following way:
\newvectorfunction{\F}{%
\SQUARE{\t}{\x}
\MULTIPLY{2}{\t}{\Dx}
\CUBE{\t}{\y}
\MULTIPLY{3}{\x}{\Dy}
}
%
%
%
%
x=t^2
x=2t
y=t^3
y=3t^2
29
Finally, to define the r = r() function, in polar coordinates, we have the declarations
\newpolarfunction, \renewpolarfunction, \ensurepolarfunction and \forcepolarfunction.
\newpolarfunction{h\Functioni}{hInstructions to compute \r and \Dr from \t i}
For example, you can define the cardioide curve r() = 1+cos , using high level instructions,
\SUMfunction{\ONEfunction}{\COSfunction}{\ffunction} % y=1 + cos t
\POLARfunction{\ffunction}{\cardioide}
or, with the \newpolarfunction declaration,
\newpolarfunction{\cardioide}{%
\COS{\t}{\r}
\ADD{1}{\r}{\r}
% r=1+cos t
\SIN{\t}{\Dr}
\MULTIPLY{-1}{\Dr}{\Dr} % r=-sin t
}
Part III
Implementation
13
calculator
hcalculatori
\NeedsTeXFormat{LaTeX2e}
3 \ProvidesPackage{calculator}[2014/02/20 v.2.0]
13.1
\cctr@epsilon
\cctr@epsilon will store the closest to zero length in the TEX arithmetic: one scaled point
(1 sp = 1/65536 pt). This means the smallest positive number will be 0.00002 1/65536 =
1/216 .
6
7
\cctr@logmaxnum
\newdimen\cctr@lengtha
\newdimen\cctr@lengthb
\newdimen\cctr@epsilon
\cctr@epsilon=1sp
The largest TEX number is 16383.99998 214 ; \cctr@logmaxnum is the logarithm of this number, 9.704 log 16384.
8
\def\cctr@logmaxnum{9.704}
30
13.2
Warning messages
\def\cctr@Warndivzero#1#2{%
\PackageWarning{calculator}%
11
{Division by 0.\MessageBreak
12
I cant define #1/#2}}
9
10
13
\def\cctr@Warnnogcd{%
\PackageWarning{calculator}%
16
{gcd(0,0) is not well defined}}
14
15
17
\def\cctr@Warnnoposrad#1{%
\PackageWarning{calculator}%
20
{The argument in square root\MessageBreak
21
must be non negative\MessageBreak
22
I cant define sqrt(#1)}}
18
19
23
\def\cctr@Warnnointexp#1#2{%
\PackageWarning{calculator}%
26
{The exponent in power function\MessageBreak
27
must be an integer\MessageBreak
28
I cant define #1^#2}}
24
25
29
\def\cctr@Warnbigarcsin#1{%
\PackageWarning{calculator}%
32
{The argument in arcsin\MessageBreak
33
must be a number between -1 and 1\MessageBreak
34
I cant define arcsin(#1)}}
30
31
35
\def\cctr@Warnbigarccos#1{%
\PackageWarning{calculator}%
38
{The argument in arccos\MessageBreak
39
must be a number between -1 and 1\MessageBreak
40
I cant define arccos(#1)}}
36
37
41
\def\cctr@Warnsmallarcosh#1{%
\PackageWarning{calculator}%
44
{The argument in arcosh\MessageBreak
45
must be a number greater or equal than 1\MessageBreak
46
I cant define arcosh(#1)}}
42
43
47
\def\cctr@Warnbigartanh#1{%
\PackageWarning{calculator}%
50
{The argument in artanh\MessageBreak
51
must be a number between -1 and 1\MessageBreak
52
I cant define artanh(#1)}}
48
49
53
\def\cctr@Warnsmallarcoth#1{%
\PackageWarning{calculator}%
56
{The argument in arcoth\MessageBreak
57
must be a number greater than 1\MessageBreak
54
55
31
58
59
60
\def\cctr@Warnsingmatrix#1#2#3#4{%
\PackageWarning{calculator}%
63
{Matrix (#1 #2 ; #3 #4) is singular\MessageBreak
64
Its inverse is not defined}}
61
62
65
\def\cctr@WarnsingTDmatrix#1#2#3#4#5#6#7#8#9{%
\PackageWarning{calculator}%
68
{Matrix (#1 #2 #3; #4 #5 #6; #7 #8 #9) is singular\MessageBreak
69
Its inverse is not defined}}
66
67
70
71
72
\def\cctr@WarnIncLinSys{\PackageWarning{calculator}{%
Incompatible linear system}}
73
\def\cctr@WarnIncTDLinSys{\PackageWarning{calculator}{%
Incompatible or indeterminate linear system\MessageBreak
76
For 3x3 systems I can solve only determinate systems}}
74
75
77
\def\cctr@WarnIndLinSys{\PackageWarning{calculator}{%
Indeterminate linear system.\MessageBreak
80
I will choose one of the infinite solutions}}
78
79
81
\def\cctr@WarnZeroLinSys{\PackageWarning{calculator}{%
0x=0 linear system. Every vector is a solution!\MessageBreak
84
I will choose the (0,0) solution}}
82
83
85
\def\cctr@Warninftan#1{%
\PackageWarning{calculator}{%
88
Undefined tangent.\MessageBreak
89
The cosine of #1 is zero and, then,\MessageBreak
90
the tangent of #1 is not defined}}
86
87
91
\def\cctr@Warninfcotan#1{%
\PackageWarning{calculator}{%
94
Undefined cotangent.\MessageBreak
95
The sine of #1 is zero and, then,\MessageBreak
96
the cotangent of #1 is not defined}}
92
93
97
\def\cctr@Warninfexp#1{%
\PackageWarning{calculator}{%
100
The absolute value of the variable\MessageBreak
101
in the exponential function must be less than
102
\cctr@logmaxnum\MessageBreak
103
(the logarithm of the max number I know)\MessageBreak
104
I cant define exp(#1)}}
98
99
105
106
107
\def\cctr@Warninfexpb#1#2{%
\PackageWarning{calculator}{%
32
The base\MessageBreak
in the exponential function must be positive.
\MessageBreak
I cant define #1^(#2)}}
108
109
110
111
112
\def\cctr@Warninflog#1{%
\PackageWarning{calculator}{%
115
The value of the variable\MessageBreak
116
in the logarithm function must be positive\MessageBreak
117
I cant define log(#1)}}
113
114
118
\def\cctr@Warncrossprod(#1)(#2){%
\PackageWarning{calculator}%
121
{Vector product only defined\MessageBreak
122
for 3 dimmensional vectors.\MessageBreak
123
I cant define (#1)x(#2)}}
119
120
124
\def\cctr@Warnnoangle(#1)(#2){%
\PackageWarning{calculator}%
127
{Angle between two vectors only defined\MessageBreak
128
for nonzero vectors.\MessageBreak
129
I cant define an angle between (#1) and (#2)}}
125
126
13.3
\GLOBALCOPY
Global version of \COPY. The new defined command #2 is not changed outside groups.
131
\@OUTPUTSOL
\def\GLOBALCOPY#1#2{\xdef#2{#1}\ignorespaces}
\@OUTPUTSOLS
\def\COPY#1#2{\edef#2{#1}\ignorespaces}
\def\@OUTPUTSOL#1{\GLOBALCOPY{#1}{\cctr@outa}\endgroup\COPY{\cctr@outa}{#1}}
133
134
\MAX
\MAX{h#1 i}{h#2 i}{h#3 i} defines the #3 command as the maximum of numbers #1 and #2.
\def\MAX#1#2#3{%
\ifdim #1\p@ < #2\p@
138
\COPY{#2}{#3}\else\COPY{#1}{#3}\fi\ignorespaces}
136
137
33
\MIN
\MIN{h#1 i}{h#2 i}{h#3 i} defines the #3 command as the minimum of numbers #1 and #2.
\def\MIN#1#2#3{%
\ifdim #1\p@ > #2\p@
141
\COPY{#2}{#3}\else\COPY{#1}{#3}\fi\ignorespaces}
139
140
Real arithmetic
\ABSVALUE
\ABSVALUE{h#1 i}{h#2 i} defines the #2 command as the absolute value of number #1.
\def\ABSVALUE#1#2{%
\ifdim #1\p@<\z@
144
\MULTIPLY{-1}{#1}{#2}\else\COPY{#1}{#2}\fi}
142
143
\MULTIPLY{h#1 i}{h#2 i}{h#3 i} defines the #3 command as the product of numbers #1 and
#2.
\def\MULTIPLY#1#2#3{\cctr@lengtha=#1\p@
\cctr@lengtha=#2\cctr@lengtha
147
\edef#3{\expandafter\strip@pt\cctr@lengtha}\ignorespaces}
145
146
\ADD
\ADD{h#1 i}{h#2 i}{h#3 i} defines the #3 command as the sum of numbers #1 and #2.
\def\ADD#1#2#3{\cctr@lengtha=#1\p@
\cctr@lengthb=#2\p@
150
\advance\cctr@lengtha by \cctr@lengthb
151
\edef#3{\expandafter\strip@pt\cctr@lengtha}\ignorespaces}
148
149
\SUBTRACT
\SUBTRACT{h#1 i}{h#2 i}{h#3 i} defines the #3 command as the difference of numbers #1 and
#2.
152
\def\SUBTRACT#1#2#3{\ADD{#1}{-#2}{#3}}
Divisions We define several kinds of divisions: the quotient of two real numbers, the integer
quotient, and the quotient of two lengths. The basic algorithm is a lightly modified version of
the Beccaris division.
\DIVIDE
\DIVIDE{h#1 i}{h#2 i}{h#3 i} defines the #3 command as the quotient of numbers #1 and
#2.
153
154
\def\DIVIDE#1#2#3{%
\begingroup
\ABSVALUE{#1}{\cctr@tempD}
\ABSVALUE{#2}{\cctr@tempd}
\ifdim#1\p@<\z@\ifdim#2\p@>\z@\COPY{-1}{\cctr@sign}
\else\COPY{1}{\cctr@sign}\fi
\else\ifdim#2\p@>\z@\COPY{1}{\cctr@sign}
\else\COPY{-1}{\cctr@sign}\fi
\fi
34
\@DIVIDE{\cctr@tempD}{\cctr@tempd}{\cctr@tempq}{\cctr@tempr}
\COPY{\cctr@tempq.}{\cctr@Q}
Fractional part up to five decimal places. \cctr@ndec is the number of decimal places already
computed.
164
165
\COPY{0}{\cctr@ndec}
\@whilenum \cctr@ndec<5 \do{%
Each decimal place is calculated by multiplying by 10 the last remainder and dividing it by the
divisor. But when the remainder is greater than 1638.3, an overflow occurs, because 16383.99998
is the greatest number. So, instead, we multiply the divisor by 0.1.
166
167
168
169
170
171
172
173
174
\ifdim\cctr@tempr\p@<1638\p@
\MULTIPLY{\cctr@tempr}{10}{\cctr@tempD}
\else
\COPY{\cctr@tempr}{\cctr@tempD}
\MULTIPLY{\cctr@tempd}{0.1}{\cctr@tempd}
\fi
\@DIVIDE{\cctr@tempD}{\cctr@tempd}{\cctr@tempq}{\cctr@tempr}
\COPY{\cctr@Q\cctr@tempq}{\cctr@Q}
\ADD{1}{\cctr@ndec}{\cctr@ndec}}%
\@DIVIDE
The \@DIVIDE(h#1 i) (h#2 i)(h#3 i)(h#4 i) command computes #1/#2 and returns an integer
quotient (#3 ) and a real remainder (#4 ).
177
178
179
180
\@INTEGERDIVIDE
\MULTIPLY{\cctr@sign}{\cctr@Q}{#3}
\@OUTPUTSOL{#3}}
\def\@DIVIDE#1#2#3#4{%
\@INTEGERDIVIDE{#1}{#2}{#3}
\MULTIPLY{#2}{#3}{#4}
\SUBTRACT{#1}{#4}{#4}}
\@INTEGERDIVIDE divides two numbers (not necessarily integer) and returns an integer (this is
the integer quotient only for nonnegative integers).
\def\@INTEGERDIVIDE#1#2#3{%
\cctr@lengtha=#1\p@
183
\cctr@lengthb=#2\p@
184
\ifdim\cctr@lengthb=\z@
185
\let#3\undefined
186
\cctr@Warndivzero#1#2%
187
\else
188
\divide\cctr@lengtha\cctr@lengthb
189
\COPY{\number\cctr@lengtha}{#3}
190
\fi\ignorespaces}
181
182
\LENGTHADD
The sum of two lengths. \LENGTHADD{h#1 i}{h#2 i}{h#3 i} stores in #3 the sum of the lenghts
#1 and #2 (#3 must be a length).
191
\def\LENGTHADD#1#2#3{\cctr@lengtha=#1
35
\cctr@lengthb=#2
\advance\cctr@lengtha by \cctr@lengthb
\setlength{#3}{\cctr@lengtha}\ignorespaces}
192
193
194
\LENGTHSUBTRACT
The difference of two lengths. \LENGTHSUBTRACT{h#1 i}{h#2 i}{h#3 i} stores in #3 the difference of the lenghts #1 and #2 (#3 must be a length).
195
196
\LENGTHDIVIDE
\def\LENGTHSUBTRACT#1#2#3{%
\LENGTHADD{#1}{-#2}{#3}}
The quotient of two lengths must be a number (not a length). For example, one inch over one
centimeter equals 2.54. \LENGTHDIVIDE{h#1 i}{h#2 i}{h#3 i} stores in #3 the quotient of the
lenghts #1 and #2.
\def\LENGTHDIVIDE#1#2#3{%
\begingroup
199
\cctr@lengtha=#1
200
\cctr@lengthb=#2
201
\edef\cctr@tempa{\expandafter\strip@pt\cctr@lengtha}%
202
\edef\cctr@tempb{\expandafter\strip@pt\cctr@lengthb}%
203
\DIVIDE{\cctr@tempa}{\cctr@tempb}{#3}
204
\@OUTPUTSOL{#3}}
197
198
Powers
\SQUARE
\CUBE
\POWER
\def\SQUARE#1#2{\MULTIPLY{#1}{#1}{#2}}
\def\CUBE#1#2{\MULTIPLY{#1}{#1}{#2}\MULTIPLY{#2}{#1}{#2}}
208
This ensures that power will be defined only if the exponent is an integer.
214
\@POWER{#1}{#2}{#3}\fi\@OUTPUTSOL{#3}}
\def\@POWER#1#2#3{%
\begingroup
217
\ifdim #2\p@<\z@
215
216
\DIVIDE{1}{#1}{\cctr@tempb}
\MULTIPLY{-1}{#2}{\cctr@tempc}
\@POWER{\cctr@tempb}{\cctr@tempc}{#3}
\else
36
222
223
224
225
226
227
\COPY{0}{\cctr@tempa}
\COPY{1}{#3}
\@whilenum \cctr@tempa<#2 \do {%
\MULTIPLY{#1}{#3}{#3}
\ADD{1}{\cctr@tempa}{\cctr@tempa}}%
\fi\@OUTPUTSOL{#3}}
\INTEGERDIVISION{h#1 i}{h#2 i}{h#3 i}{h#4 i} computes the division #1/#2 and returns an
integer quotient and a positive remainder.
\def\INTEGERDIVISION#1#2#3#4{%
\begingroup
230
\ABSVALUE{#2}{\cctr@tempd}
231
\@DIVIDE{#1}{#2}{#3}{#4}
232
\ifdim #4\p@<\z@
233
\ifdim #1\p@<\z@
234
\ifdim #2\p@<\z@
235
\ADD{#3}{1}{#3}
236
\else
237
\SUBTRACT{#3}{1}{#3}
238
\fi
239
\ADD{#4}{\cctr@tempd}{#4}
240
\fi\fi\@OUTPUTSOLS{#3}{#4}}
228
229
\MODULO
242
\INTEGERQUOTIENT
245
\INTEGERPART
248
37
\FLOOR
\FRACTIONALPART
\let\FLOOR\INTEGERPART
263
\TRUNCATE
273
\ROUND
292
38
304
305
306
307
308
309
310
\GCD
\else
\DIVIDE{1}{\cctr@tempb}{\cctr@tempb}
\ADD{\cctr@tempe}{\cctr@tempb}{\cctr@tempe}
\fi
\@@TRUNCATE[#1]{\cctr@tempe}{#3}
\fi
\@OUTPUTSOL{#3}}
\GCD{h#1 i}{h#2 i}{h#3 i} Greatest common divisor, using the Euclidean algorithm
\def\GCD#1#2#3{%
\begingroup
313
\ABSVALUE{#1}{\cctr@tempa}
314
\ABSVALUE{#2}{\cctr@tempb}
315
\MAX{\cctr@tempa}{\cctr@tempb}{\cctr@tempc}
316
\MIN{\cctr@tempa}{\cctr@tempb}{\cctr@tempa}
317
\COPY{\cctr@tempc}{\cctr@tempb}
318
\ifnum \cctr@tempa = 0
319
\ifnum \cctr@tempb = 0
320
\cctr@Warnnogcd
321
\let#3\undefined
322
\else
323
\COPY{\cctr@tempb}{#3}
324
\fi
325
\else
311
312
Euclidean algorithm: if c b (mod a) then gcd(b, a) = gcd(a, c). Iterating this property, we
obtain gcd(b, a) as the last nonzero residual.
326
327
328
329
330
331
\LCM
\FRACTIONSIMPLIFY
\FRACTIONSIMPLIFY{h#1 i}{h#2 i}{h#3 i}{h#4 i} Fraction simplification: #3/#4 is the irreducible fraction equivalent to #1/#2.
\def\FRACTIONSIMPLIFY#1#2#3#4{%
\ifnum #1=\z@
342
\COPY{0}{#3}\COPY{1}{#4}
343
\else
340
341
39
344
345
346
347
348
\GCD{#1}{#2}{#3}%
\DIVIDE{#2}{#3}{#4}
\DIVIDE{#1}{#3}{#3}
\ifnum #4<0 \MULTIPLY{-1}{#4}{#4}\MULTIPLY{-1}{#3}{#3}\fi
\fi\ignorespaces}
Elementary functions
Square roots
\SQUAREROOT
\SQUAREROOT{h#1 i}{h#2 i} defines #2 as the square root of #1, using the Newtons method:
xn+1 = xn (x2n #1)/(2xn ).
\def\SQUAREROOT#1#2{%
\begingroup
351
\ifdim #1\p@ = \z@
352
\COPY{0}{#2}
353
\else
354
\ifdim #1\p@ < \z@
355
\let#2\undefined
356
\cctr@Warnnoposrad{#1}%
357
\else
349
350
\COPY{#1}{#2}
\cctr@lengthb=5\p@
Successive iterations
360
\COPY{#2}{\cctr@tempw}
\DIVIDE{#1}{\cctr@tempw}{\cctr@tempz}
\ADD{\cctr@tempw}{\cctr@tempz}{\cctr@tempz}
\DIVIDE{\cctr@tempz}{2}{\cctr@tempz}
\COPY{\cctr@tempz}{#2}
Finally, we store in \cctr@lengthb the difference of the two last approximations, finishing the
loop.
366
367
368
369
370
371
\SQRT
\SUBTRACT{#2}{\cctr@tempw}{\cctr@tempw}
\cctr@lengthb=\cctr@tempw\p@%
\ifnum
\cctr@lengthb<\z@ \cctr@lengthb=-\cctr@lengthb
\fi}
\fi\fi\@OUTPUTSOL{#2}}
\let\SQRT\SQUAREROOT
40
Trigonometric functions For a variable close enough to zero, the sine and tangent functions
are computed using some continued fractions. Then, all trigonometric functions are derived
from well-known formulas.
\SIN
\def\SIN#1#2{%
\begingroup
381
382
383
384
385
\@BASICSINE
\@BASICSINE{#1}{#2}
\else
\ifdim #1\p@<\numberTHREEHALFPI\p@
\SUBTRACT{\numberPI}{#1}{\cctr@tempb}
\SIN{\cctr@tempb}{#2}
\else
\SUBTRACT{#1}{\numberTWOPI}{\cctr@tempb}
\SIN{\cctr@tempb}{#2}
\fi\fi\fi\fi\fi\fi\@OUTPUTSOL{#2}}
sin x =
x2
1+
2 3 x2 +
2 3x2
4 5x2
4 5 x2 +
6 7 x2 +
\def\@BASICSINE#1#2{%
\begingroup
397
\ABSVALUE{#1}{\cctr@tempa}
395
396
\ifdim\cctr@tempa\p@=\z@ \COPY{0}{#2}
\else
\ifdim \cctr@tempa\p@<0.009\p@\COPY{#1}{#2}
\else
41
\COS
\SQUARE{#1}{\cctr@tempa}
\DIVIDE{\cctr@tempa}{42}{#2}
\SUBTRACT{1}{#2}{#2}
\MULTIPLY{#2}{\cctr@tempa}{#2}
\DIVIDE{#2}{20}{#2}
\SUBTRACT{1}{#2}{#2}
\MULTIPLY{#2}{\cctr@tempa}{#2}
\DIVIDE{#2}{6}{#2}
\SUBTRACT{1}{#2}{#2}
\MULTIPLY{#2}{#1}{#2}
\fi\fi\@OUTPUTSOL{#2}}
413
414
\TAN
\def\TAN#1#2{%
\begingroup
\ifdim #1\p@=-\numberHALFPI\p@
\cctr@Warninftan{#1}
\let#2\undefined
\else
\ifdim #1\p@=\numberHALFPI\p@
\cctr@Warninftan{#1}
\let#2\undefined
\else
\ifdim #1\p@<-\numberHALFPI\p@
\ADD{#1}{\numberPI}{\cctr@tempb}
\TAN{\cctr@tempb}{#2}
\else
\ifdim #1\p@<\numberHALFPI\p@
\@BASICTAN{#1}{#2}
\else
\SUBTRACT{#1}{\numberPI}{\cctr@tempb}
\TAN{\cctr@tempb}{#2}
\fi\fi\fi\fi\@OUTPUTSOL{#2}}
42
\@BASICTAN
1
1
1
3
1
x
5
1
x
7
1
x
9
1
x
11
x
x
\def\@BASICTAN#1#2{%
\begingroup
439
\ABSVALUE{#1}{\cctr@tempa}
437
438
\ifdim\cctr@tempa\p@=\z@ \COPY{0}{#2}
\else
\ifdim\cctr@tempa\p@<0.04\p@
\COPY{#1}{#2}
\else
\COT
\DIVIDE{#1}{11}{#2}
\DIVIDE{9}{#1}{\cctr@tempa}
\SUBTRACT{\cctr@tempa}{#2}{#2}
\DIVIDE{1}{#2}{#2}
\DIVIDE{7}{#1}{\cctr@tempa}
\SUBTRACT{\cctr@tempa}{#2}{#2}
\DIVIDE{1}{#2}{#2}
\DIVIDE{5}{#1}{\cctr@tempa}
\SUBTRACT{\cctr@tempa}{#2}{#2}
\DIVIDE{1}{#2}{#2}
\DIVIDE{3}{#1}{\cctr@tempa}
\SUBTRACT{\cctr@tempa}{#2}{#2}
\DIVIDE{1}{#2}{#2}
\DIVIDE{1}{#1}{\cctr@tempa}
\SUBTRACT{\cctr@tempa}{#2}{#2}
\DIVIDE{1}{#2}{#2}
\fi\fi\@OUTPUTSOL{#2}}
\COT{h#1 i}{h#2 i}. Cotangent of #1 : If cos t = 0 then cot t = 0; if tan t = 0 then cot t = .
Otherwise, cot t = 1/ tan t.
\def\COT#1#2{%
\begingroup
464
\COS{#1}{#2}
465
\ifdim #2\p@ = \z@
466
\COPY{0}{#2}
467
\else
462
463
43
468
469
470
471
472
473
474
\DEGtoRAD
\RADtoDEG
\def\DEGtoRAD#1#2{\DIVIDE{#1}{57.29578}{#2}}
\REDUCERADIANSANGLE
\TAN{#1}{#2}
\ifdim #2\p@ = \z@
\cctr@Warninfcotan{#1}
\let#2\undefined
\else
\DIVIDE{1}{#2}{#2}
\fi\fi\@OUTPUTSOL{#2}}
\def\RADtoDEG#1#2{\MULTIPLY{#1}{57.29578}{#2}}
478
\REDUCEDEGREESANGLE
489
Trigonometric functions in degrees Four next commands compute trigonometric functions in degrees. By default, a circle has 360 degrees, but we can use an arbitrary number of
divisions using the optional argument of these commands.
\DEGREESSIN
\DEGREESCOS
\def\DEGREESSIN{\@ifnextchar[\@@DEGREESSIN\@DEGREESSIN}
\def\DEGREESCOS{\@ifnextchar[\@@DEGREESCOS\@DEGREESCOS}
44
\DEGREESTAN
\DEGREESCOT
\@DEGREESSIN
\def\DEGREESTAN{\@ifnextchar[\@@DEGREESTAN\@DEGREESTAN}
\def\DEGREESCOT{\@ifnextchar[\@@DEGREESCOT\@DEGREESCOT}
504
\@DEGREESCOS
526
527
\@DEGREESTAN
530
531
45
542
543
544
545
546
547
548
549
\@DEGREESCOT
\else
\ifdim #1\p@<90\p@
\DEGtoRAD{#1}{\cctr@tempb}
\@BASICTAN{\cctr@tempb}{#2}
\else
\SUBTRACT{#1}{180}{\cctr@tempb}
\DEGREESTAN{\cctr@tempb}{#2}
\fi\fi\fi\fi\@OUTPUTSOL{#2}}
550
551
For an arbitrary number of degrees, we normalise to 360 degrees and, then, call the former
functions.
\@@DEGREESSIN
\@@DEGREESCOS
\@@DEGREESTAN
568
\def\@@DEGREESTAN[#1]#2#3{\@CONVERTDEG{#1}{#2}
\DEGREESTAN{\@DEGREES}{#3}}
\@CONVERTDEG
\def\@@DEGREESCOS[#1]#2#3{\@CONVERTDEG{#1}{#2}
\DEGREESCOS{\@DEGREES}{#3}}
\@@DEGREESCOT
\def\@@DEGREESSIN[#1]#2#3{\@CONVERTDEG{#1}{#2}
\@DEGREESSIN{\@DEGREES}{#3}}
\def\@@DEGREESCOT[#1]#2#3{\@CONVERTDEG{#1}{#2}
\DEGREESCOT{\@DEGREES}{#3}}
\def\@CONVERTDEG#1#2{\DIVIDE{#2}{#1}{\@DEGREES}
\MULTIPLY{\@DEGREES}{360}{\@DEGREES}}
46
Exponential functions
\EXP
\EXP[h#1 i]{h#2 i}{h#3 i} computes the exponential #3 = #1#2 . Default for #1 is number
e.
573
\@@EXP
\def\EXP{\@ifnextchar[\@@EXP\@EXP}
\def\@@EXP[#1]#2#3{%
\begingroup
\ifdim #1\p@<\cctr@epsilon
\cctr@Warninfexpb{#1}{#2}
\let#3\undefined
\else
\@EXP
\LOG{#1}{\cctr@log}
\MULTIPLY{#2}{\cctr@log}{\cctr@log}
\@EXP{\cctr@log}{#3}
\fi\@OUTPUTSOL{#3}}
584
585
\ifdim \cctr@absval\p@>\cctr@logmaxnum\p@
\cctr@Warninfexp{#1}
\let#2\undefined
\else
\ifdim #1\p@ < \z@
2
We call \@BASICEXP when t [6, 3]. Otherwise we use the equality exp t = (exp t/2) .
\ifdim #1\p@ > -6.00002\p@
\@BASICEXP{#1}{#2}
594
\else
595
\DIVIDE{#1}{2}{\cctr@expt}
596
\@EXP{\cctr@expt}{\cctr@expy}
597
\SQUARE{\cctr@expy}{#2}
598
\fi
599
\else
600
\ifdim #1\p@ < 3.00002\p@
601
\@BASICEXP{#1}{#2}
602
\else
603
\DIVIDE{#1}{2}{\cctr@expt}
604
\@EXP{\cctr@expt}{\cctr@expy}
605
\SQUARE{\cctr@expy}{#2}
606
\fi
607 \fi\fi\@OUTPUTSOL{#2}}
592
593
47
\@BASICEXP
exp x 1 +
2x+
x2 /6
x2 /60
1+
x2 /140
1+
x2 /256
1+
x2
1+
396
\def\@BASICEXP#1#2{%
\begingroup
610
\SQUARE{#1}\cctr@tempa
611
\DIVIDE{\cctr@tempa}{396}{#2}
612
\ADD{1}{#2}{#2}
613
\DIVIDE\cctr@tempa{#2}{#2}
614
\DIVIDE{#2}{256}{#2}
615
\ADD{1}{#2}{#2}
616
\DIVIDE\cctr@tempa{#2}{#2}
617
\DIVIDE{#2}{140}{#2}
618
\ADD{1}{#2}{#2}
619
\DIVIDE\cctr@tempa{#2}{#2}
620
\DIVIDE{#2}{60}{#2}
621
\ADD{1}{#2}{#2}
622
\DIVIDE\cctr@tempa{#2}{#2}
623
\DIVIDE{#2}{6}{#2}
624
\ADD{2}{#2}{#2}
625
\SUBTRACT{#2}{#1}{#2}
626
\DIVIDE{#1}{#2}{#2}
627
\MULTIPLY{2}{#2}{#2}
628
\ADD{1}{#2}{#2}\@OUTPUTSOL{#2}}
608
609
Hyperbolic functions
\COSH
630
48
\SINH
643
\TANH
656
\COTH
667
Logarithm
\LOG
\LOG[h#1 i]{h#2 i}{h#3 i} computes the logarithm #3 = log#1 #2. Default for #1 is number
e.
677
\@LOG
\def\LOG{\@ifnextchar[\@@LOG\@LOG}
\def\@LOG#1#2{%
\begingroup
49
\ifdim #1\p@<\cctr@epsilon
\cctr@Warninflog{#1}
\let#2\undefined
\else
\ifdim #1\p@ > \numberETWO\p@
\DIVIDE{#1}{\numberE}{\cctr@ae}
\@LOG{\cctr@ae}{#2}
\ADD{1}{#2}{#2}
\else
\ifdim #1\p@ < 1\p@
\MULTIPLY{\numberE}{#1}{\cctr@ae}
\LOG{\cctr@ae}{#2}
\SUBTRACT{#2}{1}{#2}
\else
\@@LOG
\@BASICLOG{#1}{#2}
\fi\fi\fi\@OUTPUTSOL{#2}}
697
\@BASICLOG
t
exn
\def\@BASICLOG#1#2{\begingroup
% We take $\textit{\#1}-1$ as the initial approximation.
702 %
\begin{macrocode}
703
\SUBTRACT{#1}{1}{\cctr@tempw}
700
701
\cctr@lengthb=5\p@%
Successive iterations
705
706
707
708
709
710
711
712
50
713
714
715
716
\ifnum
\cctr@lengthb<\z@ \cctr@lengthb=-\cctr@lengthb
\fi}%
\COPY{\cctr@tempw}{#2}\@OUTPUTSOL{#2}}
\ARCSIN{h#1 i}{h#2 i} defines #2 as the arcsin of #1, using the Newtons method: xn+1 =
xn (sin xn #1)/(cos xn ).
\def\ARCSIN#1#2{%
\begingroup
719
\ifdim #1\p@ = \z@
720
\COPY{0}{#2}
721
\else
722
\ifdim #1\p@ = 1\p@
723
\COPY{\numberHALFPI}{#2}
724
\else
725
\ifdim #1\p@ = -1\p@
726
\COPY{-\numberHALFPI}{#2}
727
\else
728
\ifdim #1\p@ > 1\p@
729
\let#2\undefined
730
\cctr@Warnbigarcsin{#1}
731
\else
732
\ifdim #1\p@ < -1\p@
733
\let#2\undefined
734
\cctr@Warnbigarcsin{#1}
735
\else
717
718
p
(1 x)/2
p
(1 + x)/2
\COPY{#1}{#2}
51
If 0.4 t 0.4 then arcsin x x is a good approximation. Else, we apply the Newton method
753
754
755
\ABSVALUE{#1}{\cctr@tempy}
\ifdim \cctr@tempy\p@ < 0.04\p@
\else
\cctr@lengthb=5\p@
\COPY{16383}{\cctr@tempy}
Successive iterations
758
\COPY{#2}{\cctr@tempw}
\COPY{\cctr@tempy}{\cctr@tempoldy}
\SIN{\cctr@tempw}{\cctr@tempz}
\SUBTRACT{\cctr@tempz}{#1}{\cctr@tempz}
\COS{\cctr@tempw}{\cctr@tempy}
\DIVIDE{\cctr@tempz}{\cctr@tempy}{\cctr@tempz}
\SUBTRACT{\cctr@tempw}{\cctr@tempz}{\cctr@tempz}
\COPY{\cctr@tempz}{#2}
Finally, we store in \cctr@lengthb the difference of the two last approximations, finishing the
loop.
767
768
769
770
771
772
\ARCCOS
\SUBTRACT{#2}{\cctr@tempw}{\cctr@tempy}
\ABSVALUE{\cctr@tempy}{\cctr@tempy}
\cctr@lengthb=\cctr@tempy\p@%
\ifdim\cctr@tempy\p@=\cctr@tempoldy\p@
\cctr@lengthb=\z@
\fi}\fi\fi\fi\fi\fi\fi\fi\fi\@OUTPUTSOL{#2}}
\ARCCOS{h#1 i}{h#2 i} defines #2 as the arccos of #1, using the well know relation arccos x =
/2 arcsin x.
\def\ARCCOS#1#2{%
\begingroup
775
\ifdim #1\p@ = \z@
776
\COPY{\numberHALFPI}{#2}
777
\else
778
\ifdim #1\p@ = 1\p@
779
\COPY{0}{#2}
780
\else
781
\ifdim #1\p@ = -1\p@
782
\COPY{\numberPI}{#2}
783
\else
784
\ifdim #1\p@ > 1\p@
785
\let#2\undefined
786
\cctr@Warnbigarccos{#1}
787
\else
773
774
52
788
789
790
791
792
793
794
\ARCTAN
\def\ARCTAN#1#2{%
\begingroup
797
798
799
800
801
802
803
804
805
806
807
808
809
\@BASICARCTAN
arctan x =
1+
810
811
x2
(2x)2
3+
(3x)2
5+
(4x)2
7+
9 +
\def\@BASICARCTAN#1#2{%
\begingroup
\ifdim#1\p@=\z@ \COPY{0}{#2}
\else
\SQUARE{#1}{\cctr@tempa}
\MULTIPLY{64}{\cctr@tempa}{#2}
\ADD{15}{#2}{#2}
\DIVIDE{\cctr@tempa}{#2}{#2}
\MULTIPLY{49}{#2}{#2}
53
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
\ARCCOT
\ADD{13}{#2}{#2}
\DIVIDE{\cctr@tempa}{#2}{#2}
\MULTIPLY{36}{#2}{#2}
\ADD{11}{#2}{#2}
\DIVIDE{\cctr@tempa}{#2}{#2}
\MULTIPLY{25}{#2}{#2}
\ADD{9}{#2}{#2}
\DIVIDE{\cctr@tempa}{#2}{#2}
\MULTIPLY{16}{#2}{#2}
\ADD{7}{#2}{#2}
\DIVIDE{\cctr@tempa}{#2}{#2}
\MULTIPLY{9}{#2}{#2}
\ADD{5}{#2}{#2}
\DIVIDE{\cctr@tempa}{#2}{#2}
\MULTIPLY{4}{#2}{#2}
\ADD{3}{#2}{#2}
\DIVIDE{\cctr@tempa}{#2}{#2}
\ADD{1}{#2}{#2}
\DIVIDE{#1}{#2}{#2}
\fi\@OUTPUTSOL{#2}}
\ARCCOT{h#1 i}{h#2 i} defines #2 as the arccot of #1, using the well know relation arccot x =
/2 arctan x.
\def\ARCCOT#1#2{%
\begingroup
841
\ARCTAN{#1}{#2}
842
\SUBTRACT{\numberHALFPI}{#2}{#2}
843
\@OUTPUTSOL{#2}}
839
840
1 + x2
\def\ARSINH#1#2{%
\begingroup
846
\SQUARE{#1}{\cctr@tempa}
847
\ADD{1}{\cctr@tempa}{\cctr@tempa}
848
\SQRT{\cctr@tempa}{\cctr@tempb}
849
\ADD{#1}{\cctr@tempb}{\cctr@tempb}
850
\LOG\cctr@tempb{#2}
851
\@OUTPUTSOL{#2}}
844
845
\ARCOSH
\def\ARCOSH#1#2{%
\begingroup
\ifdim#1\p@<1\p@
\let#2\undefined
\cctr@Warnsmallarcosh{#1}
\else
54
x2 1
858
859
860
861
862
863
\ARTANH
\SQUARE{#1}{\cctr@tempa}
\SUBTRACT{\cctr@tempa}{1}{\cctr@tempa}
\SQRT{\cctr@tempa}{\cctr@tempb}
\ADD{#1}{\cctr@tempb}{\cctr@tempb}
\LOG\cctr@tempb{#2}
\fi\@OUTPUTSOL{#2}}
864
\ARCOTH
\ifdim#1\p@<-0.99998\p@
\let#2\undefined
\cctr@Warnbigartanh{#1}
\else
\ifdim#1\p@>0.99998\p@
\let#2\undefined
\cctr@Warnbigartanh{#1}
\else
\COPY{#1}{\cctr@tempa}
\ADD1\cctr@tempa\cctr@tempb
\SUBTRACT1\cctr@tempa\cctr@tempc
\LOG\cctr@tempb\cctr@tempB
\LOG\cctr@tempc\cctr@tempC
\SUBTRACT\cctr@tempB\cctr@tempC{#2}
\DIVIDE{#2}{2}{#2}
\fi
\fi\@OUTPUTSOL{#2}}
\def\ARCOTH#1#2{%
\begingroup
\ifdim#1\p@>-0.99998\p@
\ifdim#1\p@<0.99998\p@
\let#2\undefined
\cctr@Warnsmallarcoth{#1}
\else
\ifdim#1\p@>\p@
1
2
\COPY{#1}{\cctr@tempa}
\ADD1\cctr@tempa\cctr@tempb
\SUBTRACT\cctr@tempa1\cctr@tempc
\LOG\cctr@tempb\cctr@tempB
\LOG\cctr@tempc\cctr@tempC
\SUBTRACT\cctr@tempB\cctr@tempC{#2}
\DIVIDE{#2}{2}{#2}
55
1
2
\else
\fi
\fi
\else
898
899
900
901
902
903
904
905
13.4
Matrix arithmetics
Vector operations
\VECTORSIZE
The size of a vector is 2 or 3. \VECTORSIZE(h#1 i){h#2 i} stores in #2 the size of (h#1 i).
Almost all vector commands needs to know the vector size.
\def\VECTORSIZE(#1)#2{\expandafter\@VECTORSIZE(#1,,){#2}}
\def\@VECTORSIZE(#1,#2,#3,#4)#5{\ifx$#3$\COPY{2}{#5}
908
\else\COPY{3}{#5}\fi\ignorespaces}
906
907
\VECTORCOPY
\def\@@VECTORCOPY(#1,#2)(#3,#4){%
\COPY{#1}{#3}\COPY{#2}{#4}}
911
912
913
\def\@@@VECTORCOPY(#1,#2,#3)(#4,#5,#6){%
\COPY{#1}{#4}\COPY{#2}{#5}\COPY{#3}{#6}}
914
\def\VECTORCOPY(#1)(#2){%
\VECTORSIZE(#1){\cctr@size}
917
\ifnum\cctr@size=2
918
\@@VECTORCOPY(#1)(#2)
919
\else \@@@VECTORCOPY(#1)(#2)\fi}
915
916
\VECTORGLOBALCOPY
\def\@@VECTORGLOBALCOPY(#1,#2)(#3,#4){%
\GLOBALCOPY{#1}{#3}\GLOBALCOPY{#2}{#4}}
922
923
924
\def\@@@VECTORGLOBALCOPY(#1,#2,#3)(#4,#5,#6){%
\GLOBALCOPY{#1}{#4}\GLOBALCOPY{#2}{#5}\GLOBALCOPY{#3}{#6}}
925
\def\VECTORGLOBALCOPY(#1)(#2){%
\VECTORSIZE(#1){\cctr@size}
928
\ifnum\cctr@size=2
929
\@@VECTORGLOBALCOPY(#1)(#2)
930
\else \@@@VECTORGLOBALCOPY(#1)(#2)\fi}
926
927
\@OUTPUTVECTOR
931
\def\@@OUTPUTVECTOR(#1,#2){%
56
932
933
\VECTORGLOBALCOPY(#1,#2)(\cctr@outa,\cctr@outb)
\endgroup\VECTORCOPY(\cctr@outa,\cctr@outb)(#1,#2)}
934
\def\@@@OUTPUTVECTOR(#1,#2,#3){%
\VECTORGLOBALCOPY(#1,#2,#3)(\cctr@outa,\cctr@outb,\cctr@outc)
937
\endgroup\VECTORCOPY(\cctr@outa,\cctr@outb,\cctr@outc)(#1,#2,#3)}
935
936
938
\def\@OUTPUTVECTOR(#1){\VECTORSIZE(#1){\cctr@size}
\ifnum\cctr@size=2
941
\@@OUTPUTVECTOR(#1)
942
\else \@@@OUTPUTVECTOR(#1)\fi}
939
940
\SCALARPRODUCT
947
\def\@@@SCALARPRODUCT(#1,#2,#3)(#4,#5,#6)#7{%
\MULTIPLY{#1}{#4}{#7}
950
\MULTIPLY{#2}{#5}\cctr@tempa
951
\ADD{#7}{\cctr@tempa}{#7}
952
\MULTIPLY{#3}{#6}\cctr@tempa
953
\ADD{#7}{\cctr@tempa}{#7}}
948
949
954
\def\SCALARPRODUCT(#1)(#2)#3{%
\begingroup
957
\VECTORSIZE(#1){\cctr@size}
958
\ifnum\cctr@size=2
959
\@@SCALARPRODUCT(#1)(#2){#3}
960
\else \@@@SCALARPRODUCT(#1)(#2){#3}\fi\@OUTPUTSOL{#3}}
955
956
\DOTPRODUCT
\VECTORPRODUCT
\let\DOTPRODUCT\SCALARPRODUCT
962
963
966
\def\@@@VECTORPRODUCT(#1,#2,#3)(#4,#5,#6)(#7,#8,#9){%
\DETERMINANT(#2,#3;#5,#6){#7}
969
\DETERMINANT(#3,#1;#6,#4){#8}
970
\DETERMINANT(#1,#2;#4,#5){#9}}
967
968
971
\def\VECTORPRODUCT(#1)(#2)(#3){%
\begingroup
974
\VECTORSIZE(#1){\cctr@size}
972
973
57
975
976
977
\CROSSPRODUCT
\VECTORADD
\ifnum\cctr@size=2
\@@VECTORPRODUCT(#1)(#2)(#3)
\else \@@@VECTORPRODUCT(#1)(#2)(#3)\fi\@OUTPUTSOL{#3}}
\let\CROSSPRODUCT\VECTORPRODUCT
980
982
\def\@@@VECTORADD(#1,#2,#3)(#4,#5,#6)(#7,#8,#9){%
\ADD{#1}{#4}{#7}
985
\ADD{#2}{#5}{#8}
986
\ADD{#3}{#6}{#9}}
983
984
987
\def\VECTORADD(#1)(#2)(#3){%
\VECTORSIZE(#1){\cctr@size}
990
\ifnum\cctr@size=2
991
\@@VECTORADD(#1)(#2)(#3)
992
\else \@@@VECTORADD(#1)(#2)(#3)\fi}
988
989
\VECTORSUB
\def\@@VECTORSUB(#1,#2)(#3,#4)(#5,#6){%
\VECTORADD(#1,#2)(-#3,-#4)(#5,#6)}
995
996
997
\def\@@@VECTORSUB(#1,#2,#3)(#4,#5,#6)(#7,#8,#9){%
\VECTORADD(#1,#2,#3)(-#4,-#5,-#6)(#7,#8,#9)}
998
\def\VECTORSUB(#1)(#2)(#3){%
\VECTORSIZE(#1){\cctr@size}
1001
\ifnum\cctr@size=2
1002
\@@VECTORSUB(#1)(#2)(#3)
1003
\else \@@@VECTORSUB(#1)(#2)(#3)\fi}
999
1000
\VECTORABSVALUE
\def\@@VECTORABSVALUE(#1,#2)(#3,#4){%
\ABSVALUE{#1}{#3}\ABSVALUE{#2}{#4}}
1006
1007
1008
\def\@@@VECTORABSVALUE(#1,#2,#3)(#4,#5,#6){%
\ABSVALUE{#1}{#4}\ABSVALUE{#2}{#5}\ABSVALUE{#3}{#6}}
1009
\def\VECTORABSVALUE(#1)(#2){%
\VECTORSIZE(#1){\cctr@size}
1012
\ifnum\cctr@size=2
1013
\@@VECTORABSVALUE(#1)(#2)
1014
\else \@@@VECTORABSVALUE(#1)(#2)\fi}
1010
1011
\SCALARVECTORPRODUCT
Scalar-vector product.
58
\def\@@SCALARVECTORPRODUCT#1(#2,#3)(#4,#5){%
\MULTIPLY{#1}{#2}{#4}
1017
\MULTIPLY{#1}{#3}{#5}}
1015
1016
1018
\def\@@@SCALARVECTORPRODUCT#1(#2,#3,#4)(#5,#6,#7){%
\MULTIPLY{#1}{#2}{#5}
1021
\MULTIPLY{#1}{#3}{#6}
1022
\MULTIPLY{#1}{#4}{#7}}
1019
1020
1023
\def\SCALARVECTORPRODUCT#1(#2)(#3){%
\VECTORSIZE(#2){\cctr@size}
1026
\ifnum\cctr@size=2
1027
\@@SCALARVECTORPRODUCT{#1}(#2)(#3)
1028
\else \@@@SCALARVECTORPRODUCT{#1}(#2)(#3)\fi}
1024
1025
\VECTORNORM
1030
\UNITVECTOR
1034
\TWOVECTORSANGLE
1039
Matrix operations
Here, we need to define some internal macros to simulate commands with more than nine
arguments.
59
\@TDMATRIXCOPY
1056
\@TDMATRIXSOL
1066
\@TDMATRIXGLOBALSOL
\def\@TDMATRIXGLOBALSOL(#1,#2,#3;#4,#5,#6;#7,#8,#9){%
\GLOBALCOPY{\cctr@solAA}{#1}
1077
\GLOBALCOPY{\cctr@solAB}{#2}
1078
\GLOBALCOPY{\cctr@solAC}{#3}
1079
\GLOBALCOPY{\cctr@solBA}{#4}
1080
\GLOBALCOPY{\cctr@solBB}{#5}
1081
\GLOBALCOPY{\cctr@solBC}{#6}
1082
\GLOBALCOPY{\cctr@solCA}{#7}
1083
\GLOBALCOPY{\cctr@solCB}{#8}
1084
\GLOBALCOPY{\cctr@solCC}{#9}}
1075
1076
\@TDMATRIXNOSOL
1086
60
\@@TDMATRIXSOL
1097
\@NUMBERSOL
\MATRIXSIZE
\def\@NUMBERSOL#1{\COPY{\cctr@sol}{#1}}
Size (2 or 3) of a matrix.
\def\MATRIXSIZE(#1)#2{\expandafter\@MATRIXSIZE(#1;;){#2}}
\def\@MATRIXSIZE(#1;#2;#3;#4)#5{\ifx$#3$\COPY{2}{#5}
1104
\else\COPY{3}{#5}\fi\ignorespaces}
1102
1103
\MATRIXCOPY
\def\@@MATRIXCOPY(#1,#2;#3,#4)(#5,#6;#7,#8){%
\COPY{#1}{#5}\COPY{#2}{#6}\COPY{#3}{#7}\COPY{#4}{#8}}
1107
\def\@@@MATRIXCOPY(#1,#2,#3;#4,#5,#6;#7,#8,#9){%
\@TDMATRIXCOPY(#1,#2,#3;#4,#5,#6;#7,#8,#9)
1110
\@TDMATRIXSOL}
1108
1109
1111
\def\MATRIXCOPY(#1)(#2){%
\MATRIXSIZE(#1){\cctr@size}
1114
\ifnum\cctr@size=2
1115
\@@MATRIXCOPY(#1)(#2)
1116
\else \@@@MATRIXCOPY(#1)(#2)\fi}
1112
1113
\MATRIXGLOBALCOPY
\def\@@MATRIXGLOBALCOPY(#1,#2;#3,#4)(#5,#6;#7,#8){%
\GLOBALCOPY{#1}{#5}\GLOBALCOPY{#2}{#6}\GLOBALCOPY{#3}{#7}\GLOBALCOPY{#4}{#8}}
1119
\def\@@@MATRIXGLOBALCOPY(#1,#2,#3;#4,#5,#6;#7,#8,#9){%
\@TDMATRIXCOPY(#1,#2,#3;#4,#5,#6;#7,#8,#9)
1122
\@TDMATRIXGLOBALSOL}
1120
1121
1123
\def\MATRIXGLOBALCOPY(#1)(#2){%
\MATRIXSIZE(#1){\cctr@size}
1126
\ifnum\cctr@size=2
1127
\@@MATRIXGLOBALCOPY(#1)(#2)
1128
\else \@@@MATRIXGLOBALCOPY(#1)(#2)\fi}
1124
1125
\@OUTPUTMATRIX
\def\@@OUTPUTMATRIX(#1,#2;#3,#4){%
\MATRIXGLOBALCOPY(#1,#2;#3,#4)(\cctr@outa,\cctr@outb;\cctr@outc,\cctr@outd)
1131
\endgroup\MATRIXCOPY(\cctr@outa,\cctr@outb;\cctr@outc,\cctr@outd)(#1,#2;#3,#4)}
1129
1130
1132
1133
\def\@@@OUTPUTMATRIX(#1,#2,#3;#4,#5,#6;#7,#8,#9){%
61
1134
1135
1136
1137
1138
1139
1140
1141
\MATRIXGLOBALCOPY(#1,#2,#3;#4,#5,#6;#7,#8,#9)(%
\cctr@outa,\cctr@outb,\cctr@outc;
\cctr@outd,\cctr@oute,\cctr@outf;
\cctr@outg,\cctr@outh,\cctr@outi)
\endgroup\MATRIXCOPY(%
\cctr@outa,\cctr@outb,\cctr@outc;
\cctr@outd,\cctr@oute,\cctr@outf;
\cctr@outg,\cctr@outh,\cctr@outi)(#1,#2,#3;#4,#5,#6;#7,#8,#9)}
1142
\def\@OUTPUTMATRIX(#1){\MATRIXSIZE(#1){\cctr@size}
\ifnum\cctr@size=2
1145
\@@OUTPUTMATRIX(#1)
1146
\else \@@@OUTPUTMATRIX(#1)\fi}
1143
1144
\TRANSPOSEMATRIX
Matrix transposition.
1147
1148
\def\@@TRANSPOSEMATRIX(#1,#2;#3,#4)(#5,#6;#7,#8){%
\COPY{#1}{#5}\COPY{#3}{#6}\COPY{#2}{#7}\COPY{#4}{#8}}
1149
\def\@@@TRANSPOSEMATRIX(#1,#2,#3;#4,#5,#6;#7,#8,#9){%
\@TDMATRIXCOPY(#1,#4,#7;#2,#5,#8;#3,#6,#9)
1152
\@TDMATRIXSOL}
1150
1151
1153
\def\TRANSPOSEMATRIX(#1)(#2){%
\begingroup
1156
\MATRIXSIZE(#1){\cctr@size}
1157
\ifnum\cctr@size=2
1158
\@@TRANSPOSEMATRIX(#1)(#2)
1159
\else \@@@TRANSPOSEMATRIX(#1)(#2)\fi\@OUTPUTMATRIX(#2)}
1154
1155
\MATRIXADD
1160
1161
1163
\def\@@@MATRIXADD(#1;#2;#3)(#4;#5;#6){%
\VECTORADD(#1)(#4)(\cctr@solAA,\cctr@solAB,\cctr@solAC)
1166
\VECTORADD(#2)(#5)(\cctr@solBA,\cctr@solBB,\cctr@solBC)
1167
\VECTORADD(#3)(#6)(\cctr@solCA,\cctr@solCB,\cctr@solCC)
1168
\@TDMATRIXSOL}
1164
1165
1169
\def\MATRIXADD(#1)(#2)(#3){%
\begingroup
1172
\MATRIXSIZE(#1){\cctr@size}
1173
\ifnum\cctr@size=2
1174
\@@MATRIXADD(#1)(#2)(#3)
1175
\else \@@@MATRIXADD(#1)(#2)(#3)\fi\@OUTPUTMATRIX(#3)}
1170
1171
\MATRIXSUB
\def\@@MATRIXSUB(#1;#2)(#3;#4)(#5,#6;#7,#8){%
\VECTORSUB(#1)(#3)(#5,#6)
62
1178
\VECTORSUB(#2)(#4)(#7,#8)}
1179
\def\@@@MATRIXSUB(#1;#2;#3)(#4;#5;#6){%
\VECTORSUB(#1)(#4)(\cctr@solAA,\cctr@solAB,\cctr@solAC)
1182
\VECTORSUB(#2)(#5)(\cctr@solBA,\cctr@solBB,\cctr@solBC)
1183
\VECTORSUB(#3)(#6)(\cctr@solCA,\cctr@solCB,\cctr@solCC)
1184
\@TDMATRIXSOL}
1180
1181
1185
\def\MATRIXSUB(#1)(#2)(#3){%
\begingroup
1188
\MATRIXSIZE(#1){\cctr@size}
1189
\ifnum\cctr@size=2
1190
\@@MATRIXSUB(#1)(#2)(#3)
1191
\else \@@@MATRIXSUB(#1)(#2)(#3)\fi\@OUTPUTMATRIX(#3)}
1186
1187
\MATRIXABSVALUE
\def\@@MATRIXABSVALUE(#1;#2)(#3;#4){%
\VECTORABSVALUE(#1)(#3)\VECTORABSVALUE(#2)(#4)}
1194
1195
1196
\def\@@@MATRIXABSVALUE(#1;#2;#3)(#4;#5;#6){%
\VECTORABSVALUE(#1)(#4)\VECTORABSVALUE(#2)(#5)\VECTORABSVALUE(#3)(#6)}
1197
\def\MATRIXABSVALUE(#1)(#2){%
\begingroup
1200
\MATRIXSIZE(#1){\cctr@size}
1201
\ifnum\cctr@size=2
1202
\@@MATRIXABSVALUE(#1)(#2)
1203
\else \@@@MATRIXABSVALUE(#1)(#2)\fi\@OUTPUTMATRIX(#2)}
1198
1199
\MATRIXVECTORPRODUCT
Matrix-vector product.
\def\@@MATRIXVECTORPRODUCT(#1;#2)(#3)(#4,#5){%
\SCALARPRODUCT(#1)(#3){#4}
1206
\SCALARPRODUCT(#2)(#3){#5}}
1204
1205
1207
\def\@@@MATRIXVECTORPRODUCT(#1;#2;#3)(#4)(#5,#6,#7){%
\SCALARPRODUCT(#1)(#4){#5}
1210
\SCALARPRODUCT(#2)(#4){#6}
1211
\SCALARPRODUCT(#3)(#4){#7}}
1208
1209
1212
\def\MATRIXVECTORPRODUCT(#1)(#2)(#3){%
\begingroup
1215
\MATRIXSIZE(#1){\cctr@size}
1216
\ifnum\cctr@size=2
1217
\@@MATRIXVECTORPRODUCT(#1)(#2)(#3)
1218
\else \@@@MATRIXVECTORPRODUCT(#1)(#2)(#3)\fi\@OUTPUTVECTOR(#3)}
1213
1214
\VECTORMATRIXPRODUCT
Vector-matrix product.
\def\@@VECTORMATRIXPRODUCT(#1)(#2,#3;#4,#5)(#6,#7){%
\SCALARPRODUCT(#1)(#2,#4){#6}
1221
\SCALARPRODUCT(#1)(#3,#5){#7}}
1219
1220
63
1222
\def\@@@VECTORMATRIXPRODUCT(#1,#2,#3)(#4;#5;#6)(#7){%
\SCALARVECTORPRODUCT{#1}(#4)(#7)
1225
\SCALARVECTORPRODUCT{#2}(#5)(\cctr@tempa,\cctr@tempb,\cctr@tempc)
1226
\VECTORADD(#7)(\cctr@tempa,\cctr@tempb,\cctr@tempc)(#7)
1227
\SCALARVECTORPRODUCT{#3}(#6)(\cctr@tempa,\cctr@tempb,\cctr@tempc)
1228
\VECTORADD(#7)(\cctr@tempa,\cctr@tempb,\cctr@tempc)(#7)}
1223
1224
1229
\def\VECTORMATRIXPRODUCT(#1)(#2)(#3){%
\begingroup
1232
\VECTORSIZE(#1){\cctr@size}
1233
\ifnum\cctr@size=2
1234
\@@VECTORMATRIXPRODUCT(#1)(#2)(#3)
1235
\else \@@@VECTORMATRIXPRODUCT(#1)(#2)(#3)\fi\@OUTPUTVECTOR(#3)}
1230
1231
\SCALARMATRIXPRODUCT
Scalar-matrix product.
\def\@@SCALARMATRIXPRODUCT#1(#2;#3)(#4,#5;#6,#7){%
\SCALARVECTORPRODUCT{#1}(#2)(#4,#5)
1238
\SCALARVECTORPRODUCT{#1}(#3)(#6,#7)}
1236
1237
1239
\def\@@@SCALARMATRIXPRODUCT#1(#2;#3;#4){%
\SCALARVECTORPRODUCT{#1}(#2)(\cctr@solAA,\cctr@solAB,\cctr@solAC)
1242
\SCALARVECTORPRODUCT{#1}(#3)(\cctr@solBA,\cctr@solBB,\cctr@solBC)
1243
\SCALARVECTORPRODUCT{#1}(#4)(\cctr@solCA,\cctr@solCB,\cctr@solCC)
1244
\@TDMATRIXSOL}
1240
1241
1245
\def\SCALARMATRIXPRODUCT#1(#2)(#3){%
\begingroup
1248
\MATRIXSIZE(#2){\cctr@size}
1249
\ifnum\cctr@size=2
1250
\@@SCALARMATRIXPRODUCT{#1}(#2)(#3)
1251
\else \@@@SCALARMATRIXPRODUCT{#1}(#2)(#3)\fi\@OUTPUTMATRIX(#3)}
1246
1247
\MATRIXPRODUCT
1253
1255
\def\@@@MATRIXPRODUCT(#1;#2;#3)(#4){%
\VECTORMATRIXPRODUCT(#1)(#4)(\cctr@solAA,\cctr@solAB,\cctr@solAC)
1258
\VECTORMATRIXPRODUCT(#2)(#4)(\cctr@solBA,\cctr@solBB,\cctr@solBC)
1259
\VECTORMATRIXPRODUCT(#3)(#4)(\cctr@solCA,\cctr@solCB,\cctr@solCC)
1260
\@TDMATRIXSOL}
1256
1257
1261
\def\MATRIXPRODUCT(#1)(#2)(#3){%
\begingroup
1264
\MATRIXSIZE(#1){\cctr@size}
1265
\ifnum\cctr@size=2
1266
\@@MATRIXPRODUCT(#1)(#2)(#3)
1267
\else \@@@MATRIXPRODUCT(#1)(#2)(#3)\fi\@OUTPUTMATRIX(#3)}
1262
1263
64
\DETERMINANT
Determinant of a matrix.
\def\@@DETERMINANT(#1,#2;#3,#4)#5{%
\MULTIPLY{#1}{#4}{#5}
1270
\MULTIPLY{#2}{#3}{\cctr@tempa}
1271
\SUBTRACT{#5}{\cctr@tempa}{#5}}
1268
1269
1272
\def\@@@DETERMINANT(#1,#2,#3;#4,#5,#6;#7,#8,#9){%
\DETERMINANT(#5,#6;#8,#9){\cctr@det}\MULTIPLY{#1}{\cctr@det}{\cctr@sol}
1275
\DETERMINANT(#6,#4;#9,#7){\cctr@det}\MULTIPLY{#2}{\cctr@det}{\cctr@det}
1276
\ADD{\cctr@sol}{\cctr@det}{\cctr@sol}
1277
\DETERMINANT(#4,#5;#7,#8){\cctr@det}\MULTIPLY{#3}{\cctr@det}{\cctr@det}
1278
\ADD{\cctr@sol}{\cctr@det}{\cctr@sol}
1279
\@NUMBERSOL}
1273
1274
1280
\def\DETERMINANT(#1)#2{%
\begingroup
1283
\MATRIXSIZE(#1){\cctr@size}
1284
\ifnum\cctr@size=2
1285
\@@DETERMINANT(#1){#2}
1286
\else \@@@DETERMINANT(#1){#2}\fi\@OUTPUTSOL{#2}}
1281
1282
\INVERSEMATRIX
Inverse of a matrix.
\def\@@INVERSEMATRIX(#1,#2;#3,#4)(#5,#6;#7,#8){%
\ifdim \cctr@@det\p@ <\cctr@epsilon % Matrix is singular
1289
\let#5\undefined
1290
\let#6\undefined
1291
\let#7\undefined
1292
\let#8\undefined
1293
\cctr@Warnsingmatrix{#1}{#2}{#3}{#4}%
1294
\else \COPY{#1}{#8}
1295
\COPY{#4}{#5}
1296
\MULTIPLY{-1}{#3}{#7}
1297
\MULTIPLY{-1}{#2}{#6}
1298
\DIVIDE{1}{\cctr@det}{\cctr@det}
1299
\SCALARMATRIXPRODUCT{\cctr@det}(#5,#6;#7,#8)(#5,#6;#7,#8)
1300
\fi}
1287
1288
1301
\def\@@@INVERSEMATRIX(#1,#2,#3;#4,#5,#6;#7,#8,#9){%
\ifdim \cctr@@det\p@ <\cctr@epsilon % Matrix is singular
1304
\@TDMATRIXNOSOL(\cctr@solAA,\cctr@solAB,\cctr@solAC;
1305
\cctr@solBA,\cctr@solBB,\cctr@solBC;
1306
\cctr@solCA,\cctr@solCB,\cctr@solCC)
1307
\cctr@WarnsingTDmatrix{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}{#9}%
1308
\else
1309
\@ADJMATRIX(#1,#2,#3;#4,#5,#6;#7,#8,#9)
1310
\@SCLRDIVVECT{\cctr@det}(\cctr@solAA,\cctr@solAB,\cctr@solAC)(%
1311
\cctr@solAA,\cctr@solAB,\cctr@solAC)
1312
\@SCLRDIVVECT{\cctr@det}(\cctr@solBA,\cctr@solBB,\cctr@solBC)(%
1313
\cctr@solBA,\cctr@solBB,\cctr@solBC)
1314
\@SCLRDIVVECT{\cctr@det}(\cctr@solCA,\cctr@solCB,\cctr@solCC)(%
1302
1303
65
\cctr@solCA,\cctr@solCB,\cctr@solCC)
1315
1316
1317
\fi
\@@TDMATRIXSOL}
1318
1319
1320
\def\@SCLRDIVVECT#1(#2,#3,#4)(#5,#6,#7){%
\DIVIDE{#2}{#1}{#5}\DIVIDE{#3}{#1}{#6}\DIVIDE{#4}{#1}{#7}}
1321
\def\@ADJMATRIX(#1,#2,#3;#4,#5,#6;#7,#8,#9){%
\DETERMINANT(#5,#6;#8,#9){\cctr@solAA}
1324
\DETERMINANT(#6,#4;#9,#7){\cctr@solBA}
1325
\DETERMINANT(#4,#5;#7,#8){\cctr@solCA}
1326
\DETERMINANT(#8,#9;#2,#3){\cctr@solAB}
1327
\DETERMINANT(#1,#3;#7,#9){\cctr@solBB}
1328
\DETERMINANT(#2,#1;#8,#7){\cctr@solCB}
1329
\DETERMINANT(#2,#3;#5,#6){\cctr@solAC}
1330
\DETERMINANT(#3,#1;#6,#4){\cctr@solBC}
1331
\DETERMINANT(#1,#2;#4,#5){\cctr@solCC}}
1322
1323
1332
\def\INVERSEMATRIX(#1)(#2){%
\begingroup
1335
\DETERMINANT(#1){\cctr@det}
1336
\ABSVALUE{\cctr@det}{\cctr@@det}
1337
\MATRIXSIZE(#1){\cctr@size}
1338
\ifnum\cctr@size=2
1339
\@@INVERSEMATRIX(#1)(#2)
1340
\else
1341
\@@@INVERSEMATRIX(#1)(#2)\fi\@OUTPUTMATRIX(#2)}
1333
1334
\SOLVELINEARSYSTEM
Solving a linear system (two equations and two unknowns or three equations and three unknowns).
1342
1343
\def\@INCSYS#1#2{\cctr@WarnIncLinSys
\let#1\undefined\let#2\undefined}
1344
\def\@SOLPART#1#2#3#4{\cctr@WarnIndLinSys
\DIVIDE{#1}{#2}{#3}
1347
\COPY{0}{#4}}
1345
1346
1348
\def\@TDINCSYS(#1,#2,#3){\cctr@WarnIncTDLinSys
\let#1\undefined
1351
\let#2\undefined
1352
\let#3\undefined}
1349
1350
1353
\def\@@SOLVELINEARSYSTEM(#1,#2;#3,#4)(#5,#6)(#7,#8){%
\DETERMINANT(#1,#2;#3,#4)\cctr@deta
1356
\DETERMINANT(#5,#2;#6,#4)\cctr@detb
1357
\DETERMINANT(#1,#5;#3,#6)\cctr@detc
1358
\ABSVALUE{\cctr@deta}{\cctr@@deta}
1359
\ABSVALUE{\cctr@detb}{\cctr@@detb}
1360
\ABSVALUE{\cctr@detc}{\cctr@@detc}
1361
\ifdim \cctr@@deta\p@>\cctr@epsilon% Regular matrix. Determinate system
1354
1355
66
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
\DIVIDE{\cctr@detb}{\cctr@deta}{#7}
\DIVIDE{\cctr@detc}{\cctr@deta}{#8}
\else % Singular matrix
\cctr@deta=0
\ifdim \cctr@@detb\p@>\cctr@epsilon% Incompatible system
\@INCSYS#7#8
\else
\ifdim \cctr@@detc\p@>\cctr@epsilon% Incompatible system
\@INCSYS#7#8
\else
\MATRIXABSVALUE(#1,#2;#3,#4)(\cctr@tempa,\cctr@tempb;
\cctr@tempc,\cctr@tempd)
\ifdim \cctr@tempa\p@ > \cctr@epsilon
% Indeterminate system
\@SOLPART{#5}{#1}{#7}{#8}
\else
\ifdim \cctr@tempb\p@ > \cctr@epsilon
% Indeterminate system
\@SOLPART{#5}{#2}{#8}{#7}
\else
\ifdim \cctr@tempc\p@ > \cctr@epsilon
% Indeterminate system
\@SOLPART{#6}{#3}{#7}{#8}
\else
\ifdim \cctr@tempd\p@ > \cctr@epsilon
% Indeterminate system
\@SOLPART{#6}{#4}{#8}{#7}
\else
\VECTORNORM(#5,#6){\cctr@tempa}
\ifdim \cctr@tempa\p@ > \cctr@epsilon
% Incompatible system
\@INCSYS#7#8
\else
\cctr@WarnZeroLinSys
\COPY{0}{#7}\COPY{0}{#8}
% 0x=0 Indeterminate system
\fi\fi\fi\fi\fi\fi\fi\fi}
1398
\def\@@@SOLVELINEARSYSTEM(#1)(#2)(#3){%
\DETERMINANT(#1){\cctr@det}
1401
\ABSVALUE{\cctr@det}{\cctr@@det}
1402
\ifdim\cctr@@det\p@<\cctr@epsilon
1403
\@TDINCSYS(#3)
1404
\else
1405
\@ADJMATRIX(#1)
1406
\MATRIXVECTORPRODUCT(\cctr@solAA,\cctr@solAB,\cctr@solAC;
1407
\cctr@solBA,\cctr@solBB,\cctr@solBC;
1408
\cctr@solCA,\cctr@solCB,\cctr@solCC)(#2)(#3)
1409
\@SCLRDIVVECT{\cctr@det}(#3)(#3)
1410
\fi}
1399
1400
1411
67
\def\SOLVELINEARSYSTEM(#1)(#2)(#3){%
\begingroup
1414
\MATRIXSIZE(#1){\cctr@size}
1415
\ifnum\cctr@size=2
1416
\@@SOLVELINEARSYSTEM(#1)(#2)(#3)
1417
\else
1418
\@@@SOLVELINEARSYSTEM(#1)(#2)(#3)
1419
\fi\@OUTPUTVECTOR(#3)}
1412
1413
Predefined numbers
\numberPI
The number
1420
\numberTWOPI
2
1421
\numberHALFPI
\SQUARE{\numberE}{\numberETWO}
1/e2
1431
\numberLOGTEN
\DIVIDE{1}{\numberE}{\numberINVE}
e2
1430
\numberINVETWO
\def\numberE{2.71828}
1/e
1429
\numberETWO
\DIVIDE{\numberPI}{6}{\numberSIXTHPI}
The number e
1428
\numberINVE
\DIVIDE{\numberPI}{5}{\numberFIFTHPI}
/6
1427
\numberE
\DIVIDE{\numberPI}{4}{\numberQUARTERPI}
/5
1426
\numberSIXTHPI
\DIVIDE{\numberPI}{3}{\numberTHIRDPI}
/4
1425
\numberFIFTHPI
\MULTIPLY{\numberPI}{1.5}{\numberTHREEHALFPI}
/3
1424
\numberQUARTERPI
\DIVIDE{\numberPI}{2}{\numberHALFPI}
3/2
1423
\numberTHIRDPI
\MULTIPLY{\numberPI}{2}{\numberTWOPI}
/2
1422
\numberTHREEHALFPI
\def\numberPI{3.14159}
\SQUARE{\numberINVE}{\numberINVETWO}
log 10
1432
\def\numberLOGTEN{2.30258}
68
\numberGOLD
\numberINVGOLD
1/
1434
\numberSQRTTWO
1435
\numberSQRTTHREE
1436
\numberSQRTFIVE
1437
\numberCOSXLV
\def\numberINVGOLD{0.61803}
2
\def\numberSQRTTWO{1.41421}
3
\def\numberSQRTTHREE{1.73205}
5
\def\numberSQRTFIVE{2.23607}
\numberCOSXXX
\def\numberGOLD{1.61803}
\def\numberCOSXLV{0.70711}
\def\numberCOSXXX{0.86603}
1440
h/calculatori
14
calculus
hcalculusi
\NeedsTeXFormat{LaTeX2e}
1443 \ProvidesPackage{calculus}[2014/02/20 v.2.0]
1441
1442
\RequirePackage{calculator}
14.1
Error message to be issued when you attempt to redefine, with \renewfunction, an undefined
command:
1452
1453
\def\ccls@ErrorFuncUnDef#1{%
\PackageError{calculus}%
69
1454
1455
1456
1457
Info message to be issued when \ensurefunction does not changes an already defined command:
\def\ccls@InfoFuncEns#1{%
\PackageInfo{calculus}%
1460
{\noexpand#1 command already defined\MessageBreak
1461
the \noexpand\ensurefunction command will not redefine it}}
1458
1459
1462
1463
1469
\def\ccls@ErrorPFuncUnDef#1{%
\PackageError{calculus}%
1472
{\noexpand#1 command undefined}
1473
{The \noexpand#1 control sequence
1474
is not currently defined.\MessageBreak
1475
If you want to define the \noexpand#1 command as a polar
1476
function\MessageBreak
1477
please, use the \noexpand\newpolarfunction command}}
1470
1471
1478
\def\ccls@InfoPFuncEns#1{%
\PackageInfo{calculus}%
1481
{\noexpand#1 command already defined\MessageBreak
1482
the \noexpand\ensurepolarfunction command does not redefine it}}
1479
1480
1483
1484
1490
\def\ccls@ErrorVFuncUnDef#1{%
\PackageError{calculus}%
1493
{\noexpand#1 command undefined}
1494
{The \noexpand#1 control sequence is not currently
1495
defined.\MessageBreak
1496
If you want to define the \noexpand#1 command as a vector
1497
function\MessageBreak
1491
1492
70
1498
1499
\def\ccls@InfoVFuncEns#1{%
\PackageInfo{calculus}%
1502
{\noexpand#1 command already defined\MessageBreak
1503
the \noexpand\ensurevectorfunction command does not redefine it}}
1500
1501
14.2
New functions
The \newfunction{#1}{#2} instruction defines a new function called #1. #2 is the list of
instructions to calculate the function \y and his derivative \Dy from the \t variable.
\def\newfunction#1#2{%
\ifx #1\undefined
1506
\ccls@deffunction{#1}{#2}
1507
\else
1508
\ccls@ErrorFuncDef{#1}
1509
\fi}
1504
1505
\renewfunction
1511
\ensurefunction
\forcefunction
\forcefunction defines (if undefined) or redefines (if defined) the new function #1.
1521
1522
\ccls@deffunction
\def\forcefunction#1#2{%
\ccls@deffunction{#1}{#2}}
The private \ccls@deffunction command makes the real work. The new functions will have
three arguments: ##1, a number, ##2, the value of the new function in that number, and
##3, the derivative.
\def\ccls@deffunction#1#2{%
\def#1##1##2##3{%
1525
\begingroup
1526
\def\t{##1}%
1527
#2
1528
\xdef##2{\y}%
1529
\xdef##3{\Dy}%
1530
\endgroup}\ignorespaces}
1523
1524
71
The \newpolarfunction{#1}{#2} instruction defines a new polar function called #1. #2 is the
list of instructions to calculate the radius \r and his derivative \Dr from the \t arc variable.
\def\newpolarfunction#1#2{%
\ifx #1\undefined
1533
\ccls@defpolarfunction{#1}{#2}
1534
\else
1535
\ccls@ErrorPFuncDef{#1}
1536
\fi}
1531
1532
\renewpolarfunction
\ensurepolarfunction
\forcepolarfunction
\ccls@defpolarfunction
\def\forcepolarfunction#1#2{%
\ccls@defpolarfunction{#1}{#2}}
The private \ccls@defpolarfunction command makes the real work. The new functions will
have three arguments: ##1, a number (the polar radius), ##2, ##3, ##4, and ##5, the x
and y component functions and its derivatives at ##1.
\def\ccls@defpolarfunction#1#2{%
\def#1##1##2##3##4##5{%
1552
\begingroup
1553
\def\t{##1}
1554
#2
1555
\COS{\t}\ccls@cost
1556
\MULTIPLY\r\ccls@cost{\x}
1557
\SIN{\t}\ccls@sint
1558
\MULTIPLY\r\ccls@sint{\y}
1559
\MULTIPLY\ccls@cost\Dr\Dx
1560
\SUBTRACT{\Dx}{\y}{\Dx}
1561
\MULTIPLY\ccls@sint\Dr\Dy
1562
\ADD{\Dy}{\x}{\Dy}
1563
\xdef##2{\x}
1564
\xdef##3{\Dx}
1565
\xdef##4{\y}
1566
\xdef##5{\Dy}
1567
\endgroup}\ignorespaces}
1550
1551
72
1569
\renewvectorfunction
\ensurevectorfunction
1581
\forcevectorfunction
\ccls@defvectorfunction
\def\forcevectorfunction#1#2{%
\ccls@defvectorfunction{#1}{#2}}
The private \ccls@defvectorfunction command makes the real work. The new functions will
have three arguments: ##1, a number, ##2, ##3, ##4, and ##5, the x and y component
functions and its derivatives at ##1.
\def\ccls@defvectorfunction#1#2{%
\def#1##1##2##3##4##5{%
1589
\begingroup
1590
\def\t{##1}
1591
#2
1592
\xdef##2{\x}
1593
\xdef##3{\Dx}
1594
\xdef##4{\y}
1595
\xdef##5{\Dy}
1596
\endgroup}\ignorespaces}
1587
1588
14.3
Polynomials
73
#1 = #2 + #3t.
\def\newlpoly#1#2#3{%
1598
\newfunction{#1}{%
1599
\ccls@lpoly{#2}{#3}}}
1597
\renewlpoly
\ensurelpoly
\def\ensurelpoly#1#2#3{%
\ensurefunction{#1}{%
1605
\ccls@lpoly{#2}{#3}}}
1603
1604
\forcelpoly
\def\forcelpoly#1#2#3{%
\forcefunction{#1}{%
1608
\ccls@lpoly{#2}{#3}}}
1606
1607
\ccls@lpoly
Quadratic polynomials
\newqpoly
\renewqpoly
\def\renewqpoly#1#2#3#4{%
\renewfunction{#1}{%
1618
\ccls@qpoly{#2}{#3}{#4}}}
1616
1617
\ensureqpoly
\def\ensureqpoly#1#2#3#4{%
\ensurefunction{#1}{%
1621
\ccls@qpoly{#2}{#3}{#4}}}
1619
1620
\forceqpoly
\def\forceqpoly#1#2#3#4{%
\forcefunction{#1}{%
1624
\ccls@qpoly{#2}{#3}{#4}}}
1622
1623
74
\ccls@qpoly
Cubic polynomials
\newcpoly
\renewcpoly
\def\renewcpoly#1#2#3#4#5{%
\renewfunction{#1}{%
1637
\ccls@cpoly{#2}{#3}{#4}{#5}}}
1635
1636
\ensurecpoly
\def\ensurecpoly#1#2#3#4#5{%
\ensurefunction{#1}{%
1640
\ccls@cpoly{#2}{#3}{#4}{#5}}}
1638
1639
\forcecpoly
\def\forcecpoly#1#2#3#4#5{%
\forcefunction{#1}{%
1643
\ccls@cpoly{#2}{#3}{#4}{#5}}}
1641
1642
\ccls@cpoly
75
14.4
\ONEfunction
Elementary functions
\ZEROfunction
\IDENTITYfunction
\RECIPROCALfunction
\SQUAREfunction
\CUBEfunction
\SQRTfunction
t, y (t) = 1/(2 t)
\newfunction{\SQRTfunction}{%
\SQRT{\t}{\y}
1679
\DIVIDE{0.5}{\y}{\Dy}}
1677
1678
\EXPfunction
1681
\COSfunction
1684
76
\SINfunction
\TANfunction
1691
\COTfunction
1696
\COSHfunction
1701
\SINHfunction
1704
\TANHfunction
1707
\COTHfunction
\LOGfunction
77
(
0
\HEAVISIDEfunction The \HEAVISIDEfunction: y(t) =
1
if t < 0 0
, y (t) = 0
if t 0
\newfunction{\HEAVISIDEfunction}{%
\ifdim \t\p@<\z@ \COPY{0}{\y}\else\COPY{1}{\y}\fi
1721
\COPY{0}{\Dy}}
1719
1720
\ARCSINfunction
1723
\ARCCOSfunction
1729
\ARCTANfunction
1735
\ARCCOTfunction
1740
\ARSINHfunction
1745
\ARCOSHfunction
\newfunction{\ARCOSHfunction}{%
\ARCOSH{\t}{\y}
78
1752
1753
1754
1755
\ARTANHfunction
\SQUARE{\t}{\yy}
\SUBTRACT{\yy}{1}{\yy}
\SQRT{\yy}{\Dy}
\DIVIDE{1}{\Dy}{\Dy}}
1757
\ARCOTHfunction
1762
14.5
\CONSTANTfunction
\SUMfunction
\SUBTRACTfunction
79
\PRODUCTfunction
1791
\QUOTIENTfunction
\COMPOSITIONfunction
\SCALEfunction
1826
80
1833
\SCALEVARIABLEfunction
\endgroup}\ignorespaces}
\POWERfunction
1844
LINEARCOMBINATIONfunction
1856
\POLARfunction
1870
81
\PARAMETRICfunction
\PARAMETRICfunction defines the parametric curve #3. #1 and #2 are the components functions (two previuosly defined functions).
\def\PARAMETRICfunction#1#2#3{%
\def#3##1##2##3##4##5{%
1875
#1{##1}{##2}{##3}
1876
#2{##1}{##4}{##5}}}
1873
1874
\VECTORfunction
\let\VECTORfunction\PARAMETRICfunction
1878
% </calculus>
Change History
v1.0
General: First public version . . . . . . . . . . 1
v1.0a
General: calculator.dtx modified to make it
autoinstallable. calculus.dtx embedded
in calculus.dtx . . . . . . . . . . . . . . . . . 1
v2.0
General: new calculator.dtx and calculator.ins files . . . . . . . . . . . . . . . . . . . . 1
New commands:
\ARCSINfunction,
\ARCCOSfunction, \ARCTANfunction,
\ARCCOTfunction . . . . . . . . . . . . . . 78
51
78
54
57
35
69
Index
Numbers written in italic refer to the page where the corresponding entry is described; numbers
underlined refer to the code line of the definition; numbers in roman refer to the code lines where
the entry is used.
Symbols
\# . . . . . . . . . . . . . . . . . 701
\@@@DETERMINANT . 1273, 1286
\@@@INVERSEMATRIX 1302, 1341
\@@@MATRIXABSVALUE 1195, 1203
\@@@MATRIXADD . . . 1164, 1175
\@@@MATRIXCOPY . . 1108, 1116
\@@@MATRIXGLOBALCOPY . . .
. . . . . . . . . . 1120, 1128
\@@@MATRIXPRODUCT 1256, 1267
\@@@MATRIXSUB . . . 1180, 1191
\@@@MATRIXVECTORPRODUCT
. . . . . . . . . . 1208, 1218
\@@@OUTPUTMATRIX
1133, 1146
\@@@OUTPUTVECTOR . . 935, 942
\@@@SCALARMATRIXPRODUCT
. . . . . . . . . . 1240, 1251
\@@@SCALARPRODUCT . 948, 960
\@@@SCALARVECTORPRODUCT
. . . . . . . . . . 1019, 1028
\@@@SOLVELINEARSYSTEM . .
. . . . . . . . . . 1399, 1418
\@@@TRANSPOSEMATRIX . . . .
. . . . . . . . . . 1150, 1159
\@@@TRUNCATE . . 278, 280, 283
\@@@VECTORABSVALUE 1007, 1014
82
\ABSVALUE
156,
338,
631,
A
. . . 7, 142,
230, 313,
397, 439,
644, 657,
83
155,
314,
586,
668,
\ccls@defvectorfunction
. . . . . . . . . . . 1570,
1578, 1581, 1586, 1587
\ccls@ErrorFuncDef 1445, 1508
\ccls@ErrorFuncUnDef . . .
. . . . . . . . . . 1452, 1512
\ccls@ErrorPFuncDef . . . .
. . . . . . . . . . 1462, 1535
\ccls@ErrorPFuncUnDef . .
. . . . . . . . . . 1470, 1539
\ccls@ErrorVFuncDef . . . .
. . . . . . . . . . 1483, 1572
\ccls@ErrorVFuncUnDef . .
. . . . . . . . . . 1491, 1576
\ccls@InfoFuncEns 1458, 1519
\ccls@InfoPFuncEns 1479, 1546
\ccls@InfoVFuncEns 1500, 1583
\ccls@LINafbg . . . 1864, 1866
\ccls@LINDafbg . . 1865, 1867
\ccls@LINDf . 1858, 1862, 1865
\ccls@LINDg . 1859, 1863, 1865
\ccls@LINf . 1858, 1860, 1864
\ccls@LINg . 1859, 1861, 1864
\ccls@lpoly . . . . . . 1599,
1602, 1605, 1608, 1609
\ccls@nminusone . 1848, 1849
\ccls@polarx . . . . 1870, 1872
\ccls@polary . . . . 1871, 1872
\ccls@POWDf . . . . . 1846, 1851
\ccls@POWDfn 18491851, 1853
\ccls@POWf . 1846, 1847, 1849
\ccls@POWfn . . . . . 1847, 1852
\ccls@PRODf . . . . . 1793, 1797
\ccls@PRODfg 1797, 1798, 1800
\ccls@PRODg . . . . . 1794, 1796
\ccls@PROf . 1793, 1795, 1796
\ccls@PROfDg . . . . 1796, 1798
\ccls@PROfg . . . . . 1795, 1799
\ccls@PROg . 1794, 1795, 1797
\ccls@qpoly . . . . . . 1615,
1618, 1621, 1624, 1625
\ccls@qsquaretempg 1811, 1812
\ccls@QUODf . . . . . 1805, 1809
\ccls@QUODfg . . . . . . . . . .
. 1809, 1810, 1812, 1814
\ccls@QUODg . . . . . 1806, 1808
\ccls@QUOf . 1805, 1807, 1808
\ccls@QUOfDg . . . . 1808, 1810
\ccls@QUOfg . . . . . 1807, 1813
\ccls@QUOg . . . . . . . . . . .
. 1806, 1807, 1809, 1811
\ccls@QUOnum . . . . 1810, 1812
\ccls@SCFaf . . . . . 1829, 1831
\ccls@SCFDaf . . . . 1830, 1832
\ccls@SCFDf . . . . . 1828, 1830
\ccls@SCFf . . . . . 1828, 1829
\ccls@SCVat . . . . . 1837, 1838
\ccls@SCVDf . 1838, 1839, 1841
\ccls@SCVf . . . . . 1838, 1840
\ccls@sint . 1557, 1558, 1561
\ccls@SUBDf . . . . . 1783, 1786
\ccls@SUBDfg . . . . 1786, 1788
\ccls@SUBDg . . . . . 1784, 1786
\ccls@SUBf . . . . . 1783, 1785
\ccls@SUBfg . . . . . 1785, 1787
\ccls@SUBg . . . . . 1784, 1785
\ccls@SUMDf . . . . . 1773, 1776
\ccls@SUMDfg . . . . 1776, 1778
\ccls@SUMDg . . . . . 1774, 1776
\ccls@SUMf . . . . . 1773, 1775
\ccls@SUMfg . . . . . 1775, 1777
\ccls@SUMg . . . . . 1774, 1775
\ccls@temp . . . . . 1648, 1649
\cctr@@det . . . . . . 1288,
1303, 1336, 1401, 1402
\cctr@@deta . . . . . 1358, 1361
\cctr@@detb . . . . . 1359, 1365
\cctr@@detc . . . . . 1360, 1368
\cctr@absval . . . . . . 586,
587, 631, 632, 644,
645, 657, 658, 668, 669
\cctr@ae . . 685, 686, 690, 691
\cctr@det . . . 12741278,
1298, 1299, 1310,
1312, 1314, 1335,
1336, 1400, 1401, 1409
\cctr@deta . . . . . . . . . . .
. 1355, 1358, 13621364
\cctr@detb . 1356, 1359, 1362
\cctr@detc . 1357, 1360, 1363
\cctr@epsilon 6, 360, 576,
680, 705, 758, 1288,
1303, 1361, 1365,
1368, 1373, 1377,
1381, 1385, 1390, 1402
\cctr@expminusx . . . . . . .
. . . . 638, 639, 651, 652
\cctr@expt 595, 596, 603, 604
\cctr@expx 636, 639, 649, 652
84
\cctr@sol . . . . . . . . . . . .
. 1101, 1274, 1276, 1278
\cctr@solAA . . . . . . . . . . .
. . 1056, 1066, 1076,
1097, 1165, 1181,
1241, 1257, 1304,
1310, 1311, 1323, 1406
\cctr@solAB . . 1057, 1067,
1077, 1165, 1181,
1241, 1257, 1304,
1310, 1311, 1326, 1406
\cctr@solAC . . 1058, 1068,
1078, 1165, 1181,
1241, 1257, 1304,
1310, 1311, 1329, 1406
\cctr@solBA . . 1059, 1069,
1079, 1166, 1182,
1242, 1258, 1305,
1312, 1313, 1324, 1407
\cctr@solBB . . 1060, 1070,
1080, 1166, 1182,
1242, 1258, 1305,
1312, 1313, 1327, 1407
\cctr@solBC . . 1061, 1071,
1081, 1166, 1182,
1242, 1258, 1305,
1312, 1313, 1330, 1407
\cctr@solCA . . 1062, 1072,
1082, 1167, 1183,
1243, 1259, 1306,
1314, 1315, 1325, 1408
\cctr@solCB . . 1063, 1073,
1083, 1167, 1183,
1243, 1259, 1306,
1314, 1315, 1328, 1408
\cctr@solCC . . 1064, 1074,
1084, 1167, 1183,
1243, 1259, 1306,
1314, 1315, 1331, 1408
\cctr@tanhden . . . . . . . . .
. . . . 663, 664, 673, 675
\cctr@tanhnum . . . . . . . . .
. . . . 662, 664, 674, 675
\cctr@temp 243, 246, 252
254, 296, 297, 1031, 1032
\cctr@tempA . . . . . . . 267, 268
\cctr@tempa . . . . . . . 201,
203, 222, 224, 226,
276, 277, 313, 315,
316, 318, 326330,
85
\cctr@tempr . . . . . . . . . . .
. 162, 166, 167, 169, 172
\cctr@tempw . . . . 361363,
366, 367, 703, 706,
707, 709711, 716,
759, 761, 763, 765, 767
\cctr@tempx 737739, 745747
\cctr@tempxw . . . . . . 707709
\cctr@tempxx 739, 740, 747, 748
\cctr@tempy 753, 754, 757,
760, 763, 764, 767770
\cctr@tempz . . . . . . . 362
365, 761, 762, 764766
\cctr@Warnbigarccos . . . .
. . . . . . . . . 36, 786, 790
\cctr@Warnbigarcsin . . . .
. . . . . . . . . 30, 730, 734
\cctr@Warnbigartanh . . . .
. . . . . . . . . 48, 868, 872
\cctr@Warncrossprod 119, 965
\cctr@Warndivzero . . 9, 186
\cctr@WarnIncLinSys 71, 1342
\cctr@WarnIncTDLinSys . .
. . . . . . . . . . . 74, 1349
\cctr@WarnIndLinSys 78, 1345
\cctr@Warninfcotan . . . . .
. . . . . . . . . 92, 470, 558
\cctr@Warninfexp . . . 98,
588, 633, 646, 659, 670
\cctr@Warninfexpb . 106, 577
\cctr@Warninflog . . 113, 681
\cctr@Warninftan . . . . . .
. . 86, 420, 424, 533, 537
\cctr@Warnnoangle . . . . .
. . . . . . 125, 1045, 1049
\cctr@Warnnogcd . . . . 14, 320
\cctr@Warnnointexp . . 24, 211
\cctr@Warnnoposrad . . 18, 356
\cctr@Warnsingmatrix 61, 1293
\cctr@WarnsingTDmatrix .
. . . . . . . . . . . 66, 1307
\cctr@Warnsmallarcosh 42, 856
\cctr@Warnsmallarcoth 54, 888
\cctr@WarnZeroLinSys 82, 1394
\COMPOSITIONfunction 25, 1816
\CONSTANTfunction . 24, 1766
\COPY 5, 130, 132, 135, 138,
141, 144, 157160,
163, 164, 169, 173,
189, 222, 223, 247,
86
. . 2, 1442
. 27, 1632
. . 29,
1598,
1657,
1666,
87
\PackageWarning . . . . . . .
. . . . 10, 15, 19, 25,
31, 37, 43, 49, 55, 62,
67, 71, 74, 78, 82, 87,
93, 99, 107, 114, 120, 126
\PARAMETRICfunction . . . .
. . . 27, 1872, 1873, 1877
\POLARfunction . . . . 28, 1869
\POWER 7, 207, 301, 1847, 1849
\POWERfunction . . . . 25, 1843
\PRODUCTfunction . . . . . .
. . . 25, 1790, 1870, 1871
\ProvidesPackage . . . 3, 1443
Q
\QUOTIENTfunction
. 25, 1802
R
\r . . . . . . . . . . . . 1556, 1558
\RADtoDEG . . . . . . . . 13, 476
\RECIPROCALfunction 23, 1666
\REDUCEDEGREESANGLE 13, 488
\REDUCERADIANSANGLE 13, 477
\renewcpoly . . . . . . . 27, 1635
\renewfunction
29, 1451,
1510, 1601, 1617, 1636
\renewlpoly . . . . . . . 27, 1600
\renewpolarfunction . . . .
. . . . . . . 30, 1468, 1537
\renewqpoly . . . . . . . 27, 1616
\renewvectorfunction . . .
. . . . . . . 29, 1489, 1574
\ROUND . . . . . . . . . . . . 8, 291
S
\SCALARMATRIXPRODUCT . . .
. . . . . . . 20, 1236, 1299
\SCALARPRODUCT . . . . . 17,
943,
961,
1031,
1042, 1205, 1206,
12091211, 1220, 1221
\SCALARVECTORPRODUCT . . .
. . . . 16, 1015, 1037,
1224, 1225, 1227,
1237, 1238, 12411243
\SCALEfunction . . . . 25, 1825
\SCALEVARIABLEfunction .
. . . . . . . . . . . 25, 1834
\setlength . . . . . . . . . . 194
\SIN . . . 11, 373, 416, 761,
1557, 1685, 1688, 1697
T
1526, 1553, 1555,
88
\VECTORMATRIXPRODUCT . . .
. . . . . 1219, 12571259
\VECTORNORM . . . 17, 1029,
1035, 1040, 1041, 1389
\VECTORPRODUCT . 17, 962, 978
\VECTORSIZE 906, 916, 927,
939, 957, 974, 989,
1000, 1011, 1025, 1232
\VECTORSUB . . . . 16, 993,
1177, 1178, 11811183
\x . . .
X
1556, 1562, 1563, 1592
Y
\y . . . . 1528, 1558, 1560,
1565, 1594, 1610,
1611, 1626, 1627,
16291631,
1645
1647, 1650, 1652,
1654, 1655, 1658,
1661, 1664, 1667,
1668, 1671, 1675,
1678, 1679, 1681,
1682, 1684, 1688,
1691, 1696, 1701,
1704, 1707, 1712,
1717, 1720, 1723,
1729, 1735, 1740,
1745, 1751, 1757, 1762
\yy . . . 17241726, 1730
1732,
17361738,
17411743,
1746
1748,
17521754,
17581760,
17631765
Z
\ZEROfunction . . . . . 23, 1660