Please enable JavaScript to view this site.

Knowledge Base

Calculates the square root of a number. Input can be complex or negative.

 

Supported Product: FDTD, MODE, DEVICE, INTERCONNECT

 

Syntax

Description

out = sqrt(x);

The square root of x. The square root is chosen so that real(sqrt(x))≥0 for any complex number x. The imaginary part, imag(sqrt(x)), can be positive or negative but if real(sqrt(x))=0 then imag(sqrt(x))≥0.

 

Example

Calculate the square root of a number.

?sqrt(4);

result: 

 

The square root function of z = x + iy in the complex plane has a branch cut at (-∞,0], as shown in the following example.

x = linspace(-1,1,100);

y = linspace(-1,1,100);

 

X = meshgridx(x,y);

Y = meshgridy(x,y);

 

image(x,y,real(sqrt(X+1i*Y)),"x", "y","Real part of sqrt(x+iy)");

image(x,y,imag(sqrt(X+1i*Y)),"x", "y","Imaginary part of sqrt(x+iy)");

 

ref_scripts_sqrt_complex_real_zoom63

ref_scripts_sqrt_complex_imag_zoom63

 

See Also

Functions, ^

Copyright Lumerical Inc. | Privacy | Site Map