freebsd-src/lib/msun/man/csqrt.3
2008-03-30 20:07:15 +00:00

103 lines
3.1 KiB
Groff

.\" Copyright (c) 2007-2008 David Schultz <das@FreeBSD.org>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD$
.\"
.Dd March 30, 2008
.Dt CSQRT 3
.Os
.Sh NAME
.Nm csqrt ,
.Nm csqrtf ,
.Nm csqrtl
.Nd complex square root functions
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In complex.h
.Ft double complex
.Fn csqrt "double complex z"
.Ft float complex
.Fn csqrtf "float complex z"
.Ft long double complex
.Fn csqrtl "long double complex z"
.Sh DESCRIPTION
The
.Fn csqrt ,
.Fn csqrtf ,
and
.Fn csqrtl
functions compute the square root of
.Fa z
in the complex plane, with a branch cut along the negative real axis.
In other words,
.Fn csqrt ,
.Fn csqrtf ,
and
.Fn csqrtl
always return the square root whose real part is non-negative.
.Sh RETURN VALUES
These functions return the requested square root.
The square root of 0 is
.Li +0 \*(Pm 0 ,
where the imaginary parts of the input and respective result have
the same sign.
For infinities and \*(Nas, the following rules apply, with the
earlier rules having precedence:
.Bl -column -offset indent "-\*(If + \*(Na*I" "\*(If \*(Pm \*(If*I " "(for all k)"
.Em Input Result
k + \*(If*I \*(If + \*(If*I (for all k)
-\*(If + \*(Na*I \*(Na \*(Pm \*(If*I
\*(If + \*(Na*I \*(If + \*(Na*I
k + \*(Na*I \*(Na + \*(Na*I
\*(Na + k*I \*(Na + \*(Na*I
-\*(If + k*I +0 + \*(If*I
\*(If + k*I \*(If + 0*I
.El
.Pp
For numbers with negative imaginary parts, the above special cases
apply given the identity:
.Dl csqrt(conj(z) = conj(sqrt(z))
Note that the sign of \*(Na is indeterminate.
Also, if the real or imaginary part of the input is finite and
an \*(Na is generated, an invalid exception will be thrown.
.Sh SEE ALSO
.Xr cabs 3 ,
.Xr fenv 3 ,
.Xr math 3 ,
.Sh STANDARDS
The
.Fn csqrt ,
.Fn csqrtf ,
and
.Fn csqrtl
functions conform to
.St -isoC-99 .
.Sh BUGS
For
.Fn csqrt
and
.Fn csqrtl ,
inexact results are not always correctly rounded.