Skip to main content
Mathematics LibreTexts


  • Page ID
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)

    ( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\id}{\mathrm{id}}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\kernel}{\mathrm{null}\,}\)

    \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\)

    \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\)

    \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    \( \newcommand{\vectorA}[1]{\vec{#1}}      % arrow\)

    \( \newcommand{\vectorAt}[1]{\vec{\text{#1}}}      % arrow\)

    \( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vectorC}[1]{\textbf{#1}} \)

    \( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)

    \( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)

    \( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)

    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)

    Solving problems is the essence of scientific computing. Many problems arise naturally from the sciences or mathematics and often to solve difficult problem relies on some computing resources. In a nutshell, this text is the blend of science, mathematics and computer science needed to solve problems.

    The intended audience for this text one who is interested in writing computer code that will solve a problem that you have. There are a few basics that you should have with this text:

    • Some background in writing computer programs. Your base language does not matter, but you should be familiar in writing short programs.
    • Some calculus. Most of the examples here do not need Calculus, but there are topics throughout the book, that at least differential calculus is helpful.

    As many textbooks, this started as a set of notes for my Scientific Computing class at Fitchburg State University. The students in the class are usually either Computer Science or Mathematics major and generally have an interest in computing. As I steered these pages from a set of notes to a textbook, I still keep those students in mind. However, I realize that an undergraduate text is often picked up by graduate students, those in industry and other faculty to build some knowledge base that one never had. I keep these readers in mind as well.

    I also want to distinguish this text from that of a Numerical Analysis or Numerical Methods text. A Numerical Methods text often covers many basic algorithms in mathematics such as numerical differentiation, numerical integration, rootfinding, linear algebra, etc. and how to implement such algorithms; this can be done with pseudocode or with a particular language. Numerical Analysis often covers the same algorithms in Numerical Methods with an emphasis on the analysis of the algorithms. This text does not broadly cover all the topics in Numerical Methods, nor does it do any analysis. There are many good books listed in the references. Instead, this text covers how to solve particular problems and often the algorithms have been coded in an existing library and we will leverage those here.

    Why use Julia or any particular language?

    The subtitle of the text says that solving problems in Scientific Computing does not happen in a vacuum or necessarily in the land of pseudocode, so I have specifically chosen a language to explain the concepts in the text much like I do in my class and the computing language that will be used will be Julia.

    Before going through the technical reasons for choosing Julia, the following personal story is interesting. I proposed teaching Scientific Computing at Fitchburg State University and the class would run in the Fall of 2014. The preceding spring, I knew that I had to choose some language for the class. There are many languages which would have been fine to use, including Maple, which our majors were learning in a required class, and that would have been an easy choice. However, one of blogs that I read regularly, , had an article by Lee Philips entitled ``Scientific computing’s future: Can any coding language top a 1950s behemoth?’’ The essence of the article is that in scientific computing, Fortran is king, due to two reasons 1) it is fast mainly because it was designed to be easily translated to machine language, which eventually is what runs on a computer and 2) there are many important mathematical libraries written in Fortran have been time-tested and virtually bug-free.

    However, nobody wants to code in Fortran. It is missing many features of modern languages and requires compilation. In selecting Julia, as stated on the main webpage, ``Julia was designed from the beginning for high performance.’’ As problems in Scientific Computing increase in size and complexity, it is an imperative that code runs fast and Julia typically does. It is one of the fastest high-level computing languages in benchmarks (REF) and compared to other scientific computing languages, it is the fastest. At the time the article was written, Julia was in version 0.2 and was quite raw, but was fascinating to consider and in hind sight, I’m glad I have done so.

    Another important aspect of Julia is that it is a scripting language like python. This means that you have an environment setup, you can just start entering julia commands and go. There is no compilation involved (like that in C or Fortran). Although compilation often finds errors, it is slow to do prototyping.

    How to read this text

    How might one read this text? Of course, the short answer is anyway you want. I hope you can pick it up and read what is relevant. There’s a few items about the layout as well as some standard conventions.

    Take a look at the table of contents. The text is broken up into a few parts. Part I consists of some basics of both the julia language as well as scientific computing. The remaining parts of the text are separate sections (Simulation, Data Analysis, Linear Algebra) and some advanced features of julia. Once Part I is read, the remaining parts are independent, however there are some ideas in Part III that are very helpful later in the test. The following diagram shows the chapter dependencies:

    In addition, because there are code snippets throughout the text, you should run the code as you read the text. Chapter 1 is the beginning to getting you started to run julia, but it is recommended to read Appendix A for more details. All julia code is written in and is either embedded in the text, like or written in a separate block like

    A = [1,2,3]

    Any blocks of code should be able to be copied and pasted directly into the julia REPL or a jupyter notebook.

    Also, output from julia is also in a fixed-width font but generally in a block like this:

    "This is a string of output"

    Here’s some of the coding style that is used throughout the text as well. This helps with readability:

    • functions are written in camelCase, like findRealRoot.
    • if a function returns a boolean (true or false) it should start with is or has, like isFullHousefrom Chapter 15
    • variables are written in snake_case like num_trials

    When writing your code, you don’t have to follow this convention, but I have tried to stay consistent in the text. Generally this convention will help with readability in that you know directly what kind of variable or function something is.

    Code blocks

    All of the code blocks in the text are written and run as julia code (see the next section below). Therefore, you should be able to copy any of the blocks out and paste them directly. The only issue might be for long lines. For example if you have

    If you try to copy and paste the above line, it will give an error until you take out the arrow characters indicating a line wrap and putting it back on a single line. After this, it should run.

    Creating this Text

    I think it’s interesting how this text was created. JuliaCon (which will be discussed later) is an annual conference on julia. In 2019, Tim Wheeler gave the talk entitled . I based a lot of this textbook on their work. Here’s some specific details about that:

    There are a couple of reasons for writing it this way and they are related. First, it eliminates errors that often occur by copying and pasting from somewhere where code is run into the document. Secondly,

    • Was this article helpful?