Square root function

MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.




sqrt(z) represents the square root of z.

represents the solution of x2 = z that has a nonnegative real part. In particular, it represents the positive root for real positive z. For real negative z, it represents the complex root with positive imaginary part.

A floating-point result is returned for floating-point arguments. Note that the branch cut is chosen as the negative real semi-axis. The values returned by sqrt jump when crossing this cut. Cf. Example 2.

Certain simplifications of the argument may occur. In particular, positive integer factors are extracted from some symbolic products. Cf. Example 3.

Note that cannot be simplified to x for all complex numbers (e.g., for real x < 0). Cf. Example 4.

Mathematically, sqrt(z) coincides with z^(1/2) = _power(z,1/2). However, sqrt provides more simplifications than _power. Cf. Example 5.

Environment Interactions

When called with a floating-point argument, the function is sensitive to the environment variable DIGITS which determines the numerical working precision.


Example 1

We demonstrate some calls with exact and symbolic input data:

sqrt(2), sqrt(4), sqrt(36*7), sqrt(127)

sqrt(1/4), sqrt(1/2), sqrt(3/4), sqrt(25/36/7), sqrt(4/127)

sqrt(-4), sqrt(-1/2), sqrt(1 + I)

sqrt(x), sqrt(4*x^(4/7)), sqrt(4*x/3), sqrt(4*(x + I))

Example 2

Floating point values are computed for floating-point arguments:

sqrt(1234.5), sqrt(-1234.5), sqrt(-2.0 + 3.0*I)

A jump occurs when crossing the negative real semi axis:

sqrt(-4.0), sqrt(-4.0 + I/10^100), sqrt(-4.0 - I/10^100)

Example 3

The square root of symbolic products involving positive integer factors is simplified:


Example 4

Square roots of squares are not simplified, unless the argument is real and its sign is known:


assume(x > 0): sqrt(x^2*y^4)

assume(x < 0): sqrt(x^2*y^4)

Example 5

sqrt provides more simplifications than the _power function:

sqrt(4*x), (4*x)^(1/2) = _power(4*x, 1/2)



An arithmetical expression

Return Values

Arithmetical expression.

Overloaded By


See Also

MuPAD Functions