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:: |
3803
|
17 * Coordinate Transformations:: |
3294
|
18 * Mathematical Constants:: |
|
19 @end menu |
|
20 |
|
21 @node Utility Functions, Complex Arithmetic, Arithmetic, Arithmetic |
|
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 |
3321
|
31 @DOCSTRING(exp) |
3294
|
32 |
3321
|
33 @DOCSTRING(fix) |
3294
|
34 |
3321
|
35 @DOCSTRING(floor) |
3294
|
36 |
3321
|
37 @DOCSTRING(gcd) |
3294
|
38 |
3321
|
39 @DOCSTRING(lcm) |
3294
|
40 |
3321
|
41 @DOCSTRING(log) |
3294
|
42 |
3321
|
43 @DOCSTRING(log10) |
3294
|
44 |
3321
|
45 @DOCSTRING(log2) |
3294
|
46 |
3321
|
47 @DOCSTRING(max) |
3294
|
48 |
3321
|
49 @DOCSTRING(min) |
|
50 |
3982
|
51 @DOCSTRING(mod) |
|
52 |
3321
|
53 @DOCSTRING(nextpow2) |
3294
|
54 |
3321
|
55 @DOCSTRING(pow2) |
3294
|
56 |
3321
|
57 @DOCSTRING(rem) |
3294
|
58 |
3321
|
59 @DOCSTRING(round) |
3294
|
60 |
3321
|
61 @DOCSTRING(sign) |
3294
|
62 |
3321
|
63 @DOCSTRING(sqrt) |
3294
|
64 |
|
65 @node Complex Arithmetic, Trigonometry, Utility Functions, Arithmetic |
|
66 @section Complex Arithmetic |
|
67 |
|
68 The following functions are available for working with complex |
|
69 numbers. Each expects a single argument. Given a matrix they work on |
|
70 an element by element basis. In the descriptions of the following |
|
71 functions, |
|
72 @iftex |
|
73 @tex |
|
74 $z$ is the complex number $x + iy$, where $i$ is defined as |
|
75 $\sqrt{-1}$. |
|
76 @end tex |
|
77 @end iftex |
|
78 @ifinfo |
|
79 @var{z} is the complex number @var{x} + @var{i}@var{y}, where @var{i} is |
|
80 defined as @code{sqrt (-1)}. |
|
81 @end ifinfo |
|
82 |
3321
|
83 @DOCSTRING(abs) |
3294
|
84 |
3321
|
85 @DOCSTRING(arg) |
3294
|
86 |
3321
|
87 @DOCSTRING(conj) |
3294
|
88 |
3321
|
89 @DOCSTRING(imag) |
3294
|
90 |
3321
|
91 @DOCSTRING(real) |
3294
|
92 |
|
93 @node Trigonometry, Sums and Products, Complex Arithmetic, Arithmetic |
|
94 @section Trigonometry |
|
95 |
|
96 Octave provides the following trigonometric functions. Angles are |
|
97 specified in radians. To convert from degrees to radians multipy by |
|
98 @iftex |
|
99 @tex |
|
100 $\pi/180$ |
|
101 @end tex |
|
102 @end iftex |
|
103 @ifinfo |
|
104 @code{pi/180} |
|
105 @end ifinfo |
|
106 (e.g. @code{sin (30 * pi/180)} returns the sine of 30 degrees). |
|
107 |
3321
|
108 @DOCSTRING(sin) |
|
109 @DOCSTRING(cos) |
|
110 @DOCSTRING(tan) |
|
111 @DOCSTRING(sec) |
|
112 @DOCSTRING(csc) |
|
113 @DOCSTRING(cot) |
3294
|
114 |
3321
|
115 @DOCSTRING(asin) |
|
116 @DOCSTRING(acos) |
|
117 @DOCSTRING(atan) |
|
118 @DOCSTRING(asec) |
|
119 @DOCSTRING(acsc) |
|
120 @DOCSTRING(acot) |
3294
|
121 |
3321
|
122 @DOCSTRING(sinh) |
|
123 @DOCSTRING(cosh) |
|
124 @DOCSTRING(tanh) |
|
125 @DOCSTRING(sech) |
3428
|
126 @DOCSTRING(csch) |
3321
|
127 @DOCSTRING(coth) |
3294
|
128 |
3321
|
129 @DOCSTRING(asinh) |
|
130 @DOCSTRING(acosh) |
|
131 @DOCSTRING(atanh) |
|
132 @DOCSTRING(asech) |
|
133 @DOCSTRING(acsch) |
|
134 @DOCSTRING(acoth) |
3294
|
135 |
|
136 Each of these functions expect a single argument. For matrix arguments, |
|
137 they work on an element by element basis. For example, |
|
138 |
|
139 @example |
|
140 @group |
|
141 sin ([1, 2; 3, 4]) |
|
142 @result{} 0.84147 0.90930 |
|
143 0.14112 -0.75680 |
|
144 @end group |
|
145 @end example |
|
146 |
3321
|
147 @DOCSTRING(atan2) |
|
148 |
3294
|
149 |
|
150 @node Sums and Products, Special Functions, Trigonometry, Arithmetic |
|
151 @section Sums and Products |
|
152 |
3321
|
153 @DOCSTRING(sum) |
3294
|
154 |
3321
|
155 @DOCSTRING(prod) |
3294
|
156 |
3321
|
157 @DOCSTRING(cumsum) |
3294
|
158 |
3321
|
159 @DOCSTRING(cumprod) |
3294
|
160 |
3321
|
161 @DOCSTRING(sumsq) |
3294
|
162 |
3803
|
163 @node Special Functions, Coordinate Transformations, Sums and Products, Arithmetic |
3294
|
164 @section Special Functions |
|
165 |
3459
|
166 @DOCSTRING(besselj) |
|
167 |
|
168 @DOCSTRING(airy) |
3294
|
169 |
3321
|
170 @DOCSTRING(beta) |
3294
|
171 |
3444
|
172 @DOCSTRING(betainc) |
3294
|
173 |
3321
|
174 @DOCSTRING(bincoeff) |
3294
|
175 |
3321
|
176 @DOCSTRING(erf) |
3294
|
177 |
3321
|
178 @DOCSTRING(erfc) |
3294
|
179 |
3321
|
180 @DOCSTRING(erfinv) |
3294
|
181 |
3321
|
182 @DOCSTRING(gamma) |
3294
|
183 |
3444
|
184 @DOCSTRING(gammainc) |
3294
|
185 |
3321
|
186 @DOCSTRING(lgamma) |
|
187 |
|
188 @DOCSTRING(cross) |
3294
|
189 |
3321
|
190 @DOCSTRING(commutation_matrix) |
3294
|
191 |
3321
|
192 @DOCSTRING(duplication_matrix) |
3294
|
193 |
3803
|
194 @node Coordinate Transformations, Mathematical Constants, Special Functions, Arithmetic |
|
195 @section Coordinate Transformations |
|
196 |
|
197 @DOCSTRING(cart2pol) |
|
198 |
|
199 @DOCSTRING(pol2cart) |
|
200 |
|
201 @DOCSTRING(cart2sph) |
|
202 |
|
203 @DOCSTRING(sph2cart) |
|
204 |
|
205 @node Mathematical Constants, , Coordinate Transformations, Arithmetic |
3294
|
206 @section Mathematical Constants |
|
207 |
3321
|
208 @DOCSTRING(I) |
|
209 |
|
210 @DOCSTRING(Inf) |
3294
|
211 |
3321
|
212 @DOCSTRING(NaN) |
3294
|
213 |
3321
|
214 @DOCSTRING(pi) |
3294
|
215 |
3321
|
216 @DOCSTRING(e) |
|
217 |
|
218 @DOCSTRING(eps) |
3294
|
219 |
3321
|
220 @DOCSTRING(realmax) |
3294
|
221 |
3321
|
222 @DOCSTRING(realmin) |