]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - lib/msun/man/hypot.3
Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.
[FreeBSD/releng/7.2.git] / lib / msun / man / hypot.3
1 .\" Copyright (c) 1985, 1991 Regents of the University of California.
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 4. Neither the name of the University nor the names of its contributors
13 .\"    may be used to endorse or promote products derived from this software
14 .\"    without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .\"     from: @(#)hypot.3       6.7 (Berkeley) 5/6/91
29 .\" $FreeBSD$
30 .\"
31 .Dd January 14, 2005
32 .Dt HYPOT 3
33 .Os
34 .Sh NAME
35 .Nm hypot ,
36 .Nm hypotf ,
37 .Nm cabs ,
38 .Nm cabsf
39 .Nd Euclidean distance and complex absolute value functions
40 .Sh LIBRARY
41 .Lb libm
42 .Sh SYNOPSIS
43 .In math.h
44 .Ft double
45 .Fn hypot "double x" "double y"
46 .Ft float
47 .Fn hypotf "float x" "float y"
48 .In complex.h
49 .Ft double
50 .Fn cabs "double complex z"
51 .Ft float
52 .Fn cabsf "float complex z"
53 .Sh DESCRIPTION
54 The
55 .Fn hypot
56 and
57 .Fn hypotf
58 functions
59 compute the
60 sqrt(x*x+y*y)
61 in such a way that underflow will not happen, and overflow
62 occurs only if the final result deserves it.
63 The
64 .Fn cabs
65 and
66 .Fn cabsf
67 functions compute the complex absolute value of
68 .Fa z .
69 .Pp
70 .Fn hypot "\*(If" "v"
71 =
72 .Fn hypot "v" "\*(If"
73 = +\*(If for all
74 .Fa v ,
75 including \*(Na.
76 .Sh ERROR (due to Roundoff, etc.)
77 Below 0.97
78 .Em ulps .
79 Consequently
80 .Fn hypot "5.0" "12.0"
81 = 13.0
82 exactly;
83 in general, hypot and cabs return an integer whenever an
84 integer might be expected.
85 .Pp
86 The same cannot be said for the shorter and faster version of hypot
87 and cabs that is provided in the comments in cabs.c; its error can
88 exceed 1.2
89 .Em ulps .
90 .Sh NOTES
91 As might be expected,
92 .Fn hypot "v" "\*(Na"
93 and
94 .Fn hypot "\*(Na" "v"
95 are \*(Na for all
96 .Em finite
97 .Fa v .
98 But programmers
99 might be surprised at first to discover that
100 .Fn hypot "\(+-\*(If" "\*(Na"
101 = +\*(If.
102 This is intentional; it happens because
103 .Fn hypot "\*(If" "v"
104 = +\*(If
105 for
106 .Em all
107 .Fa v ,
108 finite or infinite.
109 Hence
110 .Fn hypot "\*(If" "v"
111 is independent of
112 .Fa v .
113 Unlike the reserved operand fault on a
114 .Tn VAX ,
115 the
116 .Tn IEEE
117 \*(Na is designed to
118 disappear when it turns out to be irrelevant, as it does in
119 .Fn hypot "\*(If" "\*(Na" .
120 .Sh SEE ALSO
121 .Xr math 3 ,
122 .Xr sqrt 3
123 .Sh HISTORY
124 Both a
125 .Fn hypot
126 function and a
127 .Fn cabs
128 function
129 appeared in
130 .At v7 .