# Complex

This is the Complex class version 1.0.

Represents a complex number.

Ferret has native support for complex numbers, including syntax for the normal mathematic notation in rectangular form `a + bi`, where `a` and `b` are real numbers and `i` is the imaginary unit. `a` and `b` are commonly called the "real part" and "imaginary part" respectively, despite both being real numbers.

Complex numbers can also be constructed from polar representations `r(cosÎ¸ + isinÎ¸)` or `re^(iÎ¸)` with `Complex.polar()`.

## Initializer

```\$z = Complex(\$a: Num, \$b: Num)
```

Creates a complex number with the given real and imaginary parts. This is only useful to create a complex number from variable parts, since Ferret has native support for inline `a + bi` notation.

If the given imaginary part is zero, the constructor returns the real part as a real number.

### Arguments

• a: Num - Real part.

• b: Num - Imaginary part (a real number, though).

## Initializer

```\$z = Complex(\$r: Num, \$Î¸: Num)
```

Create a complex number in polar form given radius `r` and angle `Î¸`.

`z = r(cosÎ¸ + isinÎ¸)`.

### Arguments

• r: Num - Distance from the origin in the complex plane.

• Î¸: Num - Angle between the positive real axis and the.

## Methods

### abs

```\$z.abs
```

Computed property. Absolute value (or modulus) of the complex number. This is distance from the origin on the complex plane.

In polar form, this is `r`.

### arg

```\$z.arg
```

Computed property. Argument) of the complex number. On the complex plane, this is the angle `Î¸` between the positive real axis and the position vector.

In polar form, this is `Î¸`.

### conj

```\$z.conj
```

Computed property. Conjugate of the complex number.

### sqrt

```\$z.sqrt
```

Computed property. Square root of the complex number.

### root

```\$z.root(\$n: Num)
```

Nth root of the complex number.

#### Arguments

```\$z + (\$rhs: Complex)
```

```\$z + (\$ehs: Num)
```

Addition of complex and real numbers.

### Subtraction operator (-)

```\$z - (\$rhs: Complex)
```

Subtraction of complex numbers.

### Subtraction operator (-)

```\$z - (\$rhs: Num)
```

Subtraction of real number from complex number.

### Subtraction operator (-)

```\$z - (\$lhs: Num)
```

Subtraction of complex number from real number.

### Multiplication operator (*)

```\$z * (\$rhs: Complex)
```

Multiplication of complex numbers.

### Multiplication operator (*)

```\$z * (\$ehs: Num)
```

Multiplication of real and complex numbers.

### Division operator (/)

```\$z / (\$rhs: Complex)
```

Division of complex numbers.

### Division operator (/)

```\$z / (\$rhs: Num)
```

Division of complex number by real number.

### Exponent operator (^)

```\$z ^ (\$rhs: Num)
```

Complex number to real power.

This can get expensive for large powers. For a quicker but less precise alternative, use `.pow()`.

### Exponent operator (^)

```\$z ^ (\$lhs: Num)
```

Real number to a complex power.

### Equality operator (==)

```\$z == (\$ehs: Complex)
```

Equality of complex numbers.

### Equality operator (==)

```\$z == (\$ehs: Num)
```

Equality of complex number and real number.

### pow

```\$z.pow(\$rhs: Num)
```

Complex number to real power. This is an alternative implementation to the power operator which is faster but less precise.

## Class functions

### polar

```Complex.polar(\$r: Num, \$Î¸: Num)
```

Create a complex number in polar form given radius `r` and angle `Î¸`.

`z = r(cosÎ¸ + isinÎ¸)`.

#### Arguments

• r: Num - Distance from the origin in the complex plane.

• Î¸: Num - Angle between the positive real axis and the.

End of the Complex class.

This file was generated automatically by the Ferret compiler from Complex.frt.