Class Log#

Wed 3 Dec 2025#

Project Checklist:

  • Hosted on GitLab (please confirm with me the project you want me to review.)

  • Serious attempt to write some code.

  • Tests with > 85% code coverage.

  • Documentation hosted on GitLab Pages (i.e. using the .gitlab-ci.yml file I provided).

  • README.md file that explains how to get started (i.e. how to install your code, run your tests etc.)

  • Automated CI running of your tests which you push with CI in your commit message.

    This is new: please try to add a target to .gitlab-ci.yml that will automatically run your tests.

Please have a complete project for me to review by Wed 10 December. I will give comments and then do my final review on Sunday 14 December.

Mon 1 Dec 2025#

Mon 17 Nov 2025#

Work through Fitting: Model Selection

Mon 27 Oct 2025#

  • GitLab Pages. CI.

  • Optimization - Gradient Descent. *

Mon 20 Oct 2025#

Wed 15 Oct 2025#

Mon 13 Oct 2025#

Wed 8 Oct 2025#

Work through Solving The Schrödinger Equation following the notes sec:SEQNotes.

  • By the end of class, everyone should have their own version of this project, as well as a fork of the official “class” version.

Mon 6 Oct 2025#

Wed 1 Oct 2025#

  • Classes in Python.

    class A:
        p = 2
        def pow(self, x):
            return x**self.p
    a = A()
    a.pow(x=3) == A.pow(self=a, x=3)
    

    Can you explain this?

    class A:
        p = 2
        def pow(self, x):
            return x**self.p
    a = A()
    a.pow(x=3) == 9
    A.p = 3
    a.pow(x=3) == 27
    
    a = A()
    a.p = 3
    a.pow(x=3) == 27
    
    a = A()
    a.p = 1
    A.p = 3
    a.pow(x=3) == 3
    
  • Introduction to the FFT as a way to compute derivatives. Please read Fourier Techniques.

Mon 29 Sept 2025#

Wed 24 Sept 2025#

We continued discussion about the Schrödinger equation, and I showed how to make interactive plots with ipywidgets and animations using display phys_581.contexts.FPS.

Mon 22 Sept 2025#

We started by integrating \(y' = \mu y\) with \(y(0) = 1\) for \(\mu = -20.0\) using Euler’s method from \(x=0\) to \(x=1\). Following the example from §8.2 of [Gezerlis, 2023], we demonstrated that for \(N\leq 9\) points, the method is unstable leading to exponential growth. We then showed that this could be remedied by backwards Euler.

For more details see Ordinary Differential Equations (ODEs).

We then went through how to compute \(\op{H}\ket{\psi}\) for a 1D harmonic oscillator using finite differences. For more details, see Time-Dependent Schrödinger Equation and Derivatives.

Wed 17 Sept 2025#

Mon 15 Sept 2025#

Walk-through using Git, GitLab, etc. with Richardson Extrapolation example.

  • Make sure you have conda, mamba, or micromamba

mkdir Physics-581-tools
git init
pixi init
pixi add python==3.12 pytest numpy pytest-cov
git add .
git commit -m "Initial commit with pixi files"
mkdir -p src/phys_581_tools
mkdir tests
pixi shell

Wed 10 Sept 2025#

  • Globally Convergent Newton’s Method for LambertW.

  • Overview of Git, the Shell, etc.

  • Create GitLab project.

    • Start with Git, move to Jujutsu.

  • Create project *

Mon 8 Sept 2025#

  • Review sections from Pragmatic Programmer.

  • Review code progress.

    • Showed how one might accelerate series acceleration.

    • Discussed Newton’s method.

Wed 3 Sept 2025#

Wed 26 Aug 2025#

  • Insertion sort: \(S(N) = N + 2S(N/2)\), \(S(1) = 1\). Show that \(S(N) = N\log_{2}(2N)\). General asymptotic properties of recursive algorithms can be found using the Master theorem.

  • Fibonacci: \(F_{n} = ...\) (perhaps using generating functions?).

  • Mostly let students program Assignment 0: Introduction. Some issues came up.

    • Some students had difficulty with compose(f, n). If they have not been exposed to higher-order functions (and they are not common in some languages), then this is quite new.

    • Some students were over-complicating things, such as trying to write different code for different types. Mentioned duck typing in python. Should mention generics in C++.

Mon 25 Aug 2025#

  • PP2: The Cat Ate My Source Code

  • PP2: Software Entropy

  • PP5: Good-Enough Software

  • Recursion (Fibonacci, Insertion Sort, Invariants). See Recursion and Invariants. As a data-fitting project, fit the model \(t(n) \propto b^n\) for the execution time of the simplest recursive implementation of fib(n) and provide uncertainties on the parameter \(b\). Where does it come from?

  • Heapsort. Implement this using only small tuples: pairs (a, b), triples (a, b, c) (which could be implemented in terms of pairs (a, (b, c))) etc. This is a good problem for an in-person programming interview. (Don’t use AI! These are well studied so there are lots of generic solutions.)

  • CoCalc demo of Fib.

Wed 20 Aug 2025#

Mon 18 Aug 2025#

  • Went over aspects of the Syllabus, including use of LLMs, Textbooks, and the first 2 SLOs.

  • Read PP22: Engineering Daybooks: discussed uses of a daily “experimental” logbook for the purposes of reproducible research, and the reason for writing by hand vs typing. Example of reproducible computing: recording the date and details of the machine on which you ran a simulation might help you reproduce the run in the future if hardware changes – maybe through an emulator.

  • Discussed random number generators and the importance of seeds for reproducible results.

  • Discussed the following abstract data types (ADTs):

    • Sets: A collection of data s with operations s.add(x), s.pop(), and s.contains(x) (the latter is written x in s in Python). We discussed other operations like union(s1, s2), intersection(s1, s2) but argued that these more complex operations can be implemented in terms of the others.

    • Stack: A collection of data s with operations s.put(x), and s.pop() where s.pop() removes and returns the last item pushed onto the stack: last-in-first-out (LIFO) (sometimes called first-in-last-out or FILO).

    • Queue: A collection of data s with operations s.put(x), and s.pop() where s.pop() removes and returns the first item pushed into the queue: first in first out (FIFO).

We discussed how consistency of an ADT can be most easily ensured by basing it on physical reality:

  • A stack represents a pile of items where you can put and take (pop) from only the top.

  • A queue represents a pipe where you can push items in one and take them from the other. We discussed how this can be used for communicating between multiple processes in a thread0safe manner.

    • A deque (double-ended queue) is a related representation of a pipe, where you can add and remove elements from either end (preserving the physical order in the pipe).

Problem#

In class, students were asked to implement a Priority Queue in terms of a Queue with operations q.put(x) and q.pop() where q.pop() returns the largest value in the queue, or a sentinel value if the queue is empty. We assume that the elements can be compared x < y etc.

We discussed that it might be useful to first implement methods like q.empty() which returns True if the queue is empty, and False otherwise, and q.copy() which returns a copy.