FreeMat: I-J Square Root of Negative One

FreeMat

- Main Page
- Related Pages

I-J Square Root of Negative One

Section: Base Constants

# Usage

Returns a `complex` value that represents the square root of -1. There are two functions that return the same value:

       y = i

and

       y = j.

This allows either `i` or `j` to be used as loop indices. The returned value is a 32-bit complex value.

# Example

The following examples demonstrate a few calculations with `i`.

    --> i

    ans =
       0.0000 +  1.0000i

    --> i^2

    ans =
      -1.0000 +  0.0000i

The same calculations with `j`:

    --> j

    ans =
       0.0000 +  1.0000i

    --> j^2

    ans =
      -1.0000 +  0.0000i

Here is an example of how `i` can be used as a loop index and then recovered as the square root of -1.

    --> accum = 0; for i=1:100; accum = accum + i; end; accum

    ans =
     5050

    --> i

    ans =
     100

    --> clear i
    --> i

    ans =
       0.0000 +  1.0000i