Files
plot_mu_trajectories/README.md
T
2026-09-15 22:00:04 +02:00

1.7 KiB

mu-trajectories

Visualize the KKT trajectory of the Euclidean projection of a point x0 onto a 2D quadric x'Ax + b'x + c = 0 (ellipse, hyperbola, parabola, two lines, a line or a point):

x(mu) = (I + mu A)^{-1} (x0 - mu b / 2)

The figure shows the trajectory in the plane, the secular function f(mu), the distance ||x0 - x(mu)|| and f'(mu), together with the KKT points: x(mu*), the other roots of f and, when x0 has a zero normalized coordinate, the degenerate points x^d.

Setup

Create a virtual environment in venv/ (ignored by git) and install the dependencies (tested with Python 3.13):

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Run source venv/bin/activate again in each new shell, and deactivate to leave the environment.

Usage

python plot_mu_trajectories.py                         # every case, into figures/
python plot_mu_trajectories.py x_trajectories_mu_2     # a single case
pytest

Cases (A, x0, and optionally b and c) are listed in CASES at the top of plot_mu_trajectories.py; each one produces <name>.png and <name>.pdf.

Text is typeset with LaTeX (text.usetex) when latex is on the PATH, with the cm-super and type1cm packages; otherwise matplotlib's Computer Modern math font is used.

Files

  • plot_mu_trajectories.py: the figure. The quadric, x(mu), f, f' and the degenerate points come from quadproj; the script adds the roots of f, the asymptotes and the plot limits.
  • test_plot_mu_trajectories.py: checks, for each type of quadric, that the KKT points contain the projection found by brute-force sampling, and that every type can be plotted.