An introduction to scientific computing in Julia
About
This is a guide to using Julia. Use the sidebars on the left and right to navigate between the pages. Code is run in Julia v1.9.3.
To get started, you can try the demonstration version of Julia on the official Julia website at https://julialang.org/learning/tryjulia/. Click the play button, and you should be greeted with the julia>
prompt. If you can see that, then you’re ready to go!
Note however, this is limited by being a web-hosted system, and for most uses of Julia it will be insufficient. What’s more, it won’t allow you to save files, which is something we’ll want to do eventually to avoid typing out a long sequence of commands every time we want to do a computation. Instead, you’ll eventually want to install Julia for yourself, for which guidance is given in Chapter 1.
Chapters
Chapter 1 details how to install Julia, and the different interfaces through which it can be used
Chapter 2 begins by looking at the building blocks of Julia programming, in particular variables, functions, and types. We also see how Julia itself can help us if we make a mistake or get stuck
Chapter 3 dives down into the different ways that numbers can be represented in Julia, their pros and cons, as well as the potential arithmetic errors that we need to be aware of when using them
Chapter 4 instead shows how text is represented in Julia using the
String
type, and how they can be manipulated. We note too how Julia reads each line of code as aString
, and how we can mimic this ourselvesChapter 5 discusses the different methods of manipulating code to run in more ways than just line by line down the page, and the possibilities that this brings
Chapter 6 looks again at variables, functions, and types, and how we can create our own custom structures of these forms
Chapter 7 analyses perhaps the most unique and defining feature of Julia: multiple dispatch. We discover how it works, why we would use it, and how to make use of it ourselves
Chapter 8 breaks down the packaging system of Julia, which permits the installation and use of specialised code written by others to add functionality
Chapter 9 investigates ways to store and manipulate several pieces of data in one go. We see how Julia works intelligently with such collections, meet some of the specialised types that take such a form, as well as putting this to use in plotting Julia sets
Chapter 10 demonstrates Julia’s ability to read and write data from or to external files
Chapter 11 describes how to use the
Plots.jl
package to plot data as a graphChapter 12 introduces ways of testing code
These chapters will refer to each other in places, but may be read somewhat independently of each other. At the start of each chapter, a list of recommended prerequisites is given, in a box like this. Some sections also expect additional knowledge, which is specified in similar boxes.
As with all programming languages, Julia has many conventions of naming, syntax, and style (and these can differ from other languages!), which will be highlighted in boxes like this. These range from the inconsequential mundanities to the genuine good practice stopping you from breaking something important, but beginners should strive to follow them as much as possible nonetheless.
Appendices
Appendix A provides quick reference definitions for Julia syntax and terminology used throughout the book.
All diagrams used in this book are generated in Julia. The code to generate these diagrams can be found in Appendix B.
Credits
This project was funded by the Cambridge University Press.
This book was rendered by Quarto.
Licence: CC BY-NC-SA