i
Imaginary unit, the square root of -1.
Category: Mathematics > Elementary Math
Syntax
z = i
The imaginary unit, the complex number 0 + 1i.
z = a + b*i
Builds a complex number from its real part a and imaginary part b.
Description
i is a built-in function that returns the imaginary unit. Because it is only a name, assigning to a variable called i (a very common loop index) hides it, and 2 + 3*i then uses the variable instead. The imaginary literals 1i, 3j and 2.5i are immune to this: a number followed directly by i or j is always imaginary, so they are the safer way to write complex constants.
j is an equivalent alias, popular in engineering.
Output arguments
z- Complex scalar of class double.
Example
Complex arithmetic
i^2
z = 2 + 3*i
abs(z)
exp(1i*pi/2)
Output
ans = -1
z = 2.0000 + 3.0000i
ans = 3.6056
ans = 6.1232e-17 + 1.0000i