Imaginary unit
In mathematics, physics, and engineering, the imaginary unit is denoted by i\,  or the Latin j\,  or the Greek iota (see alternative notations below).  It allows the real number system, \mathbb{R}, to be extended to the complex number system, \mathbb{C}.  Its precise definition is dependent upon the particular method of extension.
The primary motivation for this extension is the fact that not every polynomial equation with real coefficients f(x)=0 has a solution in the real numbers. In particular, the equation x^2+1=0 has no real solution (see "Definition", below). However, if we allow complex numbers as solutions, then this equation, and indeed every polynomial equation f(x)=0 does have a solution. (See algebraic closure and fundamental theorem of algebra.)
For a history of the imaginary unit, see the history of complex numbers.
The imaginary unit is often loosely referred to as the "square root of negative one" or the "square root of minus one", but see below for difficulties that may arise from a naive use of this idea.

# Definition
By definition, the imaginary unit i is one solution (of two) of the quadratic equation
-r equivalently
Since there is no real number that produces a negative real number when squared, we imagine such a number and assign to it the symbol i. It is important to realize, though, that i is as well-defined a mathematical construct as the real numbers, despite its formal name and being less than immediately intuitive.
Real number operations can be extended to imaginary and complex numbers by treating i as an unknown quantity while manipulating an expression, and then using the definition to replace any occurrence of i 2 with 1.  Higher integral powers of i can also be replaced with i, 1, i, or 1:

# i and i
Being a second order polynomial with no multiple real root, the above equation has two distinct solutions that are equally valid and that happen to be additive and multiplicative inverses of each other. More precisely, once a solution i of the equation has been fixed, the value i (which is not equal to i) is also a solution. Since the equation is the only definition of i, it appears that the definition is ambiguous (more precisely, not well-defined). However, no ambiguity results as long as one of the solutions is chosen and fixed as the "positive i".   This is because, although i and i are not quantitatively equivalent (they are negatives of each other), there is no qualitative difference between i and i (which cannot be said for 1 and +1).  Both imaginary numbers have equal claim to being the number whose square is 1.  If all mathematical textbooks and published literature referring to imaginary or complex numbers were rewritten with i replacing every occurrence of +i (and therefore every occurrence of i replaced by (i) = +i), all facts and theorems would continue to be equivalently valid.  The distinction between the two roots x of x^2 + 1 = 0 with one of them as "positive" is purely a notational relic; neither root can be said to be more primary or fundamental than the other.
The issue can be a subtle one. The most precise explanation is to say that although the complex field, defined as R/ (X2 + 1), (see complex number) is unique up to isomorphism, it is not unique up to a unique isomorphism  there are exactly 2 field automorphisms of R/ (X2 + 1), the identity and the automorphism sending X to X. (These are not the only field automorphisms of C, but are the only field automorphisms of C which keep each real number fixed.) See complex number, complex conjugation, field automorphism, and Galois group.
A similar issue arises if the complex numbers are interpreted as 2  2 real matrices (see complex number), because then both
and
are solutions to the matrix equation
In this case, the ambiguity results from the geometric choice of which "direction" around the unit circle is "positive" rotation.  A more precise explanation is to say that the automorphism group of the special orthogonal group SO (2, R) has exactly 2 elements  the identity and the automorphism which exchanges "CW" (clockwise) and "CCW" (counter-clockwise) rotations. See orthogonal group.
All these ambiguities can be solved by adopting a more rigorous definition of complex number, and explicitly choosing one of the solutions to the equation to be the imaginary unit. For example, the ordered pair (0, 1), in the usual construction of the complex numbers with two-dimensional vectors.

# Proper use
The imaginary unit is sometimes written \sqrt{-1} in advanced mathematics contexts (as well as in less advanced popular texts); however, great care needs to be taken when manipulating formulas involving radicals. The notation is reserved either for the principal square root function, which is only defined for real x  0, or for the principal branch of the complex square root function. Attempting to apply the calculation rules of the principal (real) square root function to manipulate the principal branch of the complex square root function will produce false results:
The calculation rule
is only valid for real, non-negative values of a and b.
For a more thorough discussion of this phenomenon, see square root and branch.
To avoid making such mistakes when manipulating complex numbers, a strategy is never to use a negative number under a square root sign. For instance, rather than writing expressions like \sqrt{-7}, one should write i\sqrt{7} instead. That is the use for which the imaginary unit was created.

# Square root of the imaginary unit
One might assume that a further set of imaginary numbers need to be invented to account for the square root of i. However this is not necessary as it can be expressed (albeit rather poorly - see above) as either of two complex numbers:
This can be shown to be valid from:

# Powers of i
The powers of i repeat in a cycle:
This can be expressed with the following pattern where n is any integer:
This leads to the conclusion that
where mod is the modulo operation.

# i and Euler's formula
Euler's formula is
where x is a real number. The formula can also be analytically extended for complex x.
Substituting x = \pi  yields
and one arrives at the elegant Euler's identity:
This remarkably simple equation relates five significant mathematical quantities (0, 1, , e, and i) by means of the basic operations of addition, multiplication, and exponentiation.

## Example
Substitution of x = \pi/2 - 2N\pi, where N is an arbitrary integer, produces
Or, raising each side to the power i,
-r
which shows that i^i\, has an infinite number of elements in the form of
where N is any integer.  This real value although real is not uniquely determined.  The reason is that the complex logarithm is multiply-valued.

# Operations with i
Many mathematical operations that can be carried out with real numbers can also be carried out with i, such as exponentation, roots, logarithms and trigonometric functions .
A number raised to the ni power is:
The  ni th root of a number is:
The log base i of a number is:
The cosine of i is a real number:
And the sine of i is imaginary:

# Alternative notations
- In electrical engineering and related fields, the imaginary unit is often written as j\, to avoid confusion with electrical current as a function of time, traditionally denoted by i(t)\, or just i.\,  The Python programming language also uses j to denote the imaginary unit, while in Matlab, both notations i and j are associated with the imaginary unit.
- Some extra care needs to be taken in certain textbooks which define j = i, in particular to travelling waves (e.g. a right travelling plane wave in the x direction e^{ i (kx - \omega t)} = e^{ j (\omega t-kx)} \,).
- Some texts use the Greek letter iota (  ) to write the imaginary unit to avoid confusion.  For example: Biquaternion.

# Notes
-  University of Toronto Mathematics Network: What is the square root of i? URL retrieved March 26, 2007.