LF Fortran 95

SQRT Function


The SQRT function returns the square root of a REAL or COMPLEX argument.


SQRT (x)


x is an INTENT(IN) scalar or array of type REAL or COMPLEX.

If x is REAL, its value must be greater than or equal to zero.


The result is the same kind and type as x.

If x is REAL, the result value is a REAL representation of the square root of x.

If x is COMPLEX, the result value is the principal value with the real part greater than or equal to zero. When the real part of the result is zero, the imaginary part is greater than or equal to zero.


real :: x.=4.,x2(2)=(/2.,6./) complex :: q=(-1.,0.) write(*,*) sqrt(x1) ! writes 2.0 write(*,*) sqrt(x2) ! writes 1.4142135 2.4494898 write(*,*) sqrt(q) ! writes (0., 1.)