Debian Codegraph @

texmf-dist/doc/latex/calculator/README.md

raw
1 The calculator and calculus packages: Use \LaTeX as a scientific calculator.
2
3 Robert Fuster, 2012, 2014, 2022
4
5
6 1. Licence
7 ----------
8 This material is subject to the LaTeX Project Public License.
9
10 See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html
11 for the details of that license.
12
13 2. Changes in version 2.1
14 -------------------------
15 - Some bugs fixed
16
17 2. Changes in version 2.0
18 -------------------------
19 - Inverse trigonometric and inverse hyperbolic functions are added
20 (this completes the typical elementary functions)
21
22 - Also vector (cross) product and angle between vectors can be evaluated
23
24 - New length operations
25
26 - ... and some other minor additions and changes
27
28 3. About the packages
29 ---------------------
30 The calculator and calculus packages define several instructions which allow us
31 to realize algebraic operations and to evaluate elementary functions
32 and derivatives in our documents.
33
34 My main goal is to define the arithmetic and functional calculations I need in
35 my package "xpicture"
36 (http://ctan.org/pkg/xpicture, http://www.upv.es/~rfuster/xpicture),
37 but the numeric abilities of "calculator" and "calculus" may be useful
38 in other contexts.
39
40 3.1 The calculator package
41 --------------------------
42 The operations implemented by the calculator package include
43 - arithmetical calculations with real and integer numbers
44 - two and three dimensional vectors and matrices arithmetics
45 - computation of powers, square roots, trigonometric, exponential,
46 logarithmic, hyperbolic, inverse trigonometric
47 and inverse hyperbolic functions.
48
49 In addition, some important numbers, such as pi, sqrt(2) or e, are predefined.
50
51 Some simple examples:
52
53 a) Simplify a fraction: if you type
54
55 \FRACTIONSIMPLIFY{252}{2220}{\num}{\den}
56
57 Then, $\num/\den$ equals to 21/186
58
59 b) Compute elementary functions:
60
61 \LOG{2}{\sol} ---> \sol equals 0.69315
62
63 \LOG[10]{2}{\sol} ---> \sol equals 0.30103
64
65 \SIN{\numberHALFPI}{\sol} ---> \sol equals 1
66
67 c) More complex calculations:
68 You can compute the value of sqrt(7.25)cos(pi/7) by typing
69
70 \SQRT{7.25}{\tempa}
71 \DIVIDE{\numberPI}{7}{\tempb}
72 \COS{\tempb}{\tempc}
73 \MULTIPLY{\tempa}{\tempc}{\sol}
74
75 Then, the value 2.42589 is stored in \sol.
76
77 d) Vectors and matrices:
78
79 \SCALARPRODUCT(1,2)(2,1){\sol} ---> \sol equals 4
80
81 \MATRIXPRODUCT(1,1;-1,2)(0,-1;1,1)(\sola,\solb;\solc,\sold)
82 ---> \sola, \solb, \solc, \sold equals 1, 0, 2, 3.
83
84
85 3.2. The calculus package
86 -------------------------
87 This package adds to the calculator package several utilities to use and define
88 real functions and their derivatives, including elementary functions,
89 operations with functions, vector-valuated functions polar coordinates.
90 When you call a "function", this function ant its derivative are evaluated
91 simultaneously.
92
93 Examples:
94
95 a) Predefined functions:
96
97 \SINfunction{\numberPI}{\sol}{\Dsol} --->
98 \sol equals to 0 (=sin(pi)), and \Dsol equals -1 (=cos(pi)),
99 because cos(t) is the derivative of sin(t).
100
101 b) Defining new functions: You can define the function f(t)=exp(2t)cos(t)-t
102 with the following code:
103
104 \SCALEVARIABLEfunction{2}{\EXPfunction}{\functionA} % A=e^(2t)
105 \MULTIPLY{\functionA}{\COSfunction}{\functionB} % b=e^(2t)cos(t)
106 \SUBTRACTfunction{\functionB}{\IDENTITYfunction}{\functionF} % My function
107
108 Then, \functionF{num}{\sol}{\Dsol} stores f(num) and f'(num) in \sol and \Dsol.
109
110
111 4. Installation and documentation
112 ---------------------------------
113 1. Compile the installation file "calculator.ins",
114
115 >> latex calculator.ins
116
117 to generate the two essential files,
118
119 "calculator.sty" and "calculus.sty".
120
121 Move these two files where LaTeX search for
122 (typically, in a local texmf tree, at tex/latex/calculator)
123 and refresh the file database.
124
125 2. To have the documentation and user's manual, "calculator.pdf",
126 compile the source file "calculator.dtx" in the following sequence:
127
128 >> pdflatex calculator.dtx
129 >> makeindex -s gind.ist -o calculator.ind calculator.idx
130 >> makeindex -s gglo.ist -o calculator.gls calculator.glo
131 >> pdflatex calculator.dtx
132 >> pdflatex calculator.dtx
133
134 In addition, many small files, named "calculatorNN.tex" are generated.
135 These files contain the source code of all examples included in the manual.
136 You can store or discard this files.
137
138 ---------------------------------------------------------------
139 Robert Fuster
140 [email protected]
141
142 Universitat Polit\`ecnica de Val\`encia, 2012/05/19, 2014/02/23, 2022/09/15
143 ---------------------------------------------------------------