HYPOT(3) - [MATHEMATICS] Returns the Euclidean distance - the distance between a point and the origin.
result = hypot(x, y)
elemental real(kind=KIND) function hypot(x,y)real(kind=KIND),intent(in) :: x real(kind=KIND),intent(in) :: y
o X,Y and the result shall all be real and of the same KIND.
HYPOT(3) is referred to as the Euclidean distance function. It is equal to
sqrt(x**2+y**2)without undue underflow or overflow.
In mathematics, the Euclidean distance between two points in Euclidean space is the length of a line segment between two points.
HYPOT(X,Y) returns the distance between the point <X,Y> and the origin.
o X : The type shall be real. o Y : The type and kind type parameter shall be the same as X.
The return value has the same type and kind type parameter as X.
The result is the positive magnitude of the distance of the point <X,Y> from the origin <0.0,0.0> .
Sample program:
program demo_hypot use, intrinsic :: iso_fortran_env, only : real32, real64, real128 implicit none real(kind=real32) :: x, y real(kind=real32),allocatable :: xs(:), ys(:) integer :: i character(len=*),parameter :: f=(a,/,SP,*(3x,g0,1x,g0:,/))Results:x = 1.e0_real32 y = 0.5e0_real32
write(*,*) write(*,(*(g0)))point <,x,,,y,> is ,hypot(x,y) write(*,(*(g0)))units away from the origin write(*,*)
! elemental xs=[ x, x**2, x*10.0, x*15.0, -x**2 ] ys=[ y, y**2, -y*20.0, y**2, -y**2 ]
write(*,f)"the points",(xs(i),ys(i),i=1,size(xs)) write(*,f)"have distances from the origin of ",hypot(xs,ys) write(*,f)"the closest is",minval(hypot(xs,ys))
end program demo_hypot
> > point <1.00000000,0.500000000> is 1.11803401 > units away from the origin > > the points > +1.00000000 +0.500000000 > +1.00000000 +0.250000000 > +10.0000000 -10.0000000 > +15.0000000 +0.250000000 > -1.00000000 -0.250000000 > have distances from the origin of > +1.11803401 +1.03077638 > +14.1421356 +15.0020828 > +1.03077638 > the closest is > +1.03077638
Fortran 2008
Fortran intrinsic descriptions (license: MIT) @urbanjost
o acos(3) - Arccosine (inverse cosine) function o acosh(3) - Inverse hyperbolic cosine function o asin(3) - Arcsine function o asinh(3) - Inverse hyperbolic sine function o atan(3) - Arctangent AKA inverse tangent function o atan2(3) - Arctangent (inverse tangent) function o atanh(3) - Inverse hyperbolic tangent function o cos(3) - Cosine function o cosh(3) - Hyperbolic cosine function o sin(3) - Sine function o sinh(3) - Hyperbolic sine function o tan(3) - Tangent function o tanh(3) - Hyperbolic tangent function o bessel_j0(3) - Bessel function of the first kind of order 0 o bessel_j1(3) - Bessel function of the first kind of order 1 o bessel_jn(3) - Bessel function of the first kind o bessel_y0(3) - Bessel function of the second kind of order 0 o bessel_y1(3) - Bessel function of the second kind of order 1 o bessel_yn(3) - Bessel function of the second kind o erf(3) - Error function o erfc(3) - Complementary error function o erfc_scaled(3) - Scaled complementary error function o exp(3) - Base-e exponential function o gamma(3) - Gamma function, which yields factorials for positive whole numbers o hypot(3) - Returns the Euclidean distance - the distance between a point and the origin. o log(3) - Natural logarithm o log10(3) - Base 10 or common logarithm o log_gamma(3) - Logarithm of the absolute value of the Gamma function o norm2(3) - Euclidean vector norm o sqrt(3) - Square-root function o random_init(3) - Initializes the state of the pseudorandom number generator o random_number(3) - Pseudo-random number o random_seed(3) - Initialize a pseudo-random number sequence
Nemo Release 3.1 | hypot (3fortran) | November 02, 2024 |