Main Content

signIm

Sign of the imaginary part of complex number

Syntax

Description

example

signIm(z) returns the sign of the imaginary part of a complex number z. For all complex numbers with a nonzero imaginary part, singIm(z) = sign(imag(z)). For real numbers, signIm(z) = -sign(z).

signIm(z)={101if Im(z)>0 or Im(z)=0 and z<0if z=0otherwise

Examples

Symbolic Results Including signIm

Results of symbolic computations, especially symbolic integration, can include the signIm function.

Integrate this expression. For complex values a and x, this integral includes signIm.

syms a x
f = 1/(a^2 + x^2);
F = int(f, x, -Inf, Inf)
F =
(pi*signIm(1i/a))/a

Signs of Imaginary Parts of Numbers

Find the signs of imaginary parts of complex numbers with nonzero imaginary parts and of real numbers.

Use signIm to find the signs of imaginary parts of these numbers. For complex numbers with nonzero imaginary parts, signIm returns the sign of the imaginary part of the number.

[signIm(-18 + 3*i), signIm(-18 - 3*i),...
signIm(10 + 3*i), signIm(10 - 3*i),...
signIm(Inf*i), signIm(-Inf*i)]
ans =
      1    -1     1    -1     1    -1

For real positive numbers, signIm returns -1.

[signIm(2/3), signIm(1), signIm(100), signIm(Inf)]
ans =
    -1    -1    -1    -1

For real negative numbers, signIm returns 1.

[signIm(-2/3), signIm(-1), signIm(-100), signIm(-Inf)]
ans =
     1     1     1     1

signIm(0) is 0.

[signIm(0), signIm(0 + 0*i), signIm(0 - 0*i)]
ans =
     0     0     0

Signs of Imaginary Parts of Symbolic Expressions

Find the signs of imaginary parts of symbolic expressions that represent complex numbers.

Call signIm for these symbolic expressions without additional assumptions. Because signIm cannot determine if the imaginary part of a symbolic expression is positive, negative, or zero, it returns unresolved symbolic calls.

syms x y z
[signIm(z), signIm(x + y*i), signIm(x - 3*i)]
ans =
[ signIm(z), signIm(x + y*1i), signIm(x - 3i)]

Assume that x, y, and z are positive values. Find the signs of imaginary parts of the same symbolic expressions.

syms x y z positive
[signIm(z), signIm(x + y*i), signIm(x - 3*i)]
ans =
[ -1, 1, -1]

For further computations, clear the assumptions by recreating the variables using syms.

syms x y z

Find the first derivative of the signIm function. signIm is a constant function, except for the jump discontinuities along the real axis. The diff function ignores these discontinuities.

syms z
diff(signIm(z), z)
ans =
0

Signs of Imaginary Parts of Matrix Elements

singIm accepts vectors and matrices as its input argument. This lets you find the signs of imaginary parts of several numbers in one function call.

Find the signs of imaginary parts of the real and complex elements of matrix A.

A = sym([(1/2 + i), -25; i*(i + 1), pi/6 - i*pi/2]);
signIm(A)
ans =
[ 1,  1]
[ 1, -1]

Input Arguments

collapse all

Input representing complex number, specified as a number, symbolic number, symbolic variable, expression, vector, or matrix.

Tips

  • signIm(NaN) returns NaN.

See Also

| | |

Introduced in R2014b