---
title: Quadratic Wiggle Height Minimization
url: https://www.emergentmind.com/topics/quadratic-wiggle-height-minimization
type: topic
---

# Quadratic Wiggle Height Minimization

Quadratic wiggle height minimization denotes a family of quadratic optimization problems in which “wiggle” is penalized by a sum of squared vertical displacements, a curvature energy, or a roughness functional. In ordered storyline visualization, the canonical objective is
\[
\mathrm{QWH}(y)=\sum_{t=1}^{\ell-1}\sum_{c\in \mathcal{A}(t)\cap \mathcal{A}(t+1)} (y_{t+1,c}-y_{t,c})^2,
\]
where \(y_{t,c}\) is the \(y\)-coordinate of character \(c\) at time \(t\) [2508.19802]. In quadratic smoothing, the same idea appears as
\[
f(x)=x^\top A x + b^\top x + c,
\]
with \(A\) chosen to encode curvature or roughness, for example \(A=D^\top D\) for a second-difference operator \(D\) [1806.10626]. In Hilbert-space formulations, a canonical wiggle functional is
\[
\mathrm{Wiggle}(f)=\int_a^b |f''(t)|^2\,dt,
\]
represented by a positive semidefinite operator \(T=(D^2)^*D^2\) [1003.5676]. In stacked area charts, the quadratic objective is the sum of squared border changes over time [2506.21175].

## 1. Formal problem classes

Several mathematically distinct models instantiate the same basic principle: large vertical changes are penalized more heavily than small ones because the penalty is quadratic. In storyline visualization, the decision variables are the layer-wise character coordinates \(y_{t,c}\), constrained by per-layer orderings and spacing rules. In smoothing and regularization, the variables are either vectors \(x\in\mathbb{R}^n\) or functions in a Hilbert space, and the objective is a quadratic form induced by a difference, Laplacian, or derivative operator. In stacked area charts, the optimization variable is typically the ordering \(\pi\), and the quadratic objective is defined on the resulting cumulative borders [2508.19802][1806.10626][1003.5676][2506.21175].

| Setting | Variables | Quadratic wiggle objective |
|---|---|---|
| Storylines | \(y_{t,c}\in\mathbb{R}\) | \(\sum_{t,c}(y_{t+1,c}-y_{t,c})^2\) |
| Discrete smoothing | \(x\in\mathbb{R}^n\) | \(x^\top D^\top D x=\|Dx\|_2^2\) |
| Hilbert-space smoothing | \(f\in H^2([a,b])\) | \(\int_a^b |f''(t)|^2 dt\) |
| Stacked area charts | ordering \(\pi\), borders \(y_i(t)\) | \(\sum_{i,j}(y_i(j+1)-y_i(j))^2\) |

The discrete and continuous versions are closely aligned. A second-difference penalty in \(\mathbb{R}^n\) and the Sobolev-space energy \(\int |f''|^2\) both penalize curvature; the storyline objective \(\sum (y_{t+1,c}-y_{t,c})^2\) penalizes temporal displacement rather than second derivative, but it is likewise a positive semidefinite quadratic objective [1806.10626][1003.5676][2508.19802].

## 2. Ordered storyline formulation

