File: Trigonometry.html

package info (click to toggle)
octave 3.8.2-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 84,396 kB
  • ctags: 45,547
  • sloc: cpp: 293,356; ansic: 42,041; fortran: 23,669; sh: 13,629; objc: 7,890; yacc: 7,093; lex: 3,442; java: 2,125; makefile: 1,589; perl: 1,009; awk: 974; xml: 34
file content (385 lines) | stat: -rw-r--r-- 17,933 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
<head>
<title>GNU Octave: Trigonometry</title>

<meta name="description" content="GNU Octave: Trigonometry">
<meta name="keywords" content="GNU Octave: Trigonometry">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Arithmetic.html#Arithmetic" rel="up" title="Arithmetic">
<link href="Sums-and-Products.html#Sums-and-Products" rel="next" title="Sums and Products">
<link href="Complex-Arithmetic.html#Complex-Arithmetic" rel="prev" title="Complex Arithmetic">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>


</head>

<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Trigonometry"></a>
<div class="header">
<p>
Next: <a href="Sums-and-Products.html#Sums-and-Products" accesskey="n" rel="next">Sums and Products</a>, Previous: <a href="Complex-Arithmetic.html#Complex-Arithmetic" accesskey="p" rel="prev">Complex Arithmetic</a>, Up: <a href="Arithmetic.html#Arithmetic" accesskey="u" rel="up">Arithmetic</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="Trigonometry-1"></a>
<h3 class="section">17.3 Trigonometry</h3>

<p>Octave provides the following trigonometric functions where angles are
specified in radians.  To convert from degrees to radians multiply by
<code>pi/180</code>
(e.g., <code>sin (30 * pi/180)</code> returns the sine of 30 degrees).  As
an alternative, Octave provides a number of trigonometric functions
which work directly on an argument specified in degrees.  These functions
are named after the base trigonometric function with a &lsquo;<samp>d</samp>&rsquo; suffix.  For
example, <code>sin</code> expects an angle in radians while <code>sind</code> expects an
angle in degrees.
</p>
<p>Octave uses the C library trigonometric functions.  It is expected that these
functions are defined by the ISO/IEC 9899 Standard.  This Standard is available
at: <a href="http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf">http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf</a>.
Section F.9.1 deals with the trigonometric functions.  The behavior of most of
the functions is relatively straightforward.  However, there are some
exceptions to the standard behavior.  Many of the exceptions involve the
behavior for -0.  The most complex case is atan2.  Octave exactly implements
the behavior given in the Standard.  Including
<code>atan2(+- 0, 0)</code> returns <code>+- pi</code>.
</p>
<p>It should be noted that <small>MATLAB</small> uses different definitions which apparently
do not distinguish -0.
</p>
<a name="XREFsin"></a><dl>
<dt><a name="index-sin"></a>Mapping Function: <em></em> <strong>sin</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Compute the sine for each element of <var>x</var> in radians.
</p>
<p><strong>See also:</strong> <a href="#XREFasin">asin</a>, <a href="#XREFsind">sind</a>, <a href="#XREFsinh">sinh</a>.
</p></dd></dl>

<a name="XREFcos"></a><dl>
<dt><a name="index-cos"></a>Mapping Function: <em></em> <strong>cos</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Compute the cosine for each element of <var>x</var> in radians.
</p>
<p><strong>See also:</strong> <a href="#XREFacos">acos</a>, <a href="#XREFcosd">cosd</a>, <a href="#XREFcosh">cosh</a>.
</p></dd></dl>

<a name="XREFtan"></a><dl>
<dt><a name="index-tan"></a>Mapping Function: <em></em> <strong>tan</strong> <em>(<var>z</var>)</em></dt>
<dd><p>Compute the tangent for each element of <var>x</var> in radians.
</p>
<p><strong>See also:</strong> <a href="#XREFatan">atan</a>, <a href="#XREFtand">tand</a>, <a href="#XREFtanh">tanh</a>.
</p></dd></dl>

<a name="XREFsec"></a><dl>
<dt><a name="index-sec"></a>Mapping Function: <em></em> <strong>sec</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Compute the secant for each element of <var>x</var> in radians.
</p>
<p><strong>See also:</strong> <a href="#XREFasec">asec</a>, <a href="#XREFsecd">secd</a>, <a href="#XREFsech">sech</a>.
</p></dd></dl>

