Lab 1: Hello, Julia
This lab sets up the software for the course and runs through the weekly workflow once. The exercises use Claude Code to turn a mystery plot into an equation, then restyle the figure.
Like every lab in this course, it is ungraded, ships pre-filled and working, and is due before the Wednesday session, where we work through what broke. After this week, the Software Reference is the page to keep open.
Why Julia
This course uses Julia. Alan Edelman explains why better than we can, in MIT’s Introduction to Computational Thinking. His essay, in full:
Superficially, many programming languages are very similar. “Showoffs” will compare functional programming vs imperative programming. Others will compare compiled languages vs dynamic languages. I will avoid such fancy terms in this little essay, preferring to provide this course’s pedagogical viewpoint.
Generally speaking beginning programmers should learn to create “arrays” write “for loops”, “conditionals”, “comparisons”, express mathematical formulas, etc. So why Julia at a time when Python seems to be the language of teaching, and Java and C++ so prominent in the corporate world?
As you might imagine, we believe Julia is special. Oh you will still have the nitty gritty of when to use a bracket and a comma. You might have strong opinions as to whether arrays should begin with 0 or 1 (joke: some say it’s time to compromise and use ½.) Getting past these irrelevant issues, you will begin to experience one by one what makes Julia so very special. For starters, a language that runs fast is more fun. We can have you try things that would just be so slow in other languages it would be boring. We also think you will start to notice how natural Julia is, how it feels like the mathematics, and how flexible it can be.
Getting to see the true value of fancy terms like multiple dispatch, strong typing, generic programming, and composable software will take a little longer, but stick with us, and you too will see why Julia is so very special.
Setup
You install these tools once and use them all semester. Budget 30 to 60 minutes. If you get stuck, note where you stopped and we will troubleshoot in the Wednesday session.
GitHub account
Create a free account at github.com if you do not have one. Use your Rice email so you qualify for the Student Developer Pack. Labs are distributed through GitHub Classroom, so you need an account before you can get this lab.
Julia
Install Julia with juliaup. It manages Julia versions and makes later upgrades easy.
On Windows, open PowerShell and run:
On macOS or Linux, open a terminal and run:
Then pin the version this course uses:
To verify, open a new terminal and run julia --version. You should see julia version 1.12.x.
Quarto
Install Quarto from the Get Started page. Quarto includes Typst, so you do not need to install anything else for PDFs. To verify, run quarto check.
Editor and extensions
Install a code editor: VSCodium is suggested, and VS Code works identically. Other editors can work, but you are on your own for support.
Then install two extensions from the Extensions pane (Cmd+Shift+X / Ctrl+Shift+X): Julia (by julialang) and Quarto. VSCodium installs them from Open VSX instead of the Microsoft marketplace; the extensions are the same. The Julia extension provides the REPL and plot pane, and the Quarto extension provides the Run Cell buttons.
Claude Code
Install Claude Code with the setup instructions. Then run claude in a terminal and log in. The exercises below and the Wednesday working sessions use it, per the AI policy.
Optional: GitHub Desktop
GitHub Desktop is a visual interface for cloning repositories and reviewing what changed before you commit. It is optional because Claude Code can run git for you, but many people like to see their changes visually.
Optional: JuliaMono
The JuliaMono font renders Julia’s Unicode operators cleanly in the editor and REPL.
Get this lab and verify everything
Accept the Lab 1 GitHub Classroom assignment linked from Canvas. This creates your personal copy of this repository. Clone it with GitHub Desktop or git clone.
Do not put the cloned folder inside OneDrive, Google Drive, iCloud, or any other synced folder. Sync services corrupt Git repositories. A folder like ~/CEVE-543/ works well.
Open the lab folder in your editor (File > Open Folder), open a terminal there, and run:
The first command installs the packages this lab needs, and the second executes the whole notebook. If the render finishes without errors, your setup works end to end.
A mystery field
The cell below loads the plotting package for this lab.
The next cell computes a two-dimensional field and plots it two ways: a filled map of the whole field, and a slice through it along the horizontal axis. Run it and look at the result before reading further.
xs = range(-8, 8; length=500)
ys = range(-8, 8; length=500)
centers = [(-2.5, 0.0), (2.5, 0.0)]
k = 2.5
function field(x, y)
return sum(
sin(k * hypot(x - cx, y - cy)) / (1 + hypot(x - cx, y - cy)) for (cx, cy) in centers
)
end
Z = [field(x, y) for x in xs, y in ys]
fig = Figure(; size=(1000, 420))
ax_map = Axis(fig[1, 1]; xlabel=L"x", ylabel=L"y", title=L"z(x, y)", aspect=DataAspect())
hm = heatmap!(ax_map, xs, ys, Z; colormap=:balance)
contour!(ax_map, xs, ys, Z; levels=12, color=(:black, 0.25))
Colorbar(fig[1, 2], hm)
ax_slice = Axis(fig[1, 3]; xlabel=L"x", ylabel=L"z(x, 0)", title=L"y = 0")
lines!(ax_slice, xs, [field(x, 0.0) for x in xs]; linewidth=2)
figExercises
Do both exercises with Claude Code, started from inside this lab’s folder. The AI policy explains how this course approaches these tools.
Decode the plot
Work with Claude to figure out what mathematical function the code plots, then write it as an equation.
- Ask Claude to read the plotting cell and explain, line by line, what
field(x, y)computes. - Write the equation in LaTeX display math, replacing the placeholder below. Define every symbol you use, including the distance to each center.
- Check the equation against the code: pick a point, evaluate your equation by hand or in the REPL, and compare it with
field(1.0, 2.0). If they disagree, figure out whether the error is in your equation or in Claude’s explanation.
Replace this sentence with your equation and the definitions of its symbols.
Restyle the plot
Update the figure’s aesthetics and layout. Make at least three changes. Some ideas:
- A different colormap, and a label on the colorbar.
- A new layout, such as the slice below the map instead of beside it.
- Different figure size, fonts, axis labels, or titles.
- An extra element: more contour levels, a marker on the slice showing the centers, or a third entry in
centers.
Ask Claude for the changes if you like, but read what it edits and re-run the cell after each change. Keep the version you find clearest, and be ready to say why.
Before Wednesday
Push your work to GitHub, with GitHub Desktop or by asking Claude to commit and push. Bring notes on what broke, what Claude got wrong, and what you had to fix by hand; we will work through them on Wednesday.