You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: exercises/concept/tracking-turntable/.docs/introduction.md
+3-32
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
`Complex numbers` are not complicated.
4
4
They just need a less alarming name.
5
5
6
-
They are so useful, especially in engineering and science, that Julia includes [complex numbers][complex] as standard numeric types alongside integers and floating-point numbers.
6
+
They are so useful, especially in engineering and science, that Julia includes complex numbers as standard numeric types alongside integers and floating-point numbers.
7
7
8
8
## Basics
9
9
@@ -16,13 +16,10 @@ To create complex numbers from two real numbers, just add the suffix `im` to the
16
16
```julia-repl
17
17
julia> z = 1.2 + 3.4im
18
18
1.2 + 3.4im
19
-
20
19
julia> typeof(z)
21
20
ComplexF64 (alias for Complex{Float64})
22
-
23
21
julia> zi = 1 + 2im
24
22
1 + 2im
25
-
26
23
julia> typeof(zi)
27
24
Complex{Int64}
28
25
```
@@ -44,10 +41,8 @@ To access the parts of a complex number individually:
44
41
```julia-repl
45
42
julia> z = 1.2 + 3.4im
46
43
1.2 + 3.4im
47
-
48
44
julia> real(z)
49
45
1.2
50
-
51
46
julia> imag(z)
52
47
3.4
53
48
```
@@ -65,13 +60,10 @@ However, it is still a complex number in Julia.
65
60
```julia-repl
66
61
julia> zr = 1.2 + 0im
67
62
1.2 + 0.0im
68
-
69
63
julia> typeof(zr)
70
64
ComplexF64 (alias for Complex{Float64})
71
-
72
65
julia> zi = 3.4im
73
66
0.0 + 3.4im
74
-
75
67
julia> typeof(zi)
76
68
ComplexF64 (alias for Complex{Float64})
77
69
```
@@ -89,27 +81,21 @@ This is a simple idea, but it leads to interesting consequences.
89
81
90
82
## Arithmetic
91
83
92
-
All of the standard mathematical [`operators`][operators] and elementary functions used with floats and integers also work with complex numbers. A small sample:
84
+
All of the standard mathematical `operators` and elementary functions used with floats and integers also work with complex numbers. A small sample:
93
85
94
86
```julia-repl
95
87
julia> z1 = 1.5 + 2im
96
88
1.5 + 2.0im
97
-
98
89
julia> z2 = 2 + 1.5im
99
90
2.0 + 1.5im
100
-
101
91
julia> z1 + z2 # addition
102
92
3.5 + 3.5im
103
-
104
93
julia> z1 * z2 # multiplication
105
94
0.0 + 6.25im
106
-
107
95
julia> z1 / z2 # division
108
96
0.96 + 0.28im
109
-
110
97
julia> z1^2 # exponentiation
111
98
-1.75 + 6.0im
112
-
113
99
julia> 2^z1 # another exponentiation
114
100
0.5188946835878313 + 2.7804223253571183im
115
101
```
@@ -127,16 +113,12 @@ There are several functions, in addition to `real()` and `imag()`, with particul
127
113
```julia-repl
128
114
julia> z1
129
115
1.5 + 2.0im
130
-
131
116
julia> conj(z1)
132
117
1.5 - 2.0im
133
-
134
118
julia> abs(z1)
135
119
2.5
136
-
137
120
julia> abs2(z1)
138
121
6.25
139
-
140
122
julia> angle(z1)
141
123
0.9272952180016122
142
124
```
@@ -151,15 +133,13 @@ Here is an example using some constants:
151
133
```julia-repl
152
134
julia> euler = exp(1im * π)
153
135
-1.0 + 1.2246467991473532e-16im
154
-
155
136
julia> real(euler)
156
137
-1.0
157
-
158
138
julia> round(imag(euler), digits=15) # round to 15 decimal places
159
139
0.0
160
140
```
161
141
162
-
The polar `(r, θ)` notation is so useful, that there are built-in functions `cis` and `cispi` for constructing it more efficiently.
142
+
The polar `(r, θ)` notation is so useful, that there are built-in functions `cis`(short for `cos(x) + isin(x)`) and `cispi`(short for`cos(πx) + isin(πx)`) which can help in constructing it more efficiently.
163
143
164
144
```julia-repl
165
145
julia> exp(1im * π) ≈ cis(π) ≈ cispi(1)
@@ -171,22 +151,13 @@ The approximate equality above is because the functions `cis` and `cispi` can gi
0 commit comments