Next: , Previous: , Up: Arithmetic   [Contents][Index]


17.3 Trigonometry

Octave provides the following trigonometric functions where angles are specified in radians. To convert from degrees to radians multiply by pi/180 (e.g., sin (30 * pi/180) 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 ‘d’ suffix. For example, sin expects an angle in radians while sind expects an angle in degrees.

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: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf. 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 atan2(+- 0, 0) returns +- pi.

It should be noted that MATLAB uses different definitions which apparently do not distinguish -0.

Mapping Function: sin (x)

Compute the sine for each element of x in radians.

See also: asin, sind, sinh.

Mapping Function: cos (x)

Compute the cosine for each element of x in radians.

See also: acos, cosd, cosh.

Mapping Function: tan (z)

Compute the tangent for each element of x in radians.

See also: atan, tand, tanh.

Mapping Function: sec (x)

Compute the secant for each element of x in radians.

See also: asec, secd, sech.

Mapping Function: csc (x)

Compute the cosecant for each element of x in radians.

See also: acsc, cscd, csch.

Mapping Function: cot (x)

Compute the cotangent for each element of x in radians.

See also: acot, cotd, coth.

Mapping Function: asin (x)

Compute the inverse sine in radians for each element of x.

See also: sin, asind.

Mapping Function: acos (x)

Compute the inverse cosine in radians for each element of x.

See also: cos, acosd.

Mapping Function: atan (x)

Compute the inverse tangent in radians for each element of x.

See also: tan, atand.

Mapping Function: asec (x)

Compute the inverse secant in radians for each element of x.

See also: sec, asecd.

Mapping Function: acsc (x)

Compute the inverse cosecant in radians for each element of x.

See also: csc, acscd.

Mapping Function: acot (x)

Compute the inverse cotangent in radians for each element of x.

See also: cot, acotd.

Mapping Function: sinh (x)

Compute the hyperbolic sine for each element of x.

See also: asinh, cosh, tanh.

Mapping Function: cosh (x)

Compute the hyperbolic cosine for each element of x.

See also: acosh, sinh, tanh.

Mapping Function: tanh (x)

Compute hyperbolic tangent for each element of x.

See also: atanh, sinh, cosh.

Mapping Function: sech (x)

Compute the hyperbolic secant of each element of x.

See also: asech.

Mapping Function: csch (x)

Compute the hyperbolic cosecant of each element of x.

See also: acsch.

Mapping Function: coth (x)

Compute the hyperbolic cotangent of each element of x.

See also: acoth.

Mapping Function: asinh (x)

Compute the inverse hyperbolic sine for each element of x.

See also: sinh.

Mapping Function: acosh (x)

Compute the inverse hyperbolic cosine for each element of x.

See also: cosh.

Mapping Function: atanh (x)

Compute the inverse hyperbolic tangent for each element of x.

See also: tanh.

Mapping Function: asech (x)

Compute the inverse hyperbolic secant of each element of x.

See also: sech.

Mapping Function: acsch (x)

Compute the inverse hyperbolic cosecant of each element of x.

See also: csch.

Mapping Function: acoth (x)

Compute the inverse hyperbolic cotangent of each element of x.

See also: coth.

Mapping Function: atan2 (y, x)

Compute atan (y / x) for corresponding elements of y and x.

y and x must match in size and orientation.

See also: tan, tand, tanh, atanh.

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:

cosd (90)
     ⇒ 0
cos (pi/2)
     ⇒ 6.1230e-17
Function File: sind (x)

Compute the sine for each element of x in degrees.

Returns zero for elements where x/180 is an integer.

See also: asind, sin.

Function File: cosd (x)

Compute the cosine for each element of x in degrees.

Returns zero for elements where (x-90)/180 is an integer.

See also: acosd, cos.

Function File: tand (x)

Compute the tangent for each element of x in degrees.

Returns zero for elements where x/180 is an integer and Inf for elements where (x-90)/180 is an integer.

See also: atand, tan.

Function File: secd (x)

Compute the secant for each element of x in degrees.

See also: asecd, sec.

Function File: cscd (x)

Compute the cosecant for each element of x in degrees.

See also: acscd, csc.

Function File: cotd (x)

Compute the cotangent for each element of x in degrees.

See also: acotd, cot.

Function File: asind (x)

Compute the inverse sine in degrees for each element of x.

See also: sind, asin.

Function File: acosd (x)

Compute the inverse cosine in degrees for each element of x.

See also: cosd, acos.

Function File: atand (x)

Compute the inverse tangent in degrees for each element of x.

See also: tand, atan.

Function File: atan2d (y, x)

Compute atan2 (y / x) in degrees for corresponding elements from y and x.

See also: tand, atan2.

Function File: asecd (x)

Compute the inverse secant in degrees for each element of x.

See also: secd, asec.

Function File: acscd (x)

Compute the inverse cosecant in degrees for each element of x.

See also: cscd, acsc.

Function File: acotd (x)

Compute the inverse cotangent in degrees for each element of x.

See also: cotd, acot.


Next: , Previous: , Up: Arithmetic   [Contents][Index]