aboutsummaryrefslogblamecommitdiff
path: root/ja_JP.eucJP/man/man3/hypot.3
blob: c274fc8f56ec27326765effcc34b6b89cd2f1b47 (plain) (tree)































                                                                              
                                                          
   
             



































































































                                                                          
.\" Copyright (c) 1985, 1991 Regents of the University of California.
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\"    must display the following acknowledgement:
.\"	This product includes software developed by the University of
.\"	California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\"    may be used to endorse or promote products derived from this software
.\"    without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
.\"
.\"     from: @(#)hypot.3	6.7 (Berkeley) 5/6/91
.\"	%Id: hypot.3,v 1.4 1997/02/22 15:09:34 peter Exp %
.\"
.\" $FreeBSD$
.Dd May 6, 1991
.Dt HYPOT 3
.Os BSD 4
.Sh 名称
.Nm hypot ,
.Nm hypotf ,
.Nm cabs ,
.Nm cabsf
.Nd ユークリッド距離と複素絶対値関数
.Sh 書式
.Fd #include <math.h>
.Ft double
.Fn hypot "double x" "double y"
.Ft float
.Fn hypotf "float x" "float y"
.Fd struct {double x, y;} z;
.Ft double
.Fn cabs z
.Fd struct {float x, y;} z;
.Ft float
.Fn cabsf z
.Sh 解説
.Fn hypot ,
.Fn hypotf ,
.Fn cabs ,
および
.Fn cabsf
関数は、アンダーフローが
起きず、最終結果でオーバーフローが起こる場合のみオーバーフローする方法で
sqrt(x*x+y*y)
を計算します。
.Pp
.Fn hypot "\*(If" "v"
あるいは
.Fn hypot "v" "\*(If"
は、全ての
.Ar v
に対して、\*(Na を含む +\*(If になります。
.Sh 誤差 ( Roundoff 等に基づく )
0.97 
.Em ulps
以下。
その結果、
完全な
.Fn hypot "5.0" "12.0"
= 13.0
となる。通常、hypot と cabs は整数値が求められる時には必ず整数を返します。
.Pp
cabs.c の注釈にある短縮、かつ高速版の hypot と cabs については例外となり、
誤差は 1.2 
.Em ulps
を超すことがあります。
.Sh 注
想定通り、
.Fn hypot "v" "\*(Na"
と
.Fn hypot "\*(Na" "v"
は
.Em 全有限数
.Ar v 
に対して
\*(Na
となります。
"reserved operand" が "\*(Na" に置き換われば、
.Tn VAX
でも同じ結果になります。
.Tn VAX
以外のマシン ( もし無限数が無ければ ) のプログラマは
.Fn hypot "\(+-\*(If" "\*(Na"
= +\*(If
に初めは驚くかもしれません。
これは意図的なものであり、無限、有限に関係なく、
.Em すべての
.Ar v
について
.Fn hypot "\*(If" "v" 
= +\*(If
であるために起こります。
したがって、
.Fn hypot "\*(If" "v"
は、
.Ar v
とは独立した値です。
.Tn VAX
での reserved operand fault とは異なり、
.Tn IEEE
\*(Na は
.Fn hypot "\*(If" "\*(Na" 
において同様に、無関係になると
消失します。
.Sh 関連項目
.Xr math 3 ,
.Xr sqrt 3
.Sh 歴史
.Fn hypot
関数と
.Fn cabs
関数はどちらも
.At v7
から登場しました。