xref: /dflybsd-src/contrib/openbsd_libm/man/hypot.3 (revision 4382f29d99a100bd77a81697c2f699c11f6a472a)
1*05a0b428SJohn Marino.\"	$OpenBSD: hypot.3,v 1.21 2015/01/15 19:06:31 schwarze Exp $
2*05a0b428SJohn Marino.\" Copyright (c) 1985, 1991 Regents of the University of California.
3*05a0b428SJohn Marino.\" All rights reserved.
4*05a0b428SJohn Marino.\"
5*05a0b428SJohn Marino.\" Redistribution and use in source and binary forms, with or without
6*05a0b428SJohn Marino.\" modification, are permitted provided that the following conditions
7*05a0b428SJohn Marino.\" are met:
8*05a0b428SJohn Marino.\" 1. Redistributions of source code must retain the above copyright
9*05a0b428SJohn Marino.\"    notice, this list of conditions and the following disclaimer.
10*05a0b428SJohn Marino.\" 2. Redistributions in binary form must reproduce the above copyright
11*05a0b428SJohn Marino.\"    notice, this list of conditions and the following disclaimer in the
12*05a0b428SJohn Marino.\"    documentation and/or other materials provided with the distribution.
13*05a0b428SJohn Marino.\" 3. Neither the name of the University nor the names of its contributors
14*05a0b428SJohn Marino.\"    may be used to endorse or promote products derived from this software
15*05a0b428SJohn Marino.\"    without specific prior written permission.
16*05a0b428SJohn Marino.\"
17*05a0b428SJohn Marino.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18*05a0b428SJohn Marino.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19*05a0b428SJohn Marino.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20*05a0b428SJohn Marino.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21*05a0b428SJohn Marino.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22*05a0b428SJohn Marino.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23*05a0b428SJohn Marino.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24*05a0b428SJohn Marino.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25*05a0b428SJohn Marino.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26*05a0b428SJohn Marino.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27*05a0b428SJohn Marino.\" SUCH DAMAGE.
28*05a0b428SJohn Marino.\"
29*05a0b428SJohn Marino.\"     from: @(#)hypot.3	6.7 (Berkeley) 5/6/91
30*05a0b428SJohn Marino.\"
31*05a0b428SJohn Marino.Dd $Mdocdate: January 15 2015 $
32*05a0b428SJohn Marino.Dt HYPOT 3
33*05a0b428SJohn Marino.Os
34*05a0b428SJohn Marino.Sh NAME
35*05a0b428SJohn Marino.Nm hypot ,
36*05a0b428SJohn Marino.Nm hypotf ,
37*05a0b428SJohn Marino.Nm hypotl ,
38*05a0b428SJohn Marino.Nm cabs ,
39*05a0b428SJohn Marino.Nm cabsf ,
40*05a0b428SJohn Marino.Nm cabsl
41*05a0b428SJohn Marino.Nd Euclidean distance and complex absolute value functions
42*05a0b428SJohn Marino.Sh SYNOPSIS
43*05a0b428SJohn Marino.In math.h
44*05a0b428SJohn Marino.Ft double
45*05a0b428SJohn Marino.Fn hypot "double x" "double y"
46*05a0b428SJohn Marino.Ft float
47*05a0b428SJohn Marino.Fn hypotf "float x" "float y"
48*05a0b428SJohn Marino.Ft long double
49*05a0b428SJohn Marino.Fn hypotl "long double x" "long double y"
50*05a0b428SJohn Marino.In complex.h
51*05a0b428SJohn Marino.Ft double
52*05a0b428SJohn Marino.Fn cabs "double complex z"
53*05a0b428SJohn Marino.Ft float
54*05a0b428SJohn Marino.Fn cabsf "float complex z"
55*05a0b428SJohn Marino.Ft long double
56*05a0b428SJohn Marino.Fn cabsl "long double complex z"
57*05a0b428SJohn Marino.Sh DESCRIPTION
58*05a0b428SJohn MarinoThe
59*05a0b428SJohn Marino.Fn hypot ,
60*05a0b428SJohn Marino.Fn hypotf
61*05a0b428SJohn Marinoand
62*05a0b428SJohn Marino.Fn hypotl
63*05a0b428SJohn Marinofunctions
64*05a0b428SJohn Marinocompute the
65*05a0b428SJohn Marinosqrt(x*x+y*y)
66*05a0b428SJohn Marinoin such a way that underflow will not happen, and overflow
67*05a0b428SJohn Marinooccurs only if the final result deserves it.
68*05a0b428SJohn Marino.Pp
69*05a0b428SJohn Marino.Fn hypot "\*(If" "v"
70*05a0b428SJohn Marino=
71*05a0b428SJohn Marino.Fn hypot "v" "\*(If"
72*05a0b428SJohn Marino= +\*(If for all
73*05a0b428SJohn Marino.Ar v ,
74*05a0b428SJohn Marinoincluding \*(Na.
75*05a0b428SJohn Marino.Pp
76*05a0b428SJohn MarinoThe
77*05a0b428SJohn Marino.Fn cabs ,
78*05a0b428SJohn Marino.Fn cabsf
79*05a0b428SJohn Marinoand
80*05a0b428SJohn Marino.Fn cabsl
81*05a0b428SJohn Marinofunctions return the absolute value of the complex number
82*05a0b428SJohn Marino.Fa z .
83*05a0b428SJohn Marino.Sh ERRORS (due to Roundoff, etc.)
84*05a0b428SJohn MarinoBelow 0.97
85*05a0b428SJohn Marino.Em ulps .
86*05a0b428SJohn MarinoConsequently
87*05a0b428SJohn Marino.Fn hypot "5.0" "12.0"
88*05a0b428SJohn Marino= 13.0
89*05a0b428SJohn Marinoexactly;
90*05a0b428SJohn Marinoin general, hypot and cabs return an integer whenever an
91*05a0b428SJohn Marinointeger might be expected.
92*05a0b428SJohn Marino.Sh NOTES
93*05a0b428SJohn MarinoAs might be expected,
94*05a0b428SJohn Marino.Fn hypot "v" "\*(Na"
95*05a0b428SJohn Marinoand
96*05a0b428SJohn Marino.Fn hypot "\*(Na" "v"
97*05a0b428SJohn Marinoare \*(Na for all
98*05a0b428SJohn Marino.Em finite
99*05a0b428SJohn Marino.Ar v ;
100*05a0b428SJohn Marinowith
101*05a0b428SJohn Marino.Dq reserved operand
102*05a0b428SJohn Marinoin place of "\*(Na", the same is true on a VAX.
103*05a0b428SJohn MarinoBut programmers on machines other than a VAX (it has no \*(If)
104*05a0b428SJohn Marinomight be surprised at first to discover that
105*05a0b428SJohn Marino.Fn hypot "\(+-\*(If" "\*(Na"
106*05a0b428SJohn Marino= +\*(If.
107*05a0b428SJohn MarinoThis is intentional; it happens because
108*05a0b428SJohn Marino.Fn hypot "\*(If" "v"
109*05a0b428SJohn Marino= +\*(If
110*05a0b428SJohn Marinofor
111*05a0b428SJohn Marino.Em all
112*05a0b428SJohn Marino.Ar v ,
113*05a0b428SJohn Marinofinite or infinite.
114*05a0b428SJohn MarinoHence
115*05a0b428SJohn Marino.Fn hypot "\*(If" "v"
116*05a0b428SJohn Marinois independent of
117*05a0b428SJohn Marino.Ar v .
118*05a0b428SJohn MarinoUnlike the reserved operand fault on a VAX,
119*05a0b428SJohn Marinothe IEEE \*(Na is designed to disappear
120*05a0b428SJohn Marinowhen it turns out to be irrelevant, as it does in
121*05a0b428SJohn Marino.Fn hypot "\*(If" "\*(Na" .
122*05a0b428SJohn Marino.Sh SEE ALSO
123*05a0b428SJohn Marino.Xr sqrt 3
124*05a0b428SJohn Marino.Sh HISTORY
125*05a0b428SJohn MarinoA
126*05a0b428SJohn Marino.Fn hypot
127*05a0b428SJohn Marinofunction first appeared in
128*05a0b428SJohn Marino.At v3 ,
129*05a0b428SJohn Marinoand
130*05a0b428SJohn Marino.Fn cabs
131*05a0b428SJohn Marinoin
132*05a0b428SJohn Marino.At v7 .
133