About the Author |
|
xvii | |
About the Technical Reviewer |
|
xix | |
Acknowledgments |
|
xi | |
|
|
1 | (14) |
|
1.1 Welcome to the Julian World |
|
|
1 | (2) |
|
|
3 | (1) |
|
|
4 | (1) |
|
|
5 | (3) |
|
|
5 | (1) |
|
|
6 | (1) |
|
|
7 | (1) |
|
|
7 | (1) |
|
|
8 | (4) |
|
1.5.1 Initialization of Package Manager |
|
|
9 | (1) |
|
1.5.2 Updating Package Repository |
|
|
9 | (1) |
|
1.5.3 Installing a New Package |
|
|
10 | (1) |
|
|
10 | (1) |
|
1.5.5 Status of Installed Packages |
|
|
11 | (1) |
|
1.5.6 Off-line Installation of Packages [ 18] |
|
|
12 | (1) |
|
1.6 Using Code in This Book |
|
|
12 | (1) |
|
|
13 | (1) |
|
|
13 | (2) |
|
Chapter 2 Object-Oriented Programming |
|
|
15 | (10) |
|
|
15 | (1) |
|
2.2 Procedural Programming vs. OOP |
|
|
15 | (1) |
|
|
15 | (1) |
|
|
16 | (1) |
|
|
16 | (1) |
|
|
17 | (4) |
|
2.6.1 Multiple References for the Same Object |
|
|
19 | (2) |
|
|
21 | (2) |
|
|
22 | (1) |
|
2.7.2 Naming Style Convention [ 4] |
|
|
22 | (1) |
|
|
23 | (1) |
|
|
23 | (2) |
|
Chapter 3 Basic Math with Julia |
|
|
25 | (44) |
|
|
25 | (1) |
|
|
26 | (5) |
|
|
26 | (1) |
|
|
27 | (1) |
|
|
28 | (1) |
|
3.2.4 Seeking Help from Julia |
|
|
29 | (1) |
|
|
30 | (1) |
|
|
30 | (1) |
|
|
30 | (1) |
|
3.2.8 Version Information |
|
|
31 | (1) |
|
3.3 Some Experiments with Numbers |
|
|
31 | (5) |
|
|
31 | (1) |
|
3.3.2 Julia as Calculator |
|
|
32 | (4) |
|
3.4 Data Type for Integers and Real Numbers |
|
|
36 | (1) |
|
|
36 | (13) |
|
3.5.1 Hierarchy Tree of Number Types |
|
|
37 | (3) |
|
3.5.2 Floating Point Arithmetic |
|
|
40 | (5) |
|
3.5.3 Overflow and Division Error |
|
|
45 | (1) |
|
3.5.4 Floating Point Numbers vs. Real Numbers |
|
|
46 | (2) |
|
|
48 | (1) |
|
3.6 Arbitrary Precision Arithmetic |
|
|
49 | (1) |
|
|
50 | (4) |
|
|
54 | (1) |
|
|
55 | (7) |
|
3.9.1 Comparison of Mathematical Quantities |
|
|
55 | (4) |
|
3.9.2 Chaining Comparisons |
|
|
59 | (1) |
|
|
60 | (2) |
|
|
62 | (2) |
|
|
64 | (2) |
|
|
66 | (1) |
|
|
66 | (3) |
|
Chapter 4 Complex Numbers |
|
|
69 | (10) |
|
|
69 | (1) |
|
4.2 Defining Complex Numbers |
|
|
69 | (3) |
|
4.3 Properties of Complex Numbers |
|
|
72 | (2) |
|
|
74 | (3) |
|
|
77 | (1) |
|
|
77 | (2) |
|
Chapter 5 Rational and Irrational Numbers |
|
|
79 | (10) |
|
|
79 | (1) |
|
|
80 | (7) |
|
5.2.1 Representation of Rational Numbers |
|
|
80 | (1) |
|
5.2.2 Complex Numbers as Numerators and Denominators |
|
|
81 | (1) |
|
5.2.3 Mathematical Operations on Rational Numbers |
|
|
82 | (2) |
|
5.2.4 Converting a Rational Number to a Floating Point Number |
|
|
84 | (1) |
|
5.2.5 Rationals with Zero Denominator |
|
|
85 | (1) |
|
5.2.6 Rationals with Other Data Types |
|
|
85 | (2) |
|
|
87 | (1) |
|
|
87 | (2) |
|
Chapter 6 Mathematical Functions |
|
|
89 | (38) |
|
|
89 | (1) |
|
|
89 | (6) |
|
6.2.1 div(x,y), fld(x,y), and cld(x,y) |
|
|
90 | (2) |
|
6.2.2 rem(), mod(), and mod1() |
|
|
92 | (1) |
|
|
93 | (1) |
|
6.2.4 divrem() and fldmod() |
|
|
94 | (1) |
|
|
94 | (1) |
|
|
95 | (1) |
|
6.3 Sign and Absolute Value Functions |
|
|
95 | (7) |
|
|
96 | (1) |
|
6.3.2 Absolute Value of a Complex Number |
|
|
97 | (1) |
|
6.3.3 sign(), signbit(), copysign(), and flipsign() |
|
|
98 | (4) |
|
6.4 Power, Logs, and Roots |
|
|
102 | (11) |
|
6.4.1 Numbers Raised to Some Power |
|
|
103 | (1) |
|
6.4.2 sqrt(), cbrt(), and hypot() |
|
|
104 | (2) |
|
6.4.3 Problem with hypot() Calculations |
|
|
106 | (1) |
|
6.4.4 exp(), expm1(), Idexp(), and exponent() |
|
|
107 | (2) |
|
6.4.5 log(), log2(), log10(), and log1p() |
|
|
109 | (4) |
|
6.5 Trigonometric and Hyperbolic Functions |
|
|
113 | (6) |
|
6.5.1 Trigonometric Functions |
|
|
113 | (5) |
|
6.5.2 Hyperbolic Functions |
|
|
118 | (1) |
|
6.6 Iterative Algorithms to Calculate Mathematical Functions |
|
|
119 | (5) |
|
6.6.1 Numerical Approximations |
|
|
119 | (1) |
|
|
119 | (1) |
|
|
120 | (1) |
|
|
121 | (1) |
|
6.6.5 Maclaurin Series for sin(x) and cos(x) |
|
|
122 | (1) |
|
6.6.6 Series Expansion to Algorithms |
|
|
123 | (1) |
|
6.6.7 How Many Numbers of Terms! |
|
|
124 | (1) |
|
|
124 | (1) |
|
|
125 | (2) |
|
|
127 | (54) |
|
7.1 Introduction to Arrays |
|
|
127 | (1) |
|
|
128 | (10) |
|
7.2.1 Arrays of Multiple Dimensions |
|
|
129 | (1) |
|
|
130 | (1) |
|
|
131 | (1) |
|
7.2.4 Arrays of Mixed Data Types |
|
|
132 | (1) |
|
|
132 | (3) |
|
7.2.6 Creating an Array Using the Ellipsis Operator |
|
|
135 | (1) |
|
7.2.7 Creating Arrays Using linspace |
|
|
135 | (1) |
|
7.2.8 Creating Arrays Using logspace |
|
|
136 | (1) |
|
|
137 | (1) |
|
|
138 | (3) |
|
|
141 | (4) |
|
7.4.1 Creating Subarrays Using: operator |
|
|
141 | (1) |
|
|
142 | (1) |
|
7.4.3 Slicing Multidimensional Arrays |
|
|
143 | (2) |
|
7.5 Filling Arrays with Values |
|
|
145 | (8) |
|
|
145 | (2) |
|
|
147 | (1) |
|
|
148 | (1) |
|
|
148 | (1) |
|
7.5.5 Arrays Filled with Random Numbers |
|
|
149 | (3) |
|
|
152 | (1) |
|
|
152 | (1) |
|
|
153 | (4) |
|
|
155 | (1) |
|
7.6.2 Squeezing and Arrays |
|
|
156 | (1) |
|
|
157 | (6) |
|
|
158 | (1) |
|
7.7.2 Sort by Transformation |
|
|
159 | (1) |
|
|
160 | (2) |
|
7.7.4 Lexicographical Order |
|
|
162 | (1) |
|
7.8 Finding Items in Arrays |
|
|
163 | (2) |
|
7.8.1 find(), findfirst(), and findnext() |
|
|
164 | (1) |
|
|
165 | (1) |
|
|
166 | (1) |
|
|
166 | (4) |
|
7.11 Generator Expressions |
|
|
170 | (1) |
|
7.12 Assignment Operator and Arrays |
|
|
171 | (1) |
|
7.12.1 Other Mathematical Operators |
|
|
172 | (1) |
|
7.13 Set Theory and Arrays |
|
|
172 | (1) |
|
|
173 | (6) |
|
7.14.1 Creating a Dictionary |
|
|
174 | (1) |
|
7.14.2 Looking Up a Dictionary |
|
|
175 | (1) |
|
7.14.3 Finding Keys and Values |
|
|
176 | (1) |
|
|
177 | (1) |
|
|
177 | (1) |
|
7.14.6 Checking a Key-Value Pair |
|
|
178 | (1) |
|
7.14.7 Adding and Deleting a Key |
|
|
178 | (1) |
|
|
179 | (1) |
|
|
179 | (2) |
|
Chapter 8 Arrays for Matrix Operations |
|
|
181 | (48) |
|
|
181 | (3) |
|
8.2 Properties of a Matrix |
|
|
184 | (8) |
|
|
185 | (1) |
|
|
186 | (1) |
|
|
187 | (1) |
|
8.2.4 An Upper and Lower Triangular Matrix |
|
|
187 | (2) |
|
|
189 | (1) |
|
|
190 | (2) |
|
|
192 | (8) |
|
|
193 | (7) |
|
|
200 | (13) |
|
8.4.1 Inverse of a Matrix |
|
|
200 | (4) |
|
|
204 | (2) |
|
8.4.3 Left or Right Division |
|
|
206 | (1) |
|
|
207 | (3) |
|
8.4.5 Exponentiation of Matrices |
|
|
210 | (2) |
|
8.4.6 Logarithm on Matrices |
|
|
212 | (1) |
|
|
213 | (1) |
|
|
213 | (2) |
|
8.6.1 Comparison of Elements |
|
|
213 | (2) |
|
|
215 | (7) |
|
|
219 | (1) |
|
|
220 | (2) |
|
|
222 | (1) |
|
|
223 | (4) |
|
|
223 | (1) |
|
8.9.2 Positive Definite Matrix |
|
|
224 | (1) |
|
|
225 | (1) |
|
|
226 | (1) |
|
|
227 | (1) |
|
|
227 | (2) |
|
|
229 | (24) |
|
|
229 | (1) |
|
|
229 | (1) |
|
|
230 | (1) |
|
|
230 | (1) |
|
9.5 Corresponding Integer Value |
|
|
231 | (2) |
|
9.6 + Operator and Characters |
|
|
233 | (2) |
|
9.6.1 Characters and Strings Are Two Data Types |
|
|
234 | (1) |
|
9.7 + Operator and Strings |
|
|
235 | (1) |
|
|
235 | (1) |
|
|
236 | (2) |
|
9.10 Strings Are Like Arrays |
|
|
238 | (3) |
|
|
239 | (1) |
|
|
240 | (1) |
|
9.11 Common String Functions |
|
|
241 | (6) |
|
|
241 | (1) |
|
|
242 | (1) |
|
9.11.3 start(), endof(), and next() |
|
|
242 | (1) |
|
|
243 | (2) |
|
9.11.5 uppercase() and lowercase() |
|
|
245 | (1) |
|
|
245 | (1) |
|
|
245 | (1) |
|
|
246 | (1) |
|
9.11.9 strip(), Istrip(), and rstrip() |
|
|
246 | (1) |
|
|
247 | (1) |
|
9.12 Reading Data as Arrays from Strings |
|
|
247 | (3) |
|
9.13 Lexicographical Comparison of Strings |
|
|
250 | (1) |
|
|
251 | (1) |
|
|
251 | (2) |
|
|
253 | (22) |
|
10.1 Introduction to Julia Functions |
|
|
253 | (1) |
|
10.2 Defining a Simple Julia Function |
|
|
254 | (14) |
|
10.2.1 Shorthand Notation |
|
|
256 | (1) |
|
|
256 | (6) |
|
|
262 | (1) |
|
10.2.4 Anonymous Functions |
|
|
263 | (1) |
|
|
264 | (2) |
|
10.2.6 reduce(), foldl(), and foldr() Functions |
|
|
266 | (1) |
|
|
267 | (1) |
|
|
268 | (2) |
|
10.3.1 Defining Multiple Function Definitions |
|
|
269 | (1) |
|
10.4 Operators Defined as Functions |
|
|
270 | (3) |
|
10.4.1 Functions Returning Functions |
|
|
271 | (2) |
|
|
273 | (2) |
|
|
275 | (20) |
|
11.1 Introduction to Control Flow |
|
|
275 | (1) |
|
|
275 | (1) |
|
|
276 | (1) |
|
|
277 | (2) |
|
|
279 | (6) |
|
11.5.1 Scope of a Loop Variable |
|
|
280 | (1) |
|
|
281 | (1) |
|
|
282 | (2) |
|
|
284 | (1) |
|
|
284 | (1) |
|
|
285 | (1) |
|
|
285 | (1) |
|
|
286 | (2) |
|
|
288 | (1) |
|
|
289 | (5) |
|
11.9.1 Built-in Exceptions |
|
|
289 | (1) |
|
11.9.2 Custom-Built Exceptions |
|
|
290 | (1) |
|
11.9.3 catch...try Construct for Testing Exceptions |
|
|
291 | (2) |
|
|
293 | (1) |
|
|
294 | (1) |
|
|
295 | (22) |
|
|
295 | (1) |
|
|
295 | (1) |
|
|
296 | (3) |
|
12.4 Byte Array Streaming |
|
|
299 | (2) |
|
12.5 Streaming a Line of Characters |
|
|
301 | (1) |
|
|
302 | (7) |
|
|
303 | (2) |
|
|
305 | (2) |
|
|
307 | (1) |
|
|
308 | (1) |
|
12.7 Different Display Units |
|
|
309 | (1) |
|
|
310 | (5) |
|
12.8.1 open(), close(), and read() |
|
|
311 | (2) |
|
12.8.2 Array Reading and Writing |
|
|
313 | (2) |
|
|
315 | (1) |
|
|
315 | (2) |
|
|
317 | (18) |
|
13.1 Introduction to Plotting in Julia |
|
|
317 | (1) |
|
|
318 | (1) |
|
|
319 | (13) |
|
13.3.1 Default Behavior of Plots |
|
|
322 | (2) |
|
13.3.2 Simpler Way to Plot Equations |
|
|
324 | (1) |
|
13.3.3 Implicitly Passing a Second Plot |
|
|
325 | (1) |
|
13.3.4 Decorating the Plots |
|
|
326 | (1) |
|
13.3.5 Many Plots in the Same Window Using subplot() |
|
|
327 | (2) |
|
|
329 | (1) |
|
|
330 | (1) |
|
|
330 | (1) |
|
|
331 | (1) |
|
|
332 | (1) |
|
|
333 | (2) |
|
|
333 | (2) |
|
Chapter 14 Metaprogramming |
|
|
335 | (10) |
|
|
335 | (1) |
|
|
335 | (2) |
|
|
337 | (3) |
|
14.3.1 fieldnames() and dump() |
|
|
337 | (3) |
|
14.4 Expression Interpolation |
|
|
340 | (1) |
|
|
341 | (2) |
|
|
343 | (1) |
|
|
344 | (1) |
Index |
|
345 | |