octave: Trigonometry

 
 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’ or use the ‘deg2rad’ function.  For example, ‘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.  As an 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.
 
  -- : RAD = deg2rad (DEG)
 
      Convert degrees to radians.
 
      The input DEG must be a scalar, vector, or N-dimensional array of
      double or single floating point values.  DEG may be complex in
      which case the real and imaginary components are converted
      separately.
 
      The output RAD is the same size and shape as DEG with degrees
      converted to radians using the conversion constant ‘pi/180’.
 
      Example:
 
           deg2rad ([0, 90, 180, 270, 360])
             ⇒  0.00000   1.57080   3.14159   4.71239   6.28319
 
      See also: Seerad2deg XREFrad2deg.
 
  -- : DEG = rad2deg (RAD)
 
      Convert radians to degrees.
 
      The input RAD must be a scalar, vector, or N-dimensional array of
      double or single floating point values.  RAD may be complex in
      which case the real and imaginary components are converted
      separately.
 
      The output DEG is the same size and shape as RAD with radians
      converted to degrees using the conversion constant ‘180/pi’.
 
      Example:
 
           rad2deg ([0, pi/2, pi, 3/2*pi, 2*pi])
             ⇒  0    90   180   270   360
 
      See also: Seedeg2rad XREFdeg2rad.
 
  -- : sin (X)
      Compute the sine for each element of X in radians.
 
DONTPRINTYET       See also: Seeasin XREFasin, Seesind XREFsind, *notesinh:
DONTPRINTYET       See also: Seeasin XREFasin, Seesind XREFsind, Seesinh

      XREFsinh.
 
  -- : cos (X)
      Compute the cosine for each element of X in radians.
 
DONTPRINTYET       See also: Seeacos XREFacos, Seecosd XREFcosd, *notecosh:
DONTPRINTYET       See also: Seeacos XREFacos, Seecosd XREFcosd, Seecosh

      XREFcosh.
 
  -- : tan (Z)
      Compute the tangent for each element of X in radians.
 
DONTPRINTYET       See also: Seeatan XREFatan, Seetand XREFtand, *notetanh:
DONTPRINTYET       See also: Seeatan XREFatan, Seetand XREFtand, Seetanh

      XREFtanh.
 
  -- : sec (X)
      Compute the secant for each element of X in radians.
 
DONTPRINTYET       See also: Seeasec XREFasec, Seesecd XREFsecd, *notesech:
DONTPRINTYET       See also: Seeasec XREFasec, Seesecd XREFsecd, Seesech

      XREFsech.
 
  -- : csc (X)
      Compute the cosecant for each element of X in radians.
 
DONTPRINTYET       See also: Seeacsc XREFacsc, Seecscd XREFcscd, *notecsch:
DONTPRINTYET       See also: Seeacsc XREFacsc, Seecscd XREFcscd, Seecsch

      XREFcsch.
 
  -- : cot (X)
      Compute the cotangent for each element of X in radians.
 
DONTPRINTYET       See also: Seeacot XREFacot, Seecotd XREFcotd, *notecoth:
DONTPRINTYET       See also: Seeacot XREFacot, Seecotd XREFcotd, Seecoth

      XREFcoth.
 
  -- : asin (X)
      Compute the inverse sine in radians for each element of X.
 
      See also: Seesin XREFsin, Seeasind XREFasind.
 
  -- : acos (X)
      Compute the inverse cosine in radians for each element of X.
 
      See also: Seecos XREFcos, Seeacosd XREFacosd.
 
  -- : atan (X)
      Compute the inverse tangent in radians for each element of X.
 
      See also: Seetan XREFtan, Seeatand XREFatand.
 
  -- : asec (X)
      Compute the inverse secant in radians for each element of X.
 
      See also: Seesec XREFsec, Seeasecd XREFasecd.
 
  -- : acsc (X)
      Compute the inverse cosecant in radians for each element of X.
 
      See also: Seecsc XREFcsc, Seeacscd XREFacscd.
 
  -- : acot (X)
      Compute the inverse cotangent in radians for each element of X.
 
      See also: Seecot XREFcot, Seeacotd XREFacotd.
 
  -- : sinh (X)
      Compute the hyperbolic sine for each element of X.
 
DONTPRINTYET       See also: Seeasinh XREFasinh, Seecosh XREFcosh, *notetanh:
DONTPRINTYET       See also: Seeasinh XREFasinh, Seecosh XREFcosh, Seetanh

      XREFtanh.
 
  -- : cosh (X)
      Compute the hyperbolic cosine for each element of X.
 