<a name="XREFcsc"></a><dl>
<dt><a name="index-csc"></a>Mapping Function: <em></em> <strong>csc</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Compute the cosecant for each element of <var>x</var> in radians.
</p>
<p><strong>See also:</strong> <a href="#XREFacsc">acsc</a>, <a href="#XREFcscd">cscd</a>, <a href="#XREFcsch">csch</a>.
</p></dd></dl>

<a name="XREFcot"></a><dl>
<dt><a name="index-cot"></a>Mapping Function: <em></em> <strong>cot</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Compute the cotangent for each element of <var>x</var> in radians.
</p>
<p><strong>See also:</strong> <a href="#XREFacot">acot</a>, <a href="#XREFcotd">cotd</a>, <a href="#XREFcoth">coth</a>.
</p></dd></dl>


<a name="XREFasin"></a><dl>
<dt><a name="index-asin"></a>Mapping Function: <em></em> <strong>asin</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Compute the inverse sine in radians for each element of <var>x</var>.
</p>
<p><strong>See also:</strong> <a href="#XREFsin">sin</a>, <a href="#XREFasind">asind</a>.
</p></dd></dl>

<a name="XREFacos"></a><dl>
<dt><a name="index-acos"></a>Mapping Function: <em></em> <strong>acos</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Compute the inverse cosine in radians for each element of <var>x</var>.
</p>
<p><strong>See also:</strong> <a href="#XREFcos">cos</a>, <a href="#XREFacosd">acosd</a>.
</p></dd></dl>

<a name="XREFatan"></a><dl>
<dt><a name="index-atan"></a>Mapping Function: <em></em> <strong>atan</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Compute the inverse tangent in radians for each element of <var>x</var>.
</p>
<p><strong>See also:</strong> <a href="#XREFtan">tan</a>, <a href="#XREFatand">atand</a>.
</p></dd></dl>

<a name="XREFasec"></a><dl>
<dt><a name="index-asec"></a>Mapping Function: <em></em> <strong>asec</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Compute the inverse secant in radians for each element of <var>x</var>.
</p>
<p><strong>See also:</strong> <a href="#XREFsec">sec</a>, <a href="#XREFasecd">asecd</a>.
</p></dd></dl>

<a name="XREFacsc"></a><dl>
<dt><a name="index-acsc"></a>Mapping Function: <em></em> <strong>acsc</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Compute the inverse cosecant in radians for each element of <var>x</var>.
</p>
<p><strong>See also:</strong> <a href="#XREFcsc">csc</a>, <a href="#XREFacscd">acscd</a>.
</p></dd></dl>

<a name="XREFacot"></a><dl>
<dt><a name="index-acot"></a>Mapping Function: <em></em> <strong>acot</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Compute the inverse cotangent in radians for each element of <var>x</var>.
</p>
<p><strong>See also:</strong> <a href="#XREFcot">cot</a>, <a href="#XREFacotd">acotd</a>.
</p></dd></dl>


<a name="XREFsinh"></a><dl>
<dt><a name="index-sinh"></a>Mapping Function: <em></em> <strong>sinh</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Compute the hyperbolic sine for each element of <var>x</var>.
</p>
<p><strong>See also:</strong> <a href="#XREFasinh">asinh</a>, <a href="#XREFcosh">cosh</a>, <a href="#XREFtanh">tanh</a>.
</p></dd></dl>

<a name="XREFcosh"></a><dl>
<dt><a name="index-cosh"></a>Mapping Function: <em></em> <strong>cosh</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Compute the hyperbolic cosine for each element of <var>x</var>.
</p>
<p><strong>See also:</strong> <a href="#XREFacosh">acosh</a>, <a href="#XREFsinh">sinh</a>, <a href="#XREFtanh">tanh</a>.
</p></dd></dl>

<a name="XREFtanh"></a><dl>
<dt><a name="index-tanh"></a>Mapping Function: <em></em> <strong>tanh</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Compute hyperbolic tangent for each element of <var>x</var>.
</p>
<p><strong>See also:</strong> <a href="#XREFatanh">atanh</a>, <a href="#XREFsinh">sinh</a>, <a href="#XREFcosh">cosh</a>.
</p></dd></dl>

<a name="XREFsech"></a><dl>
<dt><a name="index-sech"></a>Mapping Function: <em></em> <strong>sech</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Compute the hyperbolic secant of each element of <var>x</var>.
</p>
<p><strong>See also:</strong> <a href="#XREFasech">asech</a>.
</p></dd></dl>

