Concept Flow - Complex type
Create complex number
Store in variable
Use complex number in operations
Output result
This flow shows how to create a complex number, store it, use it in calculations, and then output the result.
z <- 3 + 4i real_part <- Re(z) imag_part <- Im(z) modulus <- Mod(z) print(modulus)
| Step | Action | Variable | Value | Output |
|---|---|---|---|---|
| 1 | Create complex number | z | 3+4i | |
| 2 | Extract real part | real_part | 3 | |
| 3 | Extract imaginary part | imag_part | 4 | |
| 4 | Calculate modulus | modulus | 5 | |
| 5 | Print modulus | 5 |
| Variable | Start | After Step 1 | After Step 2 | After Step 3 | After Step 4 | Final |
|---|---|---|---|---|---|---|
| z | undefined | 3+4i | 3+4i | 3+4i | 3+4i | 3+4i |
| real_part | undefined | undefined | 3 | 3 | 3 | 3 |
| imag_part | undefined | undefined | undefined | 4 | 4 | 4 |
| modulus | undefined | undefined | undefined | undefined | 5 | 5 |
Complex type in R: - Created using a + bi (e.g., 3+4i) - Use Re() to get real part - Use Im() to get imaginary part - Use Mod() to get modulus (distance) - Supports arithmetic and functions