signIm

Sign of the imaginary part of a complex number, with a branch-cut convention.

Category: Mathematics > Mathematical Functions

Syntax

s = signIm(z)

Returns 1, -1 or 0 according to the position of z relative to the real axis.

Description

For a nonreal z, signIm(z) is the sign of imag(z). On the real axis the imaginary part is zero, so the function uses the convention that continues the function from above along the negative axis: it returns 1 for negative real numbers and -1 for positive real numbers. signIm(0) is 0.

The convention matches the branch cut of the principal square root and logarithm along the negative real axis, which is why the function appears in symbolic simplification.

Input arguments

z
Numeric or symbolic scalar or array.

Output arguments

s
Array of the same size as z with the values 1, -1 or 0.

Example

Complex and real inputs

signIm([1+2i, -3i, 4, -4, 0])
Output
ans = 1×5

     1    -1    -1     1     0

See also

sign imag angle abs