# sqrt

sqrt(x)

Return $\sqrt{x}$. Throws DomainError for negative Real arguments. Use complex negative arguments instead. The prefix operator âˆš is equivalent to sqrt.

## Examples

1. Compute the square root of a positive number:

julia> sqrt(25)
5.0

This example calculates the square root of the number 25, which is 5.

2. Handle complex numbers:

julia> sqrt(-4 + 3im)
0.0 + 2.0im

The sqrt function can handle complex numbers as well. In this example, it computes the square root of -4 + 3im, which is 0.0 + 2.0im.

3. Use the prefix operator √:
julia> √9
3.0

The prefix operator √ is equivalent to calling the sqrt function. It can be used to compute the square root of a number. In this example, √9 returns 3.0.

Common mistake example:

julia> sqrt(-9)
ERROR: DomainError with -9.0:
sqrt will only return a complex result if called with a complex argument. Try sqrt(Complex(x)).

In this example, a DomainError is thrown because the input -9 is a negative real number. To compute the square root of negative real numbers, use complex numbers instead by passing a complex argument, like sqrt(Complex(-9)).