@c Copyright (C) 1996-2011 John W. Eaton
@c
@c This file is part of Octave.
@c
@c Octave is free software; you can redistribute it and/or modify it
@c under the terms of the GNU General Public License as published by the
@c Free Software Foundation; either version 3 of the License, or (at
@c your option) any later version.
@c 
@c Octave is distributed in the hope that it will be useful, but WITHOUT
@c ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@c FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
@c for more details.
@c 
@c You should have received a copy of the GNU General Public License
@c along with Octave; see the file COPYING.  If not, see
@c <http://www.gnu.org/licenses/>.

@node Arithmetic
@chapter Arithmetic

Unless otherwise noted, all of the functions described in this chapter
will work for real and complex scalar, vector, or matrix arguments.  Functions
described as @dfn{mapping functions} apply the given operation individually to 
each element when given a matrix argument.  For example:

@example
@group
sin ([1, 2; 3, 4])
     @result{}  0.84147   0.90930
         0.14112  -0.75680
@end group
@end example

@menu
* Exponents and Logarithms::
* Complex Arithmetic::          
* Trigonometry::                
* Sums and Products::           
* Utility Functions::           
* Special Functions::           
* Rational Approximations::
* Coordinate Transformations::
* Mathematical Constants::      
@end menu

@node Exponents and Logarithms
@section Exponents and Logarithms

@DOCSTRING(exp)

@DOCSTRING(expm1)

@DOCSTRING(log)

@DOCSTRING(reallog)

@DOCSTRING(log1p)

@DOCSTRING(log10)

@DOCSTRING(log2)

@DOCSTRING(pow2)

@DOCSTRING(nextpow2)

@DOCSTRING(realpow)

@DOCSTRING(sqrt)

@DOCSTRING(realsqrt)

@DOCSTRING(cbrt)

@DOCSTRING(nthroot)

@node Complex Arithmetic
@section Complex Arithmetic

In the descriptions of the following functions,
@tex
$z$ is the complex number $x + iy$, where $i$ is defined as
$\sqrt{-1}$.
@end tex
@ifnottex
@var{z} is the complex number @var{x} + @var{i}@var{y}, where @var{i} is
defined as @code{sqrt (-1)}.
@end ifnottex

@DOCSTRING(abs)

@DOCSTRING(arg)

@DOCSTRING(conj)

@DOCSTRING(cplxpair)

@DOCSTRING(imag)

@DOCSTRING(real)

@node Trigonometry
@section Trigonometry

Octave provides the following trigonometric functions where angles are
specified in radians.  To convert from degrees to radians multiply by
@tex
$\pi/180$
@end tex
@ifnottex
@code{pi/180}
@end ifnottex
(e.g., @code{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 @samp{d} suffix.  For
example, @code{sin} expects an angle in radians while @code{sind} expects an
angle in degrees.

@DOCSTRING(sin)
@DOCSTRING(cos)
@DOCSTRING(tan)
@DOCSTRING(sec)
@DOCSTRING(csc)
@DOCSTRING(cot)

@DOCSTRING(asin)
@DOCSTRING(acos)
@DOCSTRING(atan)
@DOCSTRING(asec)
@DOCSTRING(acsc)
@DOCSTRING(acot)

@DOCSTRING(sinh)
@DOCSTRING(cosh)
@DOCSTRING(tanh)
@DOCSTRING(sech)
@DOCSTRING(csch)
@DOCSTRING(coth)

@DOCSTRING(asinh)
@DOCSTRING(acosh)
@DOCSTRING(atanh)
@DOCSTRING(asech)
@DOCSTRING(acsch)
@DOCSTRING(acoth)

@DOCSTRING(atan2)

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:

@example
@group
cosd (90)
     @result{} 0
cos (pi/2)
     @result{} 6.1230e-17
@end group
@end example

@DOCSTRING(sind)
@DOCSTRING(cosd)
@DOCSTRING(tand)
@DOCSTRING(secd)
@DOCSTRING(cscd)
@DOCSTRING(cotd)

@DOCSTRING(asind)
@DOCSTRING(acosd)
@DOCSTRING(atand)
@DOCSTRING(asecd)
@DOCSTRING(acscd)
@DOCSTRING(acotd)

@node Sums and Products
@section Sums and Products

@DOCSTRING(sum)

@DOCSTRING(prod)

@DOCSTRING(cumsum)

@DOCSTRING(cumprod)

@DOCSTRING(sumsq)

@DOCSTRING(accumarray)

@DOCSTRING(accumdim)

@node Utility Functions
@section Utility Functions

@DOCSTRING(ceil)

@DOCSTRING(curl)

@DOCSTRING(cross)

@DOCSTRING(del2)

@DOCSTRING(divergence)

@DOCSTRING(factor)

@DOCSTRING(factorial)

@DOCSTRING(fix)

@DOCSTRING(floor)

@DOCSTRING(fmod)

@DOCSTRING(gcd)

@DOCSTRING(gradient)

@DOCSTRING(hypot)

@DOCSTRING(lcm)

@DOCSTRING(list_primes)

@DOCSTRING(max)

@DOCSTRING(min)

@DOCSTRING(cummax)

@DOCSTRING(cummin)

@DOCSTRING(mod)

@DOCSTRING(primes)

@DOCSTRING(rem)

@DOCSTRING(round)

@DOCSTRING(roundb)

@DOCSTRING(sign)

@node Special Functions
@section Special Functions

@DOCSTRING(airy)

@DOCSTRING(besselj)

@DOCSTRING(beta)

@DOCSTRING(betainc)

@DOCSTRING(betaln)

@DOCSTRING(bincoeff)

@DOCSTRING(commutation_matrix)

@DOCSTRING(duplication_matrix)

@DOCSTRING(erf)

@DOCSTRING(erfc)

@DOCSTRING(erfcx)

@DOCSTRING(erfinv)

@DOCSTRING(gamma)

@DOCSTRING(gammainc)

@DOCSTRING(legendre)

@anchor{doc-gammaln}
@DOCSTRING(lgamma)

@node Rational Approximations
@section Rational Approximations

@DOCSTRING(rat)

@DOCSTRING(rats)

@node Coordinate Transformations
@section Coordinate Transformations

@DOCSTRING(cart2pol)

@DOCSTRING(pol2cart)

@DOCSTRING(cart2sph)

@DOCSTRING(sph2cart)

@node Mathematical Constants
@section Mathematical Constants

@DOCSTRING(e)

@DOCSTRING(pi)

@DOCSTRING(I)

@DOCSTRING(Inf)

@DOCSTRING(NaN)

@DOCSTRING(eps)

@DOCSTRING(realmax)

@DOCSTRING(realmin)
