Deleted Added
full compact
hypot.3 (165906) hypot.3 (174561)
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
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: head/lib/msun/man/hypot.3 165906 2007-01-09 01:02:06Z imp $
29.\" $FreeBSD: head/lib/msun/man/hypot.3 174561 2007-12-12 23:43:51Z das $
30.\"
30.\"
31.Dd January 14, 2005
31.Dd December 12, 2007
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
54The
55.Fn hypot
56and
57.Fn hypotf
58functions
59compute the
60sqrt(x*x+y*y)
61in such a way that underflow will not happen, and overflow
62occurs only if the final result deserves it.
63The
64.Fn cabs
65and
66.Fn cabsf
67functions 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 ,
75including \*(Na.
76.Sh ERROR (due to Roundoff, etc.)
77Below 0.97
78.Em ulps .
79Consequently
80.Fn hypot "5.0" "12.0"
81= 13.0
82exactly;
83in general, hypot and cabs return an integer whenever an
84integer might be expected.
85.Pp
86The same cannot be said for the shorter and faster version of hypot
87and cabs that is provided in the comments in cabs.c; its error can
88exceed 1.2
89.Em ulps .
90.Sh NOTES
91As might be expected,
92.Fn hypot "v" "\*(Na"
93and
94.Fn hypot "\*(Na" "v"
95are \*(Na for all
96.Em finite
97.Fa v .
98But programmers
99might be surprised at first to discover that
100.Fn hypot "\(+-\*(If" "\*(Na"
101= +\*(If.
102This is intentional; it happens because
103.Fn hypot "\*(If" "v"
104= +\*(If
105for
106.Em all
107.Fa v ,
108finite or infinite.
109Hence
110.Fn hypot "\*(If" "v"
111is independent of
112.Fa v .
113Unlike the reserved operand fault on a
114.Tn VAX ,
115the
116.Tn IEEE
117\*(Na is designed to
118disappear when it turns out to be irrelevant, as it does in
119.Fn hypot "\*(If" "\*(Na" .
120.Sh SEE ALSO
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
54The
55.Fn hypot
56and
57.Fn hypotf
58functions
59compute the
60sqrt(x*x+y*y)
61in such a way that underflow will not happen, and overflow
62occurs only if the final result deserves it.
63The
64.Fn cabs
65and
66.Fn cabsf
67functions 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 ,
75including \*(Na.
76.Sh ERROR (due to Roundoff, etc.)
77Below 0.97
78.Em ulps .
79Consequently
80.Fn hypot "5.0" "12.0"
81= 13.0
82exactly;
83in general, hypot and cabs return an integer whenever an
84integer might be expected.
85.Pp
86The same cannot be said for the shorter and faster version of hypot
87and cabs that is provided in the comments in cabs.c; its error can
88exceed 1.2
89.Em ulps .
90.Sh NOTES
91As might be expected,
92.Fn hypot "v" "\*(Na"
93and
94.Fn hypot "\*(Na" "v"
95are \*(Na for all
96.Em finite
97.Fa v .
98But programmers
99might be surprised at first to discover that
100.Fn hypot "\(+-\*(If" "\*(Na"
101= +\*(If.
102This is intentional; it happens because
103.Fn hypot "\*(If" "v"
104= +\*(If
105for
106.Em all
107.Fa v ,
108finite or infinite.
109Hence
110.Fn hypot "\*(If" "v"
111is independent of
112.Fa v .
113Unlike the reserved operand fault on a
114.Tn VAX ,
115the
116.Tn IEEE
117\*(Na is designed to
118disappear when it turns out to be irrelevant, as it does in
119.Fn hypot "\*(If" "\*(Na" .
120.Sh SEE ALSO
121.Xr carg 3 ,
121.Xr math 3 ,
122.Xr sqrt 3
123.Sh HISTORY
124Both a
125.Fn hypot
126function and a
127.Fn cabs
128function
129appeared in
130.At v7 .
122.Xr math 3 ,
123.Xr sqrt 3
124.Sh HISTORY
125Both a
126.Fn hypot
127function and a
128.Fn cabs
129function
130appeared in
131.At v7 .