6778
|
1 @c Copyright (C) 1996, 1997, 2007 John W. Eaton |
3294
|
2 @c This is part of the Octave manual. |
|
3 @c For copying conditions, see the file gpl.texi. |
|
4 |
4167
|
5 @node Arithmetic |
3294
|
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:: |
3803
|
17 * Coordinate Transformations:: |
3294
|
18 * Mathematical Constants:: |
|
19 @end menu |
|
20 |
4169
|
21 @node Utility Functions |
3294
|
22 @section Utility Functions |
|
23 |
|
24 The following functions are available for working with complex numbers. |
|
25 Each expects a single argument. They are called @dfn{mapping functions} |
|
26 because when given a matrix argument, they apply the given function to |
|
27 each element of the matrix. |
|
28 |
3321
|
29 @DOCSTRING(ceil) |
3294
|
30 |
6550
|
31 @DOCSTRING(cplxpair) |
|
32 |
3321
|
33 @DOCSTRING(exp) |
3294
|
34 |
6550
|
35 @DOCSTRING(factor) |
|
36 |
|
37 @DOCSTRING(factorial) |
|
38 |
3321
|
39 @DOCSTRING(fix) |
3294
|
40 |
3321
|
41 @DOCSTRING(floor) |
3294
|
42 |
6550
|
43 @DOCSTRING(fmod) |
|
44 |
3321
|
45 @DOCSTRING(gcd) |
3294
|
46 |
6551
|
47 @DOCSTRING(gradient) |
|
48 |
3321
|
49 @DOCSTRING(lcm) |
3294
|
50 |
3321
|
51 @DOCSTRING(log) |
3294
|
52 |
3321
|
53 @DOCSTRING(log10) |
3294
|
54 |
3321
|
55 @DOCSTRING(log2) |
3294
|
56 |
3321
|
57 @DOCSTRING(max) |
3294
|
58 |
3321
|
59 @DOCSTRING(min) |
|
60 |
3982
|
61 @DOCSTRING(mod) |
|
62 |
3321
|
63 @DOCSTRING(nextpow2) |
3294
|
64 |
6550
|
65 @DOCSTRING(nthroot) |
|
66 |
3321
|
67 @DOCSTRING(pow2) |
3294
|
68 |
6550
|
69 @DOCSTRING(primes) |
|
70 |
3321
|
71 @DOCSTRING(rem) |
3294
|
72 |
3321
|
73 @DOCSTRING(round) |
3294
|
74 |
3321
|
75 @DOCSTRING(sign) |
3294
|
76 |
3321
|
77 @DOCSTRING(sqrt) |
3294
|
78 |
4169
|
79 @node Complex Arithmetic |
3294
|
80 @section Complex Arithmetic |
|
81 |
|
82 The following functions are available for working with complex |
|
83 numbers. Each expects a single argument. Given a matrix they work on |
|
84 an element by element basis. In the descriptions of the following |
|
85 functions, |
|
86 @iftex |
|
87 @tex |
|
88 $z$ is the complex number $x + iy$, where $i$ is defined as |
|
89 $\sqrt{-1}$. |
|
90 @end tex |
|
91 @end iftex |
|
92 @ifinfo |
|
93 @var{z} is the complex number @var{x} + @var{i}@var{y}, where @var{i} is |
|
94 defined as @code{sqrt (-1)}. |
|
95 @end ifinfo |
|
96 |
3321
|
97 @DOCSTRING(abs) |
3294
|
98 |
3321
|
99 @DOCSTRING(arg) |
3294
|
100 |
3321
|
101 @DOCSTRING(conj) |
3294
|
102 |
3321
|
103 @DOCSTRING(imag) |
3294
|
104 |
3321
|
105 @DOCSTRING(real) |
3294
|
106 |
4169
|
107 @node Trigonometry |
3294
|
108 @section Trigonometry |
|
109 |
|
110 Octave provides the following trigonometric functions. Angles are |
|
111 specified in radians. To convert from degrees to radians multipy by |
|
112 @iftex |
|
113 @tex |
|
114 $\pi/180$ |
|
115 @end tex |
|
116 @end iftex |
|
117 @ifinfo |
|
118 @code{pi/180} |
|
119 @end ifinfo |
|
120 (e.g. @code{sin (30 * pi/180)} returns the sine of 30 degrees). |
|
121 |
3321
|
122 @DOCSTRING(sin) |
|
123 @DOCSTRING(cos) |
|
124 @DOCSTRING(tan) |
|
125 @DOCSTRING(sec) |
|
126 @DOCSTRING(csc) |
|
127 @DOCSTRING(cot) |
3294
|
128 |
3321
|
129 @DOCSTRING(asin) |
|
130 @DOCSTRING(acos) |
|
131 @DOCSTRING(atan) |
|
132 @DOCSTRING(asec) |
|
133 @DOCSTRING(acsc) |
|
134 @DOCSTRING(acot) |
3294
|
135 |
3321
|
136 @DOCSTRING(sinh) |
|
137 @DOCSTRING(cosh) |
|
138 @DOCSTRING(tanh) |
|
139 @DOCSTRING(sech) |
3428
|
140 @DOCSTRING(csch) |
3321
|
141 @DOCSTRING(coth) |
3294
|
142 |
3321
|
143 @DOCSTRING(asinh) |
|
144 @DOCSTRING(acosh) |
|
145 @DOCSTRING(atanh) |
|
146 @DOCSTRING(asech) |
|
147 @DOCSTRING(acsch) |
|
148 @DOCSTRING(acoth) |
3294
|
149 |
|
150 Each of these functions expect a single argument. For matrix arguments, |
|
151 they work on an element by element basis. For example, |
|
152 |
|
153 @example |
|
154 @group |
|
155 sin ([1, 2; 3, 4]) |
|
156 @result{} 0.84147 0.90930 |
|
157 0.14112 -0.75680 |
|
158 @end group |
|
159 @end example |
|
160 |
3321
|
161 @DOCSTRING(atan2) |
|
162 |
6502
|
163 In addition to the trigonometric functions that work with radians, |
|
164 Octave also provides the following functions which work with degrees. |
|
165 |
|
166 @DOCSTRING(sind) |
|
167 @DOCSTRING(cosd) |
|
168 @DOCSTRING(tand) |
|
169 @DOCSTRING(secd) |
|
170 @DOCSTRING(cscd) |
|
171 @DOCSTRING(cotd) |
|
172 |
|
173 @DOCSTRING(asind) |
|
174 @DOCSTRING(acosd) |
|
175 @DOCSTRING(atand) |
|
176 @DOCSTRING(asecd) |
|
177 @DOCSTRING(acscd) |
|
178 @DOCSTRING(acotd) |
3294
|
179 |
4169
|
180 @node Sums and Products |
3294
|
181 @section Sums and Products |
|
182 |
3321
|
183 @DOCSTRING(sum) |
3294
|
184 |
3321
|
185 @DOCSTRING(prod) |
3294
|
186 |
3321
|
187 @DOCSTRING(cumsum) |
3294
|
188 |
3321
|
189 @DOCSTRING(cumprod) |
3294
|
190 |
3321
|
191 @DOCSTRING(sumsq) |
3294
|
192 |
6770
|
193 @DOCSTRING(accumarray) |
|
194 |
4169
|
195 @node Special Functions |
3294
|
196 @section Special Functions |
|
197 |
3459
|
198 @DOCSTRING(besselj) |
|
199 |
|
200 @DOCSTRING(airy) |
3294
|
201 |
3321
|
202 @DOCSTRING(beta) |
3294
|
203 |
3444
|
204 @DOCSTRING(betainc) |
3294
|
205 |
6502
|
206 @DOCSTRING(betaln) |
|
207 |
3321
|
208 @DOCSTRING(bincoeff) |
3294
|
209 |
3321
|
210 @DOCSTRING(erf) |
3294
|
211 |
3321
|
212 @DOCSTRING(erfc) |
3294
|
213 |
3321
|
214 @DOCSTRING(erfinv) |
3294
|
215 |
3321
|
216 @DOCSTRING(gamma) |
3294
|
217 |
3444
|
218 @DOCSTRING(gammainc) |
3294
|
219 |
6502
|
220 @DOCSTRING(legendre) |
|
221 |
3321
|
222 @DOCSTRING(lgamma) |
|
223 |
|
224 @DOCSTRING(cross) |
3294
|
225 |
3321
|
226 @DOCSTRING(commutation_matrix) |
3294
|
227 |
3321
|
228 @DOCSTRING(duplication_matrix) |
3294
|
229 |
4169
|
230 @node Coordinate Transformations |
3803
|
231 @section Coordinate Transformations |
|
232 |
|
233 @DOCSTRING(cart2pol) |
|
234 |
|
235 @DOCSTRING(pol2cart) |
|
236 |
|
237 @DOCSTRING(cart2sph) |
|
238 |
|
239 @DOCSTRING(sph2cart) |
|
240 |
4169
|
241 @node Mathematical Constants |
3294
|
242 @section Mathematical Constants |
|
243 |
3321
|
244 @DOCSTRING(I) |
|
245 |
|
246 @DOCSTRING(Inf) |
3294
|
247 |
3321
|
248 @DOCSTRING(NaN) |
3294
|
249 |
3321
|
250 @DOCSTRING(pi) |
3294
|
251 |
3321
|
252 @DOCSTRING(e) |
|
253 |
|
254 @DOCSTRING(eps) |
3294
|
255 |
3321
|
256 @DOCSTRING(realmax) |
3294
|
257 |
3321
|
258 @DOCSTRING(realmin) |