3294
|
1 @c Copyright (C) 1996, 1997 John W. Eaton |
|
2 @c This is part of the Octave manual. |
|
3 @c For copying conditions, see the file gpl.texi. |
|
4 |
|
5 @node Arithmetic, Linear Algebra, Matrix Manipulation, Top |
|
6 @chapter Arithmetic |
|
7 |
|
8 Unless otherwise noted, all of the functions described in this chapter |
|
9 will work for real and complex scalar or matrix arguments. |
|
10 |
|
11 @menu |
|
12 * Utility Functions:: |
|
13 * Complex Arithmetic:: |
|
14 * Trigonometry:: |
|
15 * Sums and Products:: |
|
16 * Special Functions:: |
|
17 * Mathematical Constants:: |
|
18 @end menu |
|
19 |
|
20 @node Utility Functions, Complex Arithmetic, Arithmetic, Arithmetic |
|
21 @section Utility Functions |
|
22 |
|
23 The following functions are available for working with complex numbers. |
|
24 Each expects a single argument. They are called @dfn{mapping functions} |
|
25 because when given a matrix argument, they apply the given function to |
|
26 each element of the matrix. |
|
27 |
3321
|
28 @DOCSTRING(ceil) |
3294
|
29 |
3321
|
30 @DOCSTRING(exp) |
3294
|
31 |
3321
|
32 @DOCSTRING(fix) |
3294
|
33 |
3321
|
34 @DOCSTRING(floor) |
3294
|
35 |
3321
|
36 @DOCSTRING(gcd) |
3294
|
37 |
3321
|
38 @DOCSTRING(lcm) |
3294
|
39 |
3321
|
40 @DOCSTRING(log) |
3294
|
41 |
3321
|
42 @DOCSTRING(log10) |
3294
|
43 |
3321
|
44 @DOCSTRING(log2) |
3294
|
45 |
3321
|
46 @DOCSTRING(max) |
3294
|
47 |
3321
|
48 @DOCSTRING(min) |
|
49 |
|
50 @DOCSTRING(nextpow2) |
3294
|
51 |
3321
|
52 @DOCSTRING(pow2) |
3294
|
53 |
3321
|
54 @DOCSTRING(rem) |
3294
|
55 |
3321
|
56 @DOCSTRING(round) |
3294
|
57 |
3321
|
58 @DOCSTRING(sign) |
3294
|
59 |
3321
|
60 @DOCSTRING(sqrt) |
3294
|
61 |
|
62 @node Complex Arithmetic, Trigonometry, Utility Functions, Arithmetic |
|
63 @section Complex Arithmetic |
|
64 |
|
65 The following functions are available for working with complex |
|
66 numbers. Each expects a single argument. Given a matrix they work on |
|
67 an element by element basis. In the descriptions of the following |
|
68 functions, |
|
69 @iftex |
|
70 @tex |
|
71 $z$ is the complex number $x + iy$, where $i$ is defined as |
|
72 $\sqrt{-1}$. |
|
73 @end tex |
|
74 @end iftex |
|
75 @ifinfo |
|
76 @var{z} is the complex number @var{x} + @var{i}@var{y}, where @var{i} is |
|
77 defined as @code{sqrt (-1)}. |
|
78 @end ifinfo |
|
79 |
3321
|
80 @DOCSTRING(abs) |
3294
|
81 |
3321
|
82 @DOCSTRING(arg) |
3294
|
83 |
3321
|
84 @DOCSTRING(conj) |
3294
|
85 |
3321
|
86 @DOCSTRING(imag) |
3294
|
87 |
3321
|
88 @DOCSTRING(real) |
3294
|
89 |
|
90 @node Trigonometry, Sums and Products, Complex Arithmetic, Arithmetic |
|
91 @section Trigonometry |
|
92 |
|
93 Octave provides the following trigonometric functions. Angles are |
|
94 specified in radians. To convert from degrees to radians multipy by |
|
95 @iftex |
|
96 @tex |
|
97 $\pi/180$ |
|
98 @end tex |
|
99 @end iftex |
|
100 @ifinfo |
|
101 @code{pi/180} |
|
102 @end ifinfo |
|
103 (e.g. @code{sin (30 * pi/180)} returns the sine of 30 degrees). |
|
104 |
3321
|
105 @DOCSTRING(sin) |
|
106 @DOCSTRING(cos) |
|
107 @DOCSTRING(tan) |
|
108 @DOCSTRING(sec) |
|
109 @DOCSTRING(csc) |
|
110 @DOCSTRING(cot) |
3294
|
111 |
3321
|
112 @DOCSTRING(asin) |
|
113 @DOCSTRING(acos) |
|
114 @DOCSTRING(atan) |
|
115 @DOCSTRING(asec) |
|
116 @DOCSTRING(acsc) |
|
117 @DOCSTRING(acot) |
3294
|
118 |
3321
|
119 @DOCSTRING(sinh) |
|
120 @DOCSTRING(cosh) |
|
121 @DOCSTRING(tanh) |
|
122 @DOCSTRING(sech) |
3428
|
123 @DOCSTRING(csch) |
3321
|
124 @DOCSTRING(coth) |
3294
|
125 |
3321
|
126 @DOCSTRING(asinh) |
|
127 @DOCSTRING(acosh) |
|
128 @DOCSTRING(atanh) |
|
129 @DOCSTRING(asech) |
|
130 @DOCSTRING(acsch) |
|
131 @DOCSTRING(acoth) |
3294
|
132 |
|
133 Each of these functions expect a single argument. For matrix arguments, |
|
134 they work on an element by element basis. For example, |
|
135 |
|
136 @example |
|
137 @group |
|
138 sin ([1, 2; 3, 4]) |
|
139 @result{} 0.84147 0.90930 |
|
140 0.14112 -0.75680 |
|
141 @end group |
|
142 @end example |
|
143 |
3321
|
144 @DOCSTRING(atan2) |
|
145 |
3294
|
146 |
|
147 @node Sums and Products, Special Functions, Trigonometry, Arithmetic |
|
148 @section Sums and Products |
|
149 |
3321
|
150 @DOCSTRING(sum) |
3294
|
151 |
3321
|
152 @DOCSTRING(prod) |
3294
|
153 |
3321
|
154 @DOCSTRING(cumsum) |
3294
|
155 |
3321
|
156 @DOCSTRING(cumprod) |
3294
|
157 |
3321
|
158 @DOCSTRING(sumsq) |
3294
|
159 |
|
160 @node Special Functions, Mathematical Constants, Sums and Products, Arithmetic |
|
161 @section Special Functions |
|
162 |
3321
|
163 @DOCSTRING(bessel) |
3294
|
164 |
3321
|
165 @DOCSTRING(beta) |
3294
|
166 |
3321
|
167 @DOCSTRING(betai) |
3294
|
168 |
3321
|
169 @DOCSTRING(bincoeff) |
3294
|
170 |
3321
|
171 @DOCSTRING(erf) |
3294
|
172 |
3321
|
173 @DOCSTRING(erfc) |
3294
|
174 |
3321
|
175 @DOCSTRING(erfinv) |
3294
|
176 |
3321
|
177 @DOCSTRING(gamma) |
3294
|
178 |
3321
|
179 @DOCSTRING(gammai) |
3294
|
180 |
3321
|
181 @DOCSTRING(lgamma) |
|
182 |
|
183 @DOCSTRING(cross) |
3294
|
184 |
3321
|
185 @DOCSTRING(commutation_matrix) |
3294
|
186 |
3321
|
187 @DOCSTRING(duplication_matrix) |
3294
|
188 |
|
189 @node Mathematical Constants, , Special Functions, Arithmetic |
|
190 @section Mathematical Constants |
|
191 |
3321
|
192 @DOCSTRING(I) |
|
193 |
|
194 @DOCSTRING(Inf) |
3294
|
195 |
3321
|
196 @DOCSTRING(NaN) |
3294
|
197 |
3321
|
198 @DOCSTRING(pi) |
3294
|
199 |
3321
|
200 @DOCSTRING(e) |
|
201 |
|
202 @DOCSTRING(eps) |
3294
|
203 |
3321
|
204 @DOCSTRING(realmax) |
3294
|
205 |
3321
|
206 @DOCSTRING(realmin) |