1 |
|
2 |
|
3 | # Function im
|
4 |
|
5 | Get the imaginary part of a complex number.
|
6 | For a complex number `a + bi`, the function returns `b`.
|
7 |
|
8 | For matrices, the function is evaluated element wise.
|
9 |
|
10 |
|
11 | ## Syntax
|
12 |
|
13 | ```js
|
14 | math.im(x)
|
15 | ```
|
16 |
|
17 | ### Parameters
|
18 |
|
19 | Parameter | Type | Description
|
20 | --------- | ---- | -----------
|
21 | `x` | number | BigNumber | Complex | Array | Matrix | A complex number or array with complex numbers
|
22 |
|
23 | ### Returns
|
24 |
|
25 | Type | Description
|
26 | ---- | -----------
|
27 | number | BigNumber | Array | Matrix | The imaginary part of x
|
28 |
|
29 |
|
30 | ## Examples
|
31 |
|
32 | ```js
|
33 | const a = math.complex(2, 3)
|
34 | math.re(a) // returns number 2
|
35 | math.im(a) // returns number 3
|
36 |
|
37 | math.re(math.complex('-5.2i')) // returns number -5.2
|
38 | math.re(math.complex(2.4)) // returns number 0
|
39 | ```
|
40 |
|
41 |
|
42 | ## See also
|
43 |
|
44 | [re](re.md),
|
45 | [conj](conj.md),
|
46 | [abs](abs.md),
|
47 | [arg](arg.md)
|