@c Copyright (C) 1996, 1997, 1999, 2000, 2001, 2002, 2007 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 or matrix arguments.

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

@node Utility Functions
@section Utility Functions

The following functions are available for working with complex numbers.
Each expects a single argument.  They are called @dfn{mapping functions}
because when given a matrix argument, they apply the given function to
each element of the matrix.

@DOCSTRING(ceil)

@DOCSTRING(cplxpair)

@DOCSTRING(del2)

@DOCSTRING(exp)

@DOCSTRING(factor)

@DOCSTRING(factorial)

@DOCSTRING(fix)

@DOCSTRING(floor)

@DOCSTRING(fmod)

@DOCSTRING(gcd)

@DOCSTRING(gradient)

@DOCSTRING(lcm)

@DOCSTRING(log)

@DOCSTRING(log10)

@DOCSTRING(log2)

@DOCSTRING(max)

@DOCSTRING(min)

@DOCSTRING(mod)

@DOCSTRING(nextpow2)

@DOCSTRING(nthroot)

@DOCSTRING(pow2)

@DOCSTRING(primes)

@DOCSTRING(rem)

@DOCSTRING(round)

@DOCSTRING(sign)

@DOCSTRING(sqrt)

@node Complex Arithmetic
@section Complex Arithmetic

The following functions are available for working with complex
numbers.  Each expects a single argument.  Given a matrix they work on
an element by element basis.  In the descriptions of the following
functions,
@iftex
@tex
$z$ is the complex number $x + iy$, where $i$ is defined as
$\sqrt{-1}$.
@end tex
@end iftex
@ifinfo
@var{z} is the complex number @var{x} + @var{i}@var{y}, where @var{i} is
defined as @code{sqrt (-1)}.
@end ifinfo

@DOCSTRING(abs)

@DOCSTRING(arg)

@DOCSTRING(conj)

@DOCSTRING(imag)

@DOCSTRING(real)

@node Trigonometry
@section Trigonometry

Octave provides the following trigonometric functions.  Angles are
specified in radians.  To convert from degrees to radians multiply by
@iftex
@tex
$\pi/180$
@end tex
@end iftex
@ifinfo
@code{pi/180}
@end ifinfo
 (e.g. @code{sin (30 * pi/180)} returns the sine of 30 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)

Each of these functions expects a single argument.  For matrix arguments,
they work on an element by element basis.  For example,

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

@DOCSTRING(atan2)

In addition to the trigonometric functions that work with radians,
Octave also provides the following functions which work with degrees.

@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)

@node Special Functions
@section Special Functions

@DOCSTRING(besselj)

@DOCSTRING(airy)

@DOCSTRING(beta)

@DOCSTRING(betainc)

@DOCSTRING(betaln)

@DOCSTRING(bincoeff)

@DOCSTRING(erf)

@DOCSTRING(erfc)

@DOCSTRING(erfinv)

@DOCSTRING(gamma)

@DOCSTRING(gammainc)

@DOCSTRING(legendre)

@DOCSTRING(lgamma)

@DOCSTRING(cross)

@DOCSTRING(commutation_matrix)

@DOCSTRING(duplication_matrix)

@node Coordinate Transformations
@section Coordinate Transformations

@DOCSTRING(cart2pol)

@DOCSTRING(pol2cart)

@DOCSTRING(cart2sph)

@DOCSTRING(sph2cart)

@node Mathematical Constants
@section Mathematical Constants

@DOCSTRING(I)

@DOCSTRING(Inf)

@DOCSTRING(NaN)

@DOCSTRING(pi)

@DOCSTRING(e)

@DOCSTRING(eps)

@DOCSTRING(realmax)

@DOCSTRING(realmin)