<a name="XREFcsch"></a><dl>
<dt><a name="index-csch"></a>Mapping Function: <em></em> <strong>csch</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Compute the hyperbolic cosecant of each element of <var>x</var>.
</p>
<p><strong>See also:</strong> <a href="#XREFacsch">acsch</a>.
</p></dd></dl>

<a name="XREFcoth"></a><dl>
<dt><a name="index-coth"></a>Mapping Function: <em></em> <strong>coth</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Compute the hyperbolic cotangent of each element of <var>x</var>.
</p>
<p><strong>See also:</strong> <a href="#XREFacoth">acoth</a>.
</p></dd></dl>


<a name="XREFasinh"></a><dl>
<dt><a name="index-asinh"></a>Mapping Function: <em></em> <strong>asinh</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Compute the inverse hyperbolic sine for each element of <var>x</var>.
</p>
<p><strong>See also:</strong> <a href="#XREFsinh">sinh</a>.
</p></dd></dl>

<a name="XREFacosh"></a><dl>
<dt><a name="index-acosh"></a>Mapping Function: <em></em> <strong>acosh</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Compute the inverse hyperbolic cosine for each element of <var>x</var>.
</p>
<p><strong>See also:</strong> <a href="#XREFcosh">cosh</a>.
</p></dd></dl>

<a name="XREFatanh"></a><dl>
<dt><a name="index-atanh"></a>Mapping Function: <em></em> <strong>atanh</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Compute the inverse hyperbolic tangent for each element of <var>x</var>.
</p>
<p><strong>See also:</strong> <a href="#XREFtanh">tanh</a>.
</p></dd></dl>

<a name="XREFasech"></a><dl>
<dt><a name="index-asech"></a>Mapping Function: <em></em> <strong>asech</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Compute the inverse hyperbolic secant of each element of <var>x</var>.
</p>
<p><strong>See also:</strong> <a href="#XREFsech">sech</a>.
</p></dd></dl>

<a name="XREFacsch"></a><dl>
<dt><a name="index-acsch"></a>Mapping Function: <em></em> <strong>acsch</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Compute the inverse hyperbolic cosecant of each element of <var>x</var>.
</p>
<p><strong>See also:</strong> <a href="#XREFcsch">csch</a>.
</p></dd></dl>

<a name="XREFacoth"></a><dl>
<dt><a name="index-acoth"></a>Mapping Function: <em></em> <strong>acoth</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Compute the inverse hyperbolic cotangent of each element of <var>x</var>.
</p>
<p><strong>See also:</strong> <a href="#XREFcoth">coth</a>.
</p></dd></dl>


<a name="XREFatan2"></a><dl>
<dt><a name="index-atan2"></a>Mapping Function: <em></em> <strong>atan2</strong> <em>(<var>y</var>, <var>x</var>)</em></dt>
<dd><p>Compute atan (<var>y</var> / <var>x</var>) for corresponding elements of <var>y</var>
and <var>x</var>.  Signal an error if <var>y</var> and <var>x</var> do not match in size
and orientation.
</p>
<p><strong>See also:</strong> <a href="#XREFtan">tan</a>, <a href="#XREFtand">tand</a>, <a href="#XREFtanh">tanh</a>, <a href="#XREFatanh">atanh</a>.
</p></dd></dl>


<p>Octave provides the following trigonometric functions where angles are
specified in degrees.  These functions produce true zeros at the appropriate
intervals rather than the small round-off error that occurs when using
radians.  For example:
</p>
<div class="example">
<pre class="example">cosd (90)
     &rArr; 0
cos (pi/2)
     &rArr; 6.1230e-17
</pre></div>

<a name="XREFsind"></a><dl>
<dt><a name="index-sind"></a>Function File: <em></em> <strong>sind</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Compute the sine for each element of <var>x</var> in degrees.  Returns zero
for elements where <code><var>x</var>/180</code> is an integer.
</p>
<p><strong>See also:</strong> <a href="#XREFasind">asind</a>, <a href="#XREFsin">sin</a>.
</p></dd></dl>

<a name="XREFcosd"></a><dl>
<dt><a name="index-cosd"></a>Function File: <em></em> <strong>cosd</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Compute the cosine for each element of <var>x</var> in degrees.  Returns zero
for elements where <code>(<var>x</var>-90)/180</code> is an integer.
</p>
<p><strong>See also:</strong> <a href="#XREFacosd">acosd</a>, <a href="#XREFcos">cos</a>.
</p></dd></dl>

