UNPKG

2.19 kBMarkdownView Raw
1<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
2
3# Function complex
4
5Create a complex value or convert a value to a complex value.
6
7
8## Syntax
9
10```js
11math.complex() // creates a complex value with zero
12 // as real and imaginary part.
13math.complex(re : number, im : string) // creates a complex value with provided
14 // values for real and imaginary part.
15math.complex(re : number) // creates a complex value with provided
16 // real value and zero imaginary part.
17math.complex(complex : Complex) // clones the provided complex value.
18math.complex(arg : string) // parses a string into a complex value.
19math.complex(array : Array) // converts the elements of the array
20 // or matrix element wise into a
21 // complex value.
22math.complex({re: number, im: number}) // creates a complex value with provided
23 // values for real an imaginary part.
24math.complex({r: number, phi: number}) // creates a complex value with provided
25 // polar coordinates
26```
27
28### Parameters
29
30Parameter | Type | Description
31--------- | ---- | -----------
32`args` | * &#124; Array &#124; Matrix | Arguments specifying the real and imaginary part of the complex number
33
34### Returns
35
36Type | Description
37---- | -----------
38Complex &#124; Array &#124; Matrix | Returns a complex value
39
40
41## Examples
42
43```js
44const a = math.complex(3, -4) // a = Complex 3 - 4i
45a.re = 5 // a = Complex 5 - 4i
46const i = a.im // Number -4
47const b = math.complex('2 + 6i') // Complex 2 + 6i
48const c = math.complex() // Complex 0 + 0i
49const d = math.add(a, b) // Complex 5 + 2i
50```
51
52
53## See also
54
55[bignumber](bignumber.md),
56[boolean](boolean.md),
57[index](index.md),
58[matrix](matrix.md),
59[number](number.md),
60[string](string.md),
61[unit](unit.md)