December 26, 2025
We’ll be making heavy use of the Jupyter Notebook environment via Google Colab in this course.
I like to think of these notebooks as permitting us to mix three things.
Today’s discussion will focus on typesettng with \(\LaTeX\) but will also give us one more opportunity to gain comfort with all three of these before we move into our Numerical Methods course content.
\(\bigstar\) You shouldn’t expect to feel fully confident, especially in using Python, after working through this content. Please know that I don’t expect that from you either. You’ll continue to gain comfort as we move through the semester – please ask for help when you need it. Slack is great for that! \(\bigstar\)
Navigate to your Google Drive and open a new Colab notebook.
You can write anything you like in text cells.
Shift+Enter.Text cells are the least frustrating component of the notebook environment because they “just work” no matter what you’ve written in them.
Disclaimer. Adding \(\LaTeX\) or images can complicate this a bit.
Code cells are where you can write and execute Python\(^*\) code.
To execute your code cell, you can use Shift+Enter.
If/when you write broken code, an error traceback will be printed out below the code cell.
The most informative portion of the traceback is generally the last line.
Colab will generally underline the offending section(s) of code in red.
It is important to note that code cells are generally “aware” of modules, variables, methods, routines, etc. that have been created as part of previous code cells, but not of objects created in later code cells.
Restarting your session (Runtime -> Restart Session) and then running your notebook from the top down every once in a while will keep you aware of any upstream/downstream issues you have.
We’ll often have the need to type mathematics as part of our explanations/solutions.
\(\bigstar\) For now, you should know that mathematics goes between dollar signs ($).
We’ll start today’s discussion with an overview of \(\LaTeX\) since we’ve seen both text and code cells previously.
Note. If you haven’t used \(\LaTeX\) before, then what appears below is new and perhaps overwhelming. I’d like you to type up the mathematics for our course, but you’ll be able to collaborate with your favorite language model to obtain \(\LaTeX\) commands if necessary.
\(\LaTeX\) is a very commonly used markup language in mathematics and the sciences – it is how we’ll format mathematics. We’ll begin to get familiar with \(\LaTeX\) below.
Inside of notebook environments, you can write \(\LaTeX\) in any text cell.
The following slides contain some tasks to help you gain familiarity.
Task 1: Put a dollar sign before and after the function f(x) = x^2 - 4 in this markdown cell to format the mathematics correctly.
Task 2: We’ll sometimes want to utilize fractions, we can do this using . Add the required dollar signs to format the rational function r(x) = (x + 3)/(x - 5)} as math type. Use \frac{}{} to further format the function.
Here’s an example of some steps to solve the equation \(2x - 8 = 14\).
\[\begin{align} 2x - 8 &= 14\\ \implies 2x &= 22\\ \implies x &= 11 \end{align}\]
In the aligned environment, the characters to the right of the ampersand (&) are vertically aligned with one another.
Expectation. You’ll sometimes find use for aligned equations as you are showing steps in solving problems. In these cases, you’ll likely copy an aligned environment that I’ve constructed, paste it into your notebook, and then edit it to fit your context.
Task 3: Try typing your own step-by-step solution to the \(\frac{3x - 5}{4} = 10\).
We’ll be working with systems of equations, matrices, and vectors often in this course.
For example, the system \(\left\{\begin{array}{rcr} 2x_1 + 3x_2 + 8x_3 & = & 0\\ -4x_1 + x_2 - 2x_3 & = & 0\end{array}\right.\) corresponds to the coefficient matrix \(\left[\begin{array}{rrr} 2 & 3 & 8\\ -4 & 1 & -2\end{array}\right]\) and constant vector \(\left[\begin{array}{r} 0\\ 0\end{array}\right]\).
Expectation. While we’ll find use for these objects often, you’ll likely copy/paste an old system/matrix/vector and edit it for your needs rather than creating it from scratch.
\left bracket must have a corresponding \right bracket (if you don’t want the right bracket to show up, then you can just use a period, like \right.).The array environment allows you to construct aligned columns.
\begin{array}.r character indicates that a column should be right-aligned, while the c and l characters indicated center- and left-alignment, respectively.&).\\)\left bracket must have a corresponding \right bracket (if you don’t want the right bracket to show up, then you can just use a period, like \right.).Task 4: Define a \(5\times 4\) matrix below, use any entries you like.
The array environment allows you to construct aligned columns.
\begin{array}.r character indicates that a column should be right-aligned, while the c and l characters indicated center- and left-alignment, respectively.&).\\)Over the past few class meetings, we’ve gotten more familiar with the Google Colab notebook environment, writing some Python, and now formatting mathematics using \(\LaTeX\). In this final task, we’ll try to put things together.
Task 5: Build a mathematical function that you find interesting.
np.linspace() to create an array of input values for your function. Use your Python routine to evaluate your function for these input values.matplotlib.pyplot() to draw a plot of your function.Hint. Look back to our Day 3 notebook or slides for help.
Task 6: Look up the Collatz Conjecture. Use \(\LaTeX\) to type out the mathematical definition of the sequence involved in the conjecture. Build a Python routine to construct the Collatz Sequence for a given non-negative integer input and plot the results.
Our journey into Numerical Methods begins.
We’ll start by revisiting linear algebra and solving linear systems via Gaussian Elimination.