<a name="XREFtand"></a><dl>
<dt><a name="index-tand"></a>Function File: <em></em> <strong>tand</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Compute the tangent for each element of <var>x</var> in degrees.  Returns zero
for elements where <code><var>x</var>/180</code> is an integer and <code>Inf</code> for
elements where <code>(<var>x</var>-90)/180</code> is an integer.
</p>
<p><strong>See also:</strong> <a href="#XREFatand">atand</a>, <a href="#XREFtan">tan</a>.
</p></dd></dl>

<a name="XREFsecd"></a><dl>
<dt><a name="index-secd"></a>Function File: <em></em> <strong>secd</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Compute the secant for each element of <var>x</var> in degrees.
</p>
<p><strong>See also:</strong> <a href="#XREFasecd">asecd</a>, <a href="#XREFsec">sec</a>.
</p></dd></dl>

<a name="XREFcscd"></a><dl>
<dt><a name="index-cscd"></a>Function File: <em></em> <strong>cscd</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Compute the cosecant for each element of <var>x</var> in degrees.
</p>
<p><strong>See also:</strong> <a href="#XREFacscd">acscd</a>, <a href="#XREFcsc">csc</a>.
</p></dd></dl>

<a name="XREFcotd"></a><dl>
<dt><a name="index-cotd"></a>Function File: <em></em> <strong>cotd</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Compute the cotangent for each element of <var>x</var> in degrees.
</p>
<p><strong>See also:</strong> <a href="#XREFacotd">acotd</a>, <a href="#XREFcot">cot</a>.
</p></dd></dl>


<a name="XREFasind"></a><dl>
<dt><a name="index-asind"></a>Function File: <em></em> <strong>asind</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Compute the inverse sine in degrees for each element of <var>x</var>.
</p>
<p><strong>See also:</strong> <a href="#XREFsind">sind</a>, <a href="#XREFasin">asin</a>.
</p></dd></dl>

<a name="XREFacosd"></a><dl>
<dt><a name="index-acosd"></a>Function File: <em></em> <strong>acosd</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Compute the inverse cosine in degrees for each element of <var>x</var>.
</p>
<p><strong>See also:</strong> <a href="#XREFcosd">cosd</a>, <a href="#XREFacos">acos</a>.
</p></dd></dl>

<a name="XREFatand"></a><dl>
<dt><a name="index-atand"></a>Function File: <em></em> <strong>atand</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Compute the inverse tangent in degrees for each element of <var>x</var>.
</p>
<p><strong>See also:</strong> <a href="#XREFtand">tand</a>, <a href="#XREFatan">atan</a>.
</p></dd></dl>

<a name="XREFatan2d"></a><dl>
<dt><a name="index-atan2d"></a>Function File: <em></em> <strong>atan2d</strong> <em>(<var>y</var>, <var>x</var>)</em></dt>
<dd><p>Compute atan2 (<var>y</var> / <var>x</var>) in degrees for corresponding elements
from <var>y</var> and <var>x</var>.
</p>
<p><strong>See also:</strong> <a href="#XREFtand">tand</a>, <a href="#XREFatan2">atan2</a>.
</p></dd></dl>

<a name="XREFasecd"></a><dl>
<dt><a name="index-asecd"></a>Function File: <em></em> <strong>asecd</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Compute the inverse secant in degrees for each element of <var>x</var>.
</p>
<p><strong>See also:</strong> <a href="#XREFsecd">secd</a>, <a href="#XREFasec">asec</a>.
</p></dd></dl>

<a name="XREFacscd"></a><dl>
<dt><a name="index-acscd"></a>Function File: <em></em> <strong>acscd</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Compute the inverse cosecant in degrees for each element of <var>x</var>.
</p>
<p><strong>See also:</strong> <a href="#XREFcscd">cscd</a>, <a href="#XREFacsc">acsc</a>.
</p></dd></dl>

<a name="XREFacotd"></a><dl>
<dt><a name="index-acotd"></a>Function File: <em></em> <strong>acotd</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Compute the inverse cotangent in degrees for each element of <var>x</var>.
</p>
<p><strong>See also:</strong> <a href="#XREFcotd">cotd</a>, <a href="#XREFacot">acot</a>.
</p></dd></dl>


<hr>
<div class="header">
<p>
Next: <a href="Sums-and-Products.html#Sums-and-Products" accesskey="n" rel="next">Sums and Products</a>, Previous: <a href="Complex-Arithmetic.html#Complex-Arithmetic" accesskey="p" rel="prev">Complex Arithmetic</a>, Up: <a href="Arithmetic.html#Arithmetic" accesskey="u" rel="up">Arithmetic</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>