A storyline instance is a 4-tuple \((\mathcal{C},T,\mathcal{M},A)\), where \(\mathcal{C}=\{c_1,\dots,c_n\}\) is the set of characters, \(T=[\ell]=\{1,\dots,\ell\}\) is an ordered set of discrete time steps, \(\mathcal{M}=\{M_1,\dots,M_m\}\) is the set of meetings, and \(A(c)\subseteq[\ell]\) is the set of time steps for which character \(c\) is active. Each active character \(c\) has a coordinate \(y_{t,c}\in\mathbb{R}\) at time \(t\). An ordered storyline instance specifies, for each \(t\), a permutation \(\pi_t\) of the active characters \(\mathcal{A}(t)\), with the requirement that every meeting at time \(t\) appears as a consecutive block in \(\pi_t\). A coordination is valid if \(y_{t,c}<y_{t,c'}\) whenever \(c\prec_t c'\) [2508.19802].

The paper defines \((s,d)\)-nice coordinations by two spacing parameters \(s\ge 0\) and \(d\ge 0\). If two consecutive characters in \(\pi_t\) belong to the same meeting, then \(|y_{t,c'}-y_{t,c}|=s\); otherwise \(|y_{t,c'}-y_{t,c}|\ge d\). With neighbor sets
\[
N(t),\qquad N_{\mathcal M}(t),\qquad N_A(t)=N(t)\setminus N_{\mathcal M}(t),
\]
the full QWHMin model uses variables \(y_{t,c}\in\mathbb{R}\) and the linear constraints
\[
y_{t,c'}-y_{t,c}=s \quad \text{for } (c,c')\in N_{\mathcal M}(t),
\]
\[
y_{t,c'}-y_{t,c}\ge d \quad \text{for } (c,c')\in N_A(t),
\]
optionally together with \(y_{t,c}\ge 0\). The direct quadratic objective is
\[
\text{Minimize } \mathrm{QWH}(y)=\sum_{t=1}^{\ell-1}\sum_{c\in\mathcal{A}(t)\cap\mathcal{A}(t+1)} (y_{t+1,c}-y_{t,c})^2.
\]

This is a convex quadratic program: the objective is a sum of squares, the constraints are linear, and in matrix form the Hessian is block-diagonal with nonnegative diagonal elements, i.e., positive semidefinite. The formulation is explicitly downstream of ordering, because crossing minimization is NP-hard and QWHMin assumes that the permutations \(\pi_t\) are already fixed [2508.19802].

## 3. Solver model, routing geometry, and empirical behavior

For the alignment phase, QWHMin is solved as a continuous convex QP. The implementation described in the paper uses Gurobi (12.0.2); the LP for linear wiggle height minimization (LWHMin) and the ILP for wiggle count minimization (WCMin) use the same coordinate variables, but QWHMin requires no binary variables, and branch-and-bound appears only for WCMin [2508.19802].

After computing the optimal coordinates \(y_{t,c}\), the routing phase replaces each vertical move by two circular arcs with radii \(r'_{t,c}\) and \(r''_{t,c}\) meeting tangentially at a crossover point. Writing
\[
\Delta y_{t,c}:=|y_{t+1,c}-y_{t,c}|
\]
and \(\Delta x_t\) for the horizontal width of transition block \(t\), the exact geometric relation is
\[
\Delta x_t^2 = 2\,(r'_{t,c}+r''_{t,c})\,\Delta y_{t,c}-\Delta y_{t,c}^2.
\]
A curve segment is \(x\)-monotone iff \((r'_{t,c}+r''_{t,c})\ge \Delta y_{t,c}\), equivalently \(\Delta x_t^2\ge \Delta y_{t,c}^2\). For each transition \(t\), the paper solves an LP that minimizes \(\Delta x_t^2\) subject to this relation, lower bounds \(r'_{t,c},r''_{t,c}\ge r_{\min}\), and additional linear constraints that enforce monotone radial distance for neighboring curves running in parallel.

The comparison among objective functions is structurally important. LWHMin minimizes \(\sum |\Delta y|\) and tends to distribute vertical movement more uniformly; QWHMin minimizes \(\sum (\Delta y)^2\) and therefore penalizes large movements more strongly, preferring many small movements over a few big ones; WCMin minimizes the number of nonzero movements and can therefore force some remaining movements to become large. On the reported benchmark instances, LP/QP runtimes were typically \(<0.1\)–\(0.9\)s on most instances, whereas ILP runtimes for WCMin ranged from sub-second to hours and sometimes did not finish within 24 hours. The case study spans novels, blockbusters, publication data, and rolling stock schedules; QWHMin achieved the minimum quadratic wiggle, but the paper notes that with the two-arc rendering style it could increase width and perceived oscillation relative to LWHMin [2508.19802].

## 4. Smoothing, curvature penalties, and constrained formulations

Outside storyline visualization, quadratic wiggle height objectives are standard quadratic roughness penalties. A general unconstrained form is
\[
f(x)=x^\top A x + b^\top x + c,
\]
and a sphere-constrained version is
\[
\min_{\|x\|_2=r}\; x^\top A x + b^\top x + c.
\]
A “wiggle height” penalty can be modeled by choosing \(A\) to encode curvature or roughness. For second-difference smoothing, with second-difference matrix \(D\), one sets \(A=L^\top L\) with \(L=D\), giving
\[
f(x)=x^\top D^\top D x=\|Dx\|_2^2,
\]
which penalizes curvature. For graph-based signals, one may set \(A=L\) or \(A=L^\top L\) with \(L\) a graph Laplacian, thereby penalizing variation across edges [1806.10626].

In Hilbert spaces, the same principle is expressed through positive operators. Let \(H\) be a complex Hilbert space, \(T\in B(H)\) bounded, self-adjoint, and positive semidefinite, and consider the quadratic objective \(\langle x,Tx\rangle=\|T^{1/2}x\|^2\). Under linear constraints \(Sx=y\), the feasible set is \(\{x\in H:Sx=y\}\). If \(T\) is positive semidefinite with closed range, minimization is performed on \(\mathcal N(T)^\perp\), and the minimal-energy minimizer is
\[
x^*=T^+S^*(ST^+S^*)^+y.
\]
For a canonical wiggle functional on \(H^2([a,b])\),
\[
\mathrm{Wiggle}(f)=\int_a^b |f''(t)|^2\,dt,
\]
one sets
\[
T=(D^2)^*D^2.
\]
Then \(\mathcal N(T)\) consists of polynomials of degree \(<2\), so nonuniqueness arises unless the constraints fix that affine space. If \(\mathcal N(T)\cap\{x:Sx=y\}\neq\varnothing\), then the minimum value is \(0\); otherwise the minimizer is unique in \(\mathcal N(T)^\perp\) [1003.5676].

This operator-theoretic view makes clear that quadratic wiggle height minimization is not tied to a single application domain. It includes minimum-curvature interpolation, minimum-variation smoothing on graphs, and discrete trust-region subproblems, all under a common positive-semidefinite quadratic structure [1806.10626][1003.5676].

## 5. Sublinear-time approximation for very large quadratic objectives

When the wiggle objective is encoded as a large quadratic form, one can approximate its minimizer in sublinear time under a random-access model. The input is \(A\in\mathbb{R}^{n\times n}\), \(b\in\mathbb{R}^n\), \(c\in\mathbb{R}\), and the algorithm assumes random access to entries \(A_{ij}\) and \(b_i\), with bounded entries such as \(A\in[-L,L]^{n\times n}\). It samples a random index set \(S\subseteq\{1,\dots,n\}\) by including each index independently with probability \(k/n\), where
\[
k=\max\left\{O\!\left(\frac{\log^2 n}{\epsilon^2}\right),\;\left(\frac{1}{\epsilon}\right)^{O(1/\epsilon^2)}\right\}.
\]
The unconstrained algorithm forms \(A|_S\) and \(b|_S\), solves the sampled quadratic, and optionally lifts the sampled minimizer by zero-padding. The sphere-constrained variant solves the sampled trust-region problem with scaled radius
\[
\tilde r = r\sqrt{\frac{|S|}{n}}.
\]
The query complexity is \(O(k^2)\) for \(A|_S\) and \(O(k)\) for \(b|_S\), and the solve time is polynomial in \(k\), for example \(O(k^3)\) [1806.10626].

The key technical tool is a decomposition
\[
A=B+C,
\]
where \(B\) is block-constant with a polylogarithmic number of blocks and \(C\) has small spectral norm. More precisely, for \(A\in[-L,L]^{n\times m}\), \(N=\sqrt{nm}\), and any \(\gamma\in(0,1)\), the number of blocks in \(B\) is
\[
O\!\left(\left(\frac{1}{\gamma^{10}}\right)^{3/\gamma^2}\right),
\]
and
\[
\|C\|_2\le 7\gamma N L.
\]
This is stronger than the Frieze–Kannan decomposition for the purposes of quadratic minimization, because the analysis needs spectral-norm control rather than cut-norm control. The residual contributes at most
\[
|x^\top Cx|\le \|C\|_2\,\|x\|_2^2,
\]
so the pseudorandom part is small on any vector of bounded norm.

For the unconstrained problem, if \(x^*\) is the full minimizer and \(\hat x_S\) is the sampled minimizer, then with probability at least \(2/3\),
\[
f(\hat x_S)-f(x^*)\le O\!\big(\epsilon L K_2^2 n^2\big),
\qquad
K_2=\max\left\{\frac{\|x^*\|_2}{\sqrt n},\frac{\|\hat x_S\|_2}{\sqrt{|S|}}\right\}.
\]
This improves the Hayashi–Yoshida dependence on \(K_\infty\) by replacing it with \(K_2\), with \(K_2\le K_\infty\). For the sphere-constrained problem, if \(z^*\) is the full optimum and \(\tilde z^*\) the sampled optimum, then with probability at least \(2/3\),
\[
\left|\frac{\tilde z^*}{|S|^2}-\frac{z^*}{n^2}\right|\le \frac{Lr^2}{n}.
\]
The same paper also gives a sublinear-time approximation algorithm for computing top singular values, connecting the wiggle-minimization setting to Rayleigh-quotient computations [1806.10626].

## 6. Complexity landscape and related discrete variants

The computational status of quadratic wiggle objectives depends sharply on which variables remain free. In ordered storylines, the combinatorial ordering has already been fixed, so both LWHMin and QWHMin are polynomial-time solvable: the former is an LP and the latter is a convex QP. By contrast, wiggle count minimization is NP-complete, and the paper gives a reduction from Planar Monotone 3-SAT. It also identifies a special case in which \(\ell=2\), for which WCMin is polynomial [2508.19802].

In stacked area charts, the discrete quadratic wiggle objective is attached to border changes generated by an ordering \(\pi\). With cumulative borders
\[
y_i(t)=\sum_{k=1}^i \pi(k)(t),
\qquad
W_{i,j}^\pi = y_i(j+1)-y_i(j),
\]
the unweighted quadratic objective is
\[
W_{\mathrm{quad}}^\Delta
=
\sum_{i=1}^n \sum_{j=1}^{\ell-1} (y_i(j+1)-y_i(j))^2.
\]
The weighted version is
\[
W_{\mathrm{quad,weighted}}^\Delta
=
\sum_{i=1}^n \sum_{j=1}^{\ell-1}
\frac{\pi(i)(j)+\pi(i)(j+1)+\pi(i+1)(j)+\pi(i+1)(j+1)}{4}
\,(y_i(j+1)-y_i(j))^2.
\]
For arbitrary \(p\ge 1\), including \(p=2\), both \(p\)-WiggleMin and Weighted-\(p\)-WiggleMin are strongly NP-complete. The paper further states that there is no PTAS unless a subexponential-time algorithm for SAT exists, and no constant-factor approximation under the Small-Set Expansion Hypothesis. An exact MILP is given for the weighted \(L_1\) objective, and replacing the linear objective by squared absolute-border-change terms yields an exact MIQP for Weighted-2-WiggleMin [2506.21175].

A recurring pattern therefore separates combinatorial and continuous difficulty. Once the vertical order is fixed, quadratic wiggle height minimization often reduces to convex quadratic programming; when the order itself must be optimized, strong NP-hardness can reappear even for the quadratic \(L_2\) objective. This suggests that in visualization applications the dominant difficulty often lies in layer ordering, while the coordinate-assignment phase remains tractable and structurally quadratic [2508.19802][2506.21175].

Source: https://www.emergentmind.com/topics/quadratic-wiggle-height-minimization