DONTPRINTYET       See also: Seeacosh XREFacosh, Seesinh XREFsinh, *notetanh:
DONTPRINTYET       See also: Seeacosh XREFacosh, Seesinh XREFsinh, Seetanh

      XREFtanh.
 
  -- : tanh (X)
      Compute hyperbolic tangent for each element of X.
 
DONTPRINTYET       See also: Seeatanh XREFatanh, Seesinh XREFsinh, *notecosh:
DONTPRINTYET       See also: Seeatanh XREFatanh, Seesinh XREFsinh, Seecosh

      XREFcosh.
 
  -- : sech (X)
      Compute the hyperbolic secant of each element of X.
 
      See also: Seeasech XREFasech.
 
  -- : csch (X)
      Compute the hyperbolic cosecant of each element of X.
 
      See also: Seeacsch XREFacsch.
 
  -- : coth (X)
      Compute the hyperbolic cotangent of each element of X.
 
      See also: Seeacoth XREFacoth.
 
  -- : asinh (X)
      Compute the inverse hyperbolic sine for each element of X.
 
      See also: Seesinh XREFsinh.
 
  -- : acosh (X)
      Compute the inverse hyperbolic cosine for each element of X.
 
      See also: Seecosh XREFcosh.
 
  -- : atanh (X)
      Compute the inverse hyperbolic tangent for each element of X.
 
      See also: Seetanh XREFtanh.
 
  -- : asech (X)
      Compute the inverse hyperbolic secant of each element of X.
 
      See also: Seesech XREFsech.
 
  -- : acsch (X)
      Compute the inverse hyperbolic cosecant of each element of X.
 
      See also: Seecsch XREFcsch.
 
  -- : acoth (X)
      Compute the inverse hyperbolic cotangent of each element of X.
 
      See also: Seecoth XREFcoth.
 
  -- : atan2 (Y, X)
      Compute atan (Y / X) for corresponding elements of Y and X.
 
      Y and X must match in size and orientation.  The signs of elements
      of Y and X are used to determine the quadrants of each resulting
      value.
 
      This function is equivalent to ‘arg (complex (X, Y))’.
 
DONTPRINTYET       See also: Seetan XREFtan, Seetand XREFtand, *notetanh:
DONTPRINTYET       See also: Seetan XREFtan, Seetand XREFtand, Seetanh

      XREFtanh, Seeatanh XREFatanh.
 
    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
 
  -- : sind (X)
      Compute the sine for each element of X in degrees.
 
      Returns zero for elements where ‘X/180’ is an integer.
 
      See also: Seeasind XREFasind, Seesin XREFsin.
 
  -- : 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: Seeacosd XREFacosd, Seecos XREFcos.
 
  -- : 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: Seeatand XREFatand, Seetan XREFtan.
 
  -- : secd (X)
      Compute the secant for each element of X in degrees.
 
      See also: Seeasecd XREFasecd, Seesec XREFsec.
 
  -- : cscd (X)
      Compute the cosecant for each element of X in degrees.
 
      See also: Seeacscd XREFacscd, Seecsc XREFcsc.
 
  -- : cotd (X)
      Compute the cotangent for each element of X in degrees.
 
      See also: Seeacotd XREFacotd, Seecot XREFcot.
 
  -- : asind (X)
      Compute the inverse sine in degrees for each element of X.
 
      See also: Seesind XREFsind, Seeasin XREFasin.
 
  -- : acosd (X)
      Compute the inverse cosine in degrees for each element of X.
 
      See also: Seecosd XREFcosd, Seeacos XREFacos.
 
  -- : atand (X)
      Compute the inverse tangent in degrees for each element of X.
 
      See also: Seetand XREFtand, Seeatan XREFatan.
 
  -- : atan2d (Y, X)
      Compute atan (Y / X) in degrees for corresponding elements from Y
      and X.
 
      See also: Seetand XREFtand, Seeatan2 XREFatan2.
 
  -- : asecd (X)
      Compute the inverse secant in degrees for each element of X.
 
      See also: Seesecd XREFsecd, Seeasec XREFasec.
 
  -- : acscd (X)
      Compute the inverse cosecant in degrees for each element of X.
 
      See also: Seecscd XREFcscd, Seeacsc XREFacsc.
 
  -- : acotd (X)
      Compute the inverse cotangent in degrees for each element of X.
 
      See also: Seecotd XREFcotd, Seeacot XREFacot.