{\mathbf{b}}egin{document}

\title{Spectral Hypergraph Sparsifiers of Nearly Linear Size}

{\mathbf{b}}egin{abstract}

Graph sparsification has been studied extensively over the past two decades,

culminating in spectral sparsifiers of optimal size (up to constant factors).
Spectral hypergraph sparsification is a natural analogue of this problem,
for which optimal bounds on the sparsifier size are not known,
mainly because the hypergraph Laplacian is non-linear,
and thus lacks the linear-algebraic structure and tools
that have been so effective for graphs.

Our main contribution is the first algorithm for constructing ${\mathbf{e}}psilon$-spectral sparsifiers for hypergraphs with $O^*(n)$ hyperedges,
where $O^*$ suppresses $({\mathbf{e}}psilon^{-1} \log n)^{O(1)}$ factors.
This bound is independent of the rank $r$ (maximum cardinality of a hyperedge), and is essentially best possible due to a recent bit complexity lower bound of $\Omega(nr)$ for hypergraph sparsification.

This result is obtained by introducing two new tools.
First, we give a new proof of spectral concentration bounds for sparsifiers of graphs;
it avoids linear-algebraic methods,
replacing e.g.~the usual application of the matrix Bernstein inequality
and therefore applies to the (non-linear) hypergraph setting. To achieve the result, we design a new sequence of hypergraph-dependent ${\mathbf{e}}psilon$-nets on the unit sphere in $\mathbb{R}^n$.
Second, we extend the weight-assignment technique of Chen, Khanna and Nagda [FOCS'20] to the spectral sparsification setting. Surprisingly, the number of spanning trees after the weight assignment can serve as a potential function guiding the reweighting process in the spectral setting.

{\mathbf{e}}nd{abstract}

{\mathbf{t}}hispagestyle{empty}

{\mathbf{t}}hispagestyle{empty}
{\mathbf{t}}ableofcontents
{\mathbf{s}}etcounter{page}{0}

{\mathbf{s}}ection{Introduction}\label{sec:intro}
We study spectral sparsification of hypergraphs, where the goal is to reduce the size of a hypergraph while preserving its energy.
Given a hypergraph $H=(V,E,w)$ with a weight function $w:E {\mathbf{t}}o \mathbb{R}_+$ over its hyperedges, the {\mathbf{e}}mph{energy} of $x\in\mathbb{R}^V$ (called a potential vector) is defined as
\[
  Q_H(x) := {\mathbf{s}}um_{e \in E}w(e){\mathbf{c}}dot \max_{u,v \in e}{(x_u - x_v)}^2.
\]

The problem of minimizing $Q_H(x)$ over $x\in \mathbb{R}^V$ subject to certain constraints appears in many problems involving hypergraphs, including clustering~{\mathbf{c}}ite{Takai2020}, semi-supervised learning~{\mathbf{c}}ite{Hein2013,Yadati2019,Zhang2020} and link prediction~{\mathbf{c}}ite{Yadati2020}, from which we can see the relevance of $Q_H(x)$ in application domains. Note that when $x\in\mathbb{R}^V$ is a characteristic vector $\mathbbm{1}_S \in \{0,1\}^V$ of a vertex subset $S {\mathbf{s}}ubset V$, the energy $Q_H(\mathbbm{1}_S)$ coincides with the total weight of hyperedges cut by $S$, where we say that a hyperedge $e \in E$ is {\mathbf{e}}mph{cut} by $S$ if  $e {\mathbf{c}}ap S\neq {\mathbf{e}}mptyset$ and $e {\mathbf{c}}ap (V {\mathbf{s}}etminus S) \neq {\mathbf{e}}mptyset$. 

Since the number of hyperedges in a hypergraph of $n$ vertices can be $\Omega(2^n)$, it is desirable to reduce the number of hyperedges in the hypergraph while (approximately) preserving the value of $Q_H(x)$ for every $x \in \mathbb{R}^V$, because this lets us speed up any algorithm involving $Q_H$  and reduce its memory usage by running it on the smaller hypergraph instead of $H$ itself.
Soma and Yoshida~{\mathbf{c}}ite{Soma2019} formalized this concept as spectral sparsification for hypergraphs -- a natural generalization of the corresponding concept introduced by the celebrated work of~{\mathbf{c}}ite{Spielman2011} for graphs.
Specifically, for $0<{\mathbf{e}}psilon<1$, we say that a hypergraph $zidetilde{H}$ is an {\mathbf{e}}mph{${\mathbf{e}}psilon$-spectral-sparsifier} of a hypergraph $H$ if $zidetilde{H}$ is a reweighted subgraph of $H$ such that
{\mathbf{b}}egin{equation} \label{eq:HypergraphSparsifier}
  {\mathbf{f}}orall x \in \mathbb{R}^V,
  {\mathbf{q}}quad
  Q_{zidetilde{H}}(x) \in (1{\mathbf{p}}m{\mathbf{e}}psilon) Q_H(x).{\mathbf{f}}ootnote{$a \in (1 {\mathbf{p}}m {\mathbf{e}}psilon)b$ is a shorthand for $(1-{\mathbf{e}}psilon)b \leq a \leq (1+{\mathbf{e}}psilon)b$.}
{\mathbf{e}}nd{equation}
We note that when $H$ is an ordinary graph, this definition matches that for graphs~{\mathbf{c}}ite{Spielman2011}.
Soma and Yoshida~{\mathbf{c}}ite{Soma2019} showed that every hypergraph $H$ admits an ${\mathbf{e}}psilon$-spectral-sparsifier with $zidetilde{O}(n^3/{\mathbf{e}}psilon^2)$ hyperedges,
{\mathbf{f}}ootnote{Throughout, $zidetilde{O}({\mathbf{c}}dot)$ suppresses a factor of $\log^{O(1)} n$.}
and gave a polynomial-time algorithm for constructing such sparsifiers.
Since then the number of hyperedges needed has been reduced to $zidetilde{O}(nr^3/{\mathbf{e}}psilon^2)$~{\mathbf{c}}ite{Bansal2019},
and recently to $zidetilde{O}(nr/{\mathbf{e}}psilon^{O(1)})$~{\mathbf{c}}ite{KKTY21},
where $r$ is the maximum size of a hyperedge in the input hypergraph $H$ (called the {\mathbf{e}}mph{rank} of $H$).

The natural question whether every hypergraph admits a spectral sparsifier
with $zidetilde{O}(n)$ hyperedges (for fixed ${\mathbf{e}}psilon$) has proved to be challenging.
On the one hand, it is well-known that
a hypergraph is a strictly richer object than an ordinary graph
(hyperedges cannot be ``simulated'' by edges, even approximately),
and in all previous results and techniques,
this extra complication introduced an extra factor of at least $r$. 
On the other hand, an exciting recent result~{\mathbf{c}}ite{Chen2020}
has achieved sparsifiers with $zidetilde{O}(n)$ hyperedges,
if one is only interested in preserving the {\mathbf{e}}mph{hypergraph cut function},
i.e., satisfying~{\mathbf{e}}qref{eq:HypergraphSparsifier}
only for all characteristic vectors $x=\mathbbm{1}_S$ where $S {\mathbf{s}}ubseteq V$.
Nevertheless, the spectral version of this question has remained open,
primarily due to the non-linearity of the hypergraph Laplacian
and the lack of linear-algebraic tools that have been so effective for graphs.

We settle this question by showing that a nearly linear number of hyperedges
suffices. 

{\mathbf{b}}egin{restatable}{thm}{thmmain}\label{thm:main}
  For every hypergraph with $n$ vertices and every $1/n\le{\mathbf{e}}psilon\le1/2$, there exists an ${\mathbf{e}}psilon$-spectral-sparsifier with $O(n{\mathbf{e}}psilon^{-4}\log^3 n)$ hyperedges.

  Moreover, one can construct such a sparsifier in time $zidetilde{O}(mr + {\mathbf{p}}oly{n})$, where $m$ is the number of hyperedges and $r$ is the maximum size of a hyperedge in $H$.
{\mathbf{e}}nd{restatable}

We note that the bit complexity of our sparsifier is tight up to a polylogarithmic factor for a large range of $r$ due to the lower bound of~{\mathbf{c}}ite{KKTY21}.
\if 0 To see this, let $zidetilde{H}=(V,zidetilde{E},zidetilde{w})$ be the ${\mathbf{e}}psilon$-spectral sparsifier of an unweighted hypergraph $H$ with $zidetilde{O}(n/{\mathbf{e}}psilon^{O(1)})$ hyperedges, whose existence is guaranteed by Theorem~\ref{thm:main}. Every hyperedge contains at most $r$ vertices, and therefore can be stored using $zidetilde{O}(r)$ bits. As we now show, the weights of hyperedges in the sparsifier can also be encoded compactly. 
First, we can assume $zidetilde{w}(e) = O(m)$ for every $e\in zidetilde{E}$ because the maximum cut size is $O(m)$ (and hence if $zidetilde{w}(e) = \omega(m)$, then $zidetilde{H}$ will not satisfy~{\mathbf{e}}qref{eq:HypergraphSparsifier} for some characteristic vector $\mathbbm{1}_S$).
For each $e \in zidetilde{E}$, set $w'(e)$ the value obtained by rounding $zidetilde{w}(e)$ to a nearest power of $1+{\mathbf{e}}psilon$. The corresponding hypergraph $H' = (V,zidetilde{E},w')$ is 
an $O({\mathbf{e}}psilon)$-spectral sparsifier of $H$ with $zidetilde{O}(n/{\mathbf{e}}psilon^{O(1)})$ hyperedges, and the weight of every edge can be encoded using $O(\log \log_{1+{\mathbf{e}}psilon}m) = O(\log ({\mathbf{e}}psilon^{-1}\log m)) = O(\log n + \log (1/{\mathbf{e}}psilon))$ bits. Thus, the sparsifier can be represented using $zidetilde{O}(r  + \log (1/{\mathbf{e}}psilon))$ bits per edge, and $|zidetilde{E}| {\mathbf{c}}dot zidetilde{O}(r + \log (1/{\mathbf{e}}psilon) ) = zidetilde{O}(nr /{\mathbf{e}}psilon^{O(1)})$ bits overall, matching the lower bound of~{\mathbf{c}}ite{KKTY21} for $r=n^{O(1/\log\log n)}$ for small constant ${\mathbf{e}}psilon > 0$.{\mathbf{f}}i

{\mathbf{s}}ubsection{Additional Related Work}

Recall that we call $zidetilde{H} = (V, zidetilde{E}, zidetilde{w})$ an {\mathbf{e}}mph{${\mathbf{e}}psilon$-cut sparsifier} of $H = (V, E, w)$ if every cut weight is preserved to within a factor of $1 {\mathbf{p}}m {\mathbf{e}}psilon$. 
This definition matches the one for ordinary graphs introduced by Bencz{\'{u}}r and Karger~{\mathbf{c}}ite{Benczur2015}, who showed that every graph has an ${\mathbf{e}}psilon$-cut-sparsifier with $O(n\log n/{\mathbf{e}}psilon^2)$ edges, where $n$ is the number of vertices.
For hypergraphs, Kogan and Krauthgamer~{\mathbf{c}}ite{Kogan2015} gave the first construction of non-trivial cut sparsifiers, which uses $O(n(r + \log n)/{\mathbf{e}}psilon^2)$ hyperedges, where $r$ is the maximum size of a hyperedge.
They also mentioned that the results of Newman and Rabinovich~{\mathbf{c}}ite{Newman2013} implicitly give an ${\mathbf{e}}psilon$-cut sparsifier with $O(n^2/{\mathbf{e}}psilon^2)$ hyperedges.
Chen, Khanna, and Nagda~{\mathbf{c}}ite{Chen2020} improved this bound to $O(n \log n/{\mathbf{e}}psilon^2)$, which is almost tight because one needs $\Omega(n/{\mathbf{e}}psilon^2)$ edges even for ordinary graphs~{\mathbf{c}}ite{ACKQWZ16,CKST19}.

Spielman and Teng~{\mathbf{c}}ite{Spielman2011} introduced the notion of a spectral sparsifier for ordinary graphs and showed that every graph on $n$ vertices admits an ${\mathbf{e}}psilon$-spectral sparsifier with $O(n\log^{O(1)} n/{\mathbf{e}}psilon^2)$ edges.
This bound was later improved to $O(n/{\mathbf{e}}psilon^2)$~{\mathbf{c}}ite{BatsonSS12}, which is tight~{\mathbf{c}}ite{ACKQWZ16,CKST19}.
The literature on graph sparsification is too vast to cover here,
including~{\mathbf{c}}ite{Spielman2011,Spielman2011a,BatsonSS12,ZhuLO15,LeeS15a,Lee017} and many other constructions,
and we refer the reader to the surveys~{\mathbf{c}}ite{Vishnoi2013,Teng2016}.

For an ordinary graph $G = (V, E, w)$, the {\mathbf{e}}mph{Laplacian} of $G$ is the matrix $L_G = D_G - A_G$, where $D_G \in \mathbb{R}^{V {\mathbf{t}}imes V}$ is the diagonal (weighted) degree matrix and $A_G \in \mathbb{R}^{V {\mathbf{t}}imes V}$ is the adjacency matrix of $G$.
Then, the energy $Q_G$, defined in~{\mathbf{e}}qref{eq:HypergraphSparsifier}, can be written also as
\[
  Q_G(x) = x^{\mathbf{t}}op L_G x.
\]
For a hypergraph $H = (V, E, w)$, it is known that we can define a (multi-valued) Laplacian operator $L_H : \mathbb{R}^V {\mathbf{t}}o 2^{\mathbb{R}^V}$, so that
\[
  Q_H(x) = x^{\mathbf{t}}op y
\]
for every $x \in \mathbb{R}^V$ and $y \in L_H(x)$~{\mathbf{c}}ite{Louis2015,Chan2018,Yoshida2019} (hence we can write $Q_H(x)$ also as $x^{\mathbf{t}}op L_H(x)$ without ambiguity).
Although the Laplacian operator $L_H$ is no longer a linear operator, its mathematical property has been actively investigated~{\mathbf{c}}ite{ikeda2019finding,fujii2018polynomialtime,ikeda2021coarse} through the theory of monotone operators and evolution equations~{\mathbf{c}}ite{komura1967nonlinear,miyadera1992nonlinear}.

Yoshida~{\mathbf{c}}ite{Yoshida2016} proposed a Laplacian operator for directed graphs and used it to study structures of real-world networks.
The Laplacian operators for graphs, hypergraphs, and directed graphs mentioned above were later unified and generalized as Laplacian operator for submodular transformations/submodular hypergraphs~{\mathbf{c}}ite{Li2018,Yoshida2019}.

{\mathbf{s}}ection{Preliminaries}\label{sec:prelims}
\iffalse
{\mathbf{b}}egin{align*}
\mathnormal{w} \\
\mathrm{w} \\
\mathit{w} \\
\mathbf{w} \\
\mathsf{w} \\
\mathtt{w}
{\mathbf{e}}nd{align*}
{\mathbf{f}}i

In this paper, we deal with spectral sparsification of hypergraphs. For the sake of generality, we consider weighted hypergraphs denoted $H=(V,E,w)$, where $V$ is the vertex set of size $n$, $E$ is the hyperedge set of size $m$, and $w:E{\mathbf{t}}o\mathbb R_+$ is the set of hyperedge weights.
We will also, however, deal with ordinary graphs, that is graphs where each edge contains two vertices exactly. In order to distinguish clearly between graphs and hypergraphs, we will typically denote graphs as $G=(V,F,z)$, where $V$ is the vertex set, $F$ is the edge set, and $z:F{\mathbf{t}}o\mathbb R_+$ is the set of edge weights. In general we will use $f$ and $g$ to denote ordinary edges, while reserving $e$ to denote hyperedges.

For simplicity {\mathbf{e}}mph{all graphs and hypergraphs we consider in this paper will be connected}.

{\mathbf{s}}ubsection{Spectral Graph Theory}

{\mathbf{b}}egin{definition}\label{def:Laplacian}
	The Laplacian of a weighted graph $G=(V,F,z)$ is defined as the matrix $L_G\in\mathbb R^{V{\mathbf{t}}imes V}$ such that
	$$\left(L_G\right)_{uv}={\mathbf{b}}egin{cases}
		d(u)&{\mathbf{t}}ext{if $u=v$,}\\
		-z(u,v)&{\mathbf{t}}ext{if $(u,v)\in F$,}\\
		0&{\mathbf{t}}ext{otherwise.}
		{\mathbf{e}}nd{cases}$$
	Here $d(u)$ denotes the weighted degree of $u$, that is the sum of all weights of incident edges.
	Thus $L_G$ is a positive semidefinite matrix, and its quadratic form can be written as
	$$x^{\mathbf{t}}op L_G x={\mathbf{s}}um_{(u,v)\in F}z(u,v){\mathbf{c}}dot(x_u-x_v)^2.$$
{\mathbf{e}}nd{definition}
The spectral sparsifier of $G$ is defined as a reweighted subgraph which closely approximates the quadratic form of the Laplacian on every possible vector.

{\mathbf{b}}egin{definition}\label{def:sparsifier}
	Let $G=(V,F,z)$ be a weighted ordinary graph. Let $zidetilde G=(V,zidetilde F,zidetilde{z})$ be a reweighted subgraph of $G$, defined by $zidetilde{z}:F{\mathbf{t}}o\mathbb R_+$, where $zidetilde F=\{f\in F \mid zidetilde{z}(f)>0\}$. For ${\mathbf{e}}psilon>0$, $zidetilde G$ is an ${\mathbf{e}}psilon$-spectral sparsifier of $G$ if for every $x\in\mathbb R^V$

	$$x^{\mathbf{t}}op L_{zidetilde G}x \in (1 {\mathbf{p}}m {\mathbf{e}}psilon){\mathbf{c}}dot x^{\mathbf{t}}op L_G x.$$
{\mathbf{e}}nd{definition}

The quadratic form of the graph Laplacian from Definition~\ref{def:Laplacian} can be generalized to hypergraphs. Although this generalization is highly non-linear, we still refer to it as the ``quadratic form'' of the hypergraph.

{\mathbf{b}}egin{definition}
	The quadratic form (or sometimes {\mathbf{e}}mph{energy}) of a hypergraph $H=(V,E,w)$ is defined on the input vector $x\in\mathbb R^V$ as
	$$Q_H(x)={\mathbf{s}}um_{e\in E}w(e){\mathbf{c}}dot\max_{u,v\in e}(x_u-x_v)^2.$$

{\mathbf{e}}nd{definition}

Consequently, we may also define the concept of spectral sparsification in hypergraphs, analogously to Definition~\ref{def:sparsifier}:

{\mathbf{b}}egin{definition}\label{def:hyper-sparsifier}
	Let $H=(V,E,w)$ be a weighted hypergraph. Let $zidetilde H=(V,zidetilde E,zidetilde{w})$ be a reweighted subgraph of $H$, defined by $zidetilde{w}:E{\mathbf{t}}o\mathbb R_+$, where $zidetilde E=\{e\in E \mid zidetilde{w}(e)>0\}$.
	For ${\mathbf{e}}psilon>0$, $zidetilde H$ is an ${\mathbf{e}}psilon$-spectral sparsifier of $H$ if for every $x\in\mathbb R^V$

	$$Q_{zidetilde H}(x) \in (1 {\mathbf{p}}m {\mathbf{e}}psilon){\mathbf{c}}dot Q_H(x).$$
{\mathbf{e}}nd{definition}

{\mathbf{s}}ubsection{Effective Resistance}

{\mathbf{b}}egin{definition}\label{def:eff-res}
	Let $G=(V,F,z)$ be a weighted ordinary graph. The effective resistance of a pair of vertices $(u,v)$ is defined as
	$$R_G(u,v)=({\mathbf{c}}hi_u-{\mathbf{c}}hi_v)^{\mathbf{t}}op L_G^+({\mathbf{c}}hi_u-{\mathbf{c}}hi_v).$$
	Here ${\mathbf{c}}hi_u\in\mathbb R^V$ is the vector with all zeros, and a single $1$ at the coordinate corresponding to $u$. $L_G^+$ is the Moore-Penrose pseudo-inverse of $L_G$, which is positive semidefinite.

	We may write $R(u,v)$ in cases where $G$ is clear from context.
{\mathbf{e}}nd{definition}

We will often use the notation $R_G(f)=R_G(u,v)$ where $f=(u,v)$ is an edge. It is important to note, however, that effective resistance is a function of the vertex pair, not the edge, and does not depend directly on the weight of $f$.

We now state several well-known and useful facts about effective resistance.

{\mathbf{b}}egin{fact}\label{fact:eff-res}
	The effective resistance of an edge $(u,v)$ is alternatively defined as
	$$R_G(u,v)=\max_{x\in\mathbb R^V}{\mathbf{f}}rac{(x_u-x_v)^2}{x^{\mathbf{t}}op Lx}.$$
{\mathbf{e}}nd{fact}

{\mathbf{b}}egin{fact}\label{fact:eff-res-metric}
	Effective resistance constitutes a metric on $V$.
{\mathbf{e}}nd{fact}

{\mathbf{b}}egin{fact}\label{fact:w-R}
	For any weighted graph $G=(V,F,z)$ and any edge $f\in F$ we have $z(f){\mathbf{c}}dot R_G(f)\le1$, with equality if and only if $f$ is a bridge.
{\mathbf{e}}nd{fact}

{\mathbf{b}}egin{fact}\label{fact:eff-res-sum}
	For any weighted graph $G=(V,F,z)$ we have
	$${\mathbf{s}}um_{f\in F}z(f){\mathbf{c}}dot R_G(f)=n-1.$$
{\mathbf{e}}nd{fact}

{\mathbf{s}}ubsection{Chernoff Bound}

{\mathbf{b}}egin{theorem}[Chernoff bound, see for example~{\mathbf{c}}ite{DBLP:books/daglib/0021015}]\label{thm:chernoff}

Let $Z_1,Z_2,\ldots,Z_k$ be independent random variables in the range $[0,a]$. Furthermore, let ${\mathbf{s}}um Z_i=Z$ and let $\mu\ge\mathbb E(Z)$. Then for any ${\mathbf{d}}elta\in(0,1)$,
$$\mathbb P\left(\left|Z-\mathbb E(Z)\right|\ge{\mathbf{d}}elta\mu\right)\le2{\mathbf{e}}xp\left(-{\mathbf{f}}rac{{\mathbf{d}}elta^2\mu}{3a}\right).$$

{\mathbf{e}}nd{theorem}

{\mathbf{s}}ection{Technical Overview}

{\mathbf{s}}ubsection{Analyzing Ordinary Graphs}

The sparsification of ordinary graphs is a highly studied topic, with several techniques proposed for the construction of spectral sparsifiers throughout the years~{\mathbf{c}}ite{Spielman2011,Spielman2011a,BatsonSS12,ZhuLO15,LeeS15a,Lee017}. However, the analysis of spectral sparsifiers always relies heavily on the linear nature of the graph Laplacian, e.g., using matrix concentration results such as matrix Bernstein~{\mathbf{c}}ite{Tropp2011} or the work of~{\mathbf{c}}ite{RudelsonV07}. This presents a significant problem when attempting to generalize these techniques to the highly non-linear setting of hypergraph spectral sparsification. Indeed, all previous results lose at least a factor of $r$ due to this obstacle. We therefore dedicate the entirety of our first technical section (Section~\ref{sec:warm-up}) to presenting a new proof of the existence of nearly linear spectral sparsifiers for ordinary graphs. We use the algorithm from~{\mathbf{c}}ite{Spielman2011a}, which constructs a sparsifier $zidetilde{G}$ by sampling each edge with probability proportional to its effective resistance.
However, our proof avoids using matrix concentration inequalities, and instead relies on a more direct chaining technique for proving the concentration of $x^{\mathbf{t}}op L_{zidetilde G}x$ around its expectation, i.e. $x^{\mathbf{t}}op L_G x$, for all $x$ simultaneously.
To our knowledge, this is the first nearly-optimal direct analysis of spectral sparsification through effective resistance sampling. It will also be the basis of our main result, as we adapt it to the hypergraph setting in Sections~\ref{sec:balanced} and~\ref{sec:main}.

More formally, for an input graph $G=(V,F,z)$, we define $zidetilde G$ as the result of sampling each edge $f$ of $G$ independently with probability $p(f){\mathbf{a}}pprox z(f){\mathbf{c}}dot R_G(f)$, and setting its weight to $zidetildez(f)=z(f)/p(f)$. Our aim is then to prove
{\mathbf{b}}egin{equation}\label{eq:tech-overview-ordinary-main}
x^{\mathbf{t}}op L_{zidetilde G}x{\mathbf{a}}pprox x^{\mathbf{t}}op L_G x
{\mathbf{e}}nd{equation}
simultaneously for all $x\in \mathbb R^V$. For simplicity we assume that $x^{\mathbf{t}}op L_G x=1$. Equation~{\mathbf{e}}qref{eq:tech-overview-ordinary-main} is in fact the concentration of a random variable around its expectation, and so we can use Chernoff bound to prove it for any specific $x$.
Our plan is then to use a combination of Chernoff and union bounds to prove it for all possible $x$. Since $x$ can take any value in $\mathbb R^V$ we must discretize it to some ${\mathbf{e}}psilon$-net while retaining a good approximation to its quadratic form, i.e. $x^{\mathbf{t}}op L_G x$.

Let us take a closer look at the application of Chernoff bound to Equation~{\mathbf{e}}qref{eq:tech-overview-ordinary-main}: $x^{\mathbf{t}}op L_{zidetilde G}x$ is the sum of the independent random variables $zidetildez(u,v){\mathbf{c}}dot(x_u-x_v)^2$ for $(u,v) \in F$; hence, by Theorem~\ref{thm:chernoff},
the strength of the bound depends crucially on the upper bound $a$ on values that each random individual random variable can possibly attain. The maximum value of $zidetildez(u,v){\mathbf{c}}dot(x_u-x_v)^2$ is attained when $(u,v)$ is sampled in $zidetilde G$, in which case it is ${\mathbf{a}}pprox(x_u-x_v)^2/R_G(u,v)$. Thus
$$\mathbb P\left(x^{\mathbf{t}}op L_{zidetilde G}x\not{\mathbf{a}}pprox x^{\mathbf{t}}op L_G x\right)\lessapprox{\mathbf{e}}xp\left(-{\mathbf{f}}rac1{\max_{(u,v)\in F}(x_u-x_v)^2/R_G(u,v)}\right).$$
This upper bound can be as bad as ${\mathbf{e}}xp(-zidetilde O(1))$ and is far too crude for our purposes---no sufficiently sparse rounding scheme (i.e., discretization) exists for $x$. We turn to the technique of chaining---the use of progressively finer and finer rounding schemes.

As seen above, the strength of our Chernoff bound depends primarily on the quantity $(x_u-x_v)^2/R_G(u,v)$ for each edge $(u,v)$, which we call the ``power'' of the edge.
Therefore, it makes sense to partition the edges of $G$ into a logarithmic number of classes based on their power, that is $F_i$ contains edges $(u,v)$ for which $(x_u-x_v)^2{\mathbf{a}}pprox2^{-i}{\mathbf{c}}dot R_G(u,v)$.
When focusing only on the subgraphs $G(F_i)$ induced by $F_i$, we get the more fine-tuned Chernoff bound
$$\mathbb P\left(x^{\mathbf{t}}op L_{zidetilde G(F_i)}x\not{\mathbf{a}}pprox x^{\mathbf{t}}op L_{G(F_i)}x\right)\lessapprox{\mathbf{e}}xp\left(-{\mathbf{f}}rac1{\max_{(u,v)\in F_i}(x_u-x_v)^2/R_G(u,v)}\right)\lessapprox{\mathbf{e}}xp\left(-2^i\right).$$

We thus have the task of proposing a rounding scheme $\varphi_i:\mathbb R^V{\mathbf{t}}o\mathbb R^V$ specially for each class $F_i$ such that
{\mathbf{b}}egin{itemize}
	\item the image of $\varphi_i$ is a finite set of size at most ${\mathbf{a}}pprox{\mathbf{e}}xp\left(2^i\right)$,
	\item the rounding approximately preserves the quantity $(x_u-x_v)^2$ for $(u,v)\in F_i$.
{\mathbf{e}}nd{itemize}

To gain more intuition on what such a rounding scheme must look like, we draw inspiration from the idea of resistive embedding from~{\mathbf{c}}ite{Spielman2011a}. We map the edges in $F_i$, as well as our potential vector $x$, into vectors in $\mathbb R^n$ in such a way that all the relevant quantities arise as norms or scalar products:
{\mathbf{b}}egin{align*}
	(u,v)&\mapsto{\mathbf{u}}nderline{a_{u,v}}={\mathbf{f}}rac{L_G^{+/2}({\mathbf{c}}hi_u-{\mathbf{c}}hi_v)}{\left\|L_G^{+/2}({\mathbf{c}}hi_u-{\mathbf{c}}hi_v)\right\|},\\
	x&\mapsto{\mathbf{u}}nderline{y_x}=L_G^{1/2}x.
{\mathbf{e}}nd{align*}

Notice that both ${\mathbf{u}}nderline{a_{u,v}}$ and ${\mathbf{u}}nderline{y_x}$ are normalized (since $x^{\mathbf{t}}op L_Gx$=1). Furthermore, the crucial quantity, the power of the edge $(u,v)$ arises as the square of a scalar product:
$$\langle{\mathbf{u}}nderline{a_{u,v}},{\mathbf{u}}nderline{y_x}\rangle^2={\mathbf{f}}rac{(x^{\mathbf{t}}op({\mathbf{c}}hi_u-{\mathbf{c}}hi_v))^2}{({\mathbf{c}}hi_u-{\mathbf{c}}hi_v)^{\mathbf{t}}op L_G^+({\mathbf{c}}hi_u-{\mathbf{c}}hi_v)}={\mathbf{f}}rac{(x_u-x_v)^2}{R_G(u,v)}.$$

Thus we are interested in rounding ${\mathbf{u}}nderline{y_x}$  in a way that preserves $\langle{\mathbf{u}}nderline{a_{u,v}},{\mathbf{u}}nderline{y_x}\rangle^2$ up to small multiplicative error {\mathbf{e}}mph{in all cases where it was ${\mathbf{a}}pprox2^{-i}$ to begin with}. Thus, it suffices to guarantee an additive error of at most $\lessapprox2^{-i}$ in our rounding scheme. This is the known problem of ``compression of approximate inner products'' and has been previously studied;~{\mathbf{c}}ite{AK17} guarantees a rounding scheme whose image is of size at most ${\mathbf{a}}pprox{\mathbf{e}}xp\left(2^i\right)$. This can be translated into a rounding scheme for $x\in\mathbb R^V$, with the same image-size, exactly as desired (see Lemma~\ref{lem:rounding}).

With the desired rounding scheme in hand, we can now use a combination of Chernoff and union bounds to prove that for all $x$ simultaneously $$x^{\mathbf{t}}op L_{zidetilde G(F_i)}x{\mathbf{a}}pprox x^{\mathbf{t}}op L_{G(F_i)}x.$$
Summing this over all edge-classes gives us Equation~\ref{eq:tech-overview-ordinary-main}.

For the detailed proof, which is considerably more complicated than the above sketch, see the proof of Theorem~\ref{thm:ordinary-sparsification} in Section~\ref{sec:warm-up}.

{\mathbf{s}}ubsection{Extension to Hypergraphs}

To adapt the previous argument to the hypergraph setting, we use the idea of balanced weight assignments from~{\mathbf{c}}ite{Chen2020}. Essentially, we construct an ordinary graph $G=(V,F,z)$ to accompany our input hypergraph $H=(V,E,w)$ by replacing each hyperedge $e$ with a clique $F_e$ over the vertices in $e$.
However, unlike in some previous works on hypergraph sparsification, the clique $F_e$ is not assigned weights uniformly, but instead the weight is carefully distributed among the edges. Intuitively, all the weight is shifted onto the most ``important'' edges. In the case of~{\mathbf{c}}ite{Chen2020}, the measure of importance was ``strength'', a quantity relevant to cut sparsification, while in our case it is effective resistance.

More formally, a weighting assignment $z$ of the cliques is considered $\gamma$-balanced if for all $e\in E$
{\mathbf{b}}egin{itemize}
	\item ${\mathbf{s}}um_{f\in F_e}z(f)=w(e)$,
	\item and
	$$\gamma{\mathbf{c}}dot\min_{g\in F_e:\ z(g)>0}R_G(g)\ge\max_{f\in F_e}R_G(f).$$
{\mathbf{e}}nd{itemize}
	
In words, all but the zero-weight edges of $F_e$ have approximately the same effective resistance. This allows hyperedge $e$ to inherit this effective-resistance value as its importance when sampling hyperedges. Our task is now to prove the existence of balanced weight assignments for all hypergraphs, and then to adapt the proof of Section~\ref{sec:warm-up}.

{\mathbf{p}}aragraph{Finding balanced weight assignments.} In~{\mathbf{c}}ite{Chen2020}, balanced weight assignments are constructed through the following intuitive process: Find a pair of edges violating the second constraint, that is $f,g\in F_e$ where $z(g)\neq0$ and $f$ has significantly higher importance than $g$. Then shift weight from $g$ to $f$; this alleviates the constraint violation either because the importances of $g$ and $f$ become more similar, or simply because the weight of $g$ decreases to $0$. We call this resolving the imbalance of $f$ and $g$.~{\mathbf{c}}ite{Chen2020} strings together such steps, carefully ordered and discretized, to eventually produce a balanced weight assignment of the input hypergraph.

However, their analysis relies heavily on a certain lemma about how ``strength'' (their measure of edge importance) behaves under weight updates. Lemma~6 of~{\mathbf{c}}ite{Chen2020} states that altering the weight of an edge $f$, will not affect edges of significantly greater ``strength'' than $f$. This is not the case for effective resistances. It is easy to construct scenarios to the contrary; even ones in which altering the weight of edges of low resistance can increase the maximum effective resistance in the graph.

Thus the analysis of~{\mathbf{c}}ite{Chen2020} does not extend to our setting. Instead we use a potential function argument to say that we make irreversible progress whenever we resolve the imbalance of two edges $f$ and $g$. Our choice of potential function is surprising, and is one of the main technical contributions of this paper. We define the spanning tree potential (or ST-potential) of a connected weighted ordinary graph $G=(V,F,z)$, denoted $\Psi(G)$. For edge weights that equal $1$ uniformly (that is for unweighted graphs) it is simply the logarithm of the number of distinct spanning trees in $G$. In weighted graphs it is generalized to
$$\Psi(G)=\log\left({\mathbf{s}}um_{T\in\mathbb T}{\mathbf{p}}rod_{f\in T}z(f)\right),$$
where $\mathbb T$ denotes the set of all spanning trees in $G$. Due to the relationship between spanning tree sampling and effective resistances (see for example~{\mathbf{c}}ite{lovasz1993random}) we can prove a crucial update formula for $\Psi(G)$: if an edge $f$ has its weight changed by $\lambda\in\mathbb R$, the ST-potential increases by $\log(1+\lambda{\mathbf{c}}dot R(f))$. Since whenever we resolve the imbalance of a pair of edges, we shift weight from the edge of lower effective resistance to that of higher effective resistance, this allows us to argue that the ST-potential always increases throughout the process, which eventually terminates in a balanced weight assignment (see Algorithm~\ref{alg:greedy-balanced} and Theorem~\ref{thm:greedy-balanced}).

This proves the existence of balanced weight assignments, which suffices to show the existence of nearly linear size spectral sparsifiers for all hypergraphs. However, to improve running time (from exponential to polynomial in the input size), we introduce the novel concept of {\mathbf{e}}mph{approximate} balanced weight assignments, by slightly relaxing the definition. These are still sufficient to aid in constructing spectral sparsifiers, and are faster to construct using Algorithm~\ref{alg:greedy-approx-balanced}.

For more details on the ST-potential, as well as the construction of balanced weight assignments see Section~\ref{sec:balanced}.

{\mathbf{p}}aragraph{Using balanced weight assignments to construct hypergraph spectral sparsifiers.} Given a hypergraph $H=(V,E,w)$ and its balanced weight assignment $G=(V,F,z)$ we assign importance to each hyperedge proportionally to the maximum effective resistance in $F_e$ (the clique corresponding to $e$). Thus we perform importance sampling, which samples each hyperedge independently with probability $p(e){\mathbf{a}}pprox w(e){\mathbf{c}}dot\max_{f\in F_e}R_G(f)$.

The broad strokes of the hypergraph proof in Section~\ref{sec:main} proceed very similarly to those of the proof for ordinary graphs in Section~\ref{sec:warm-up}. However, numerous details need to be figured out in order to bridge the gap between the two settings. It is interesting to note that our rounding scheme is exactly the same as in Section~\ref{sec:warm-up}, to the point of even being defined in terms of $G$, not $H$. (Indeed it is impossible to define such a rounding scheme directly in terms of $H$; Lemma~\ref{lem:rounding} relies heavily on the linear nature of the ordinary graph Laplacian.) Nevertheless, we manage to extend the approximation guarantee of the rounding scheme from edges to hyperedges (see Claim~\ref{claim:hyper-rounding}).

For the detailed analysis of hypergraph spectral sparsification through effective resistance-based importance sampling, see Section~\ref{sec:main}.

{\mathbf{s}}ubsection{Speed-Up}

Using a results of Sections~\ref{sec:balanced} and~\ref{sec:main} we can put together a polynomial time algorithm for spectral sparsification of hypergraphs. Simply run Algorithm~\ref{alg:greedy-approx-balanced} to produce an approximate balanced weight assignment, and then use importance sampling (Algorithm~\ref{alg:main}). The bottleneck of this procedure is constructing the weight assignment, which takes time $O(m{\mathbf{c}}dot {\mathbf{p}}oly{n})$. (Given the weight assignment, it is trivial to implement importance sampling).

In Section~\ref{sec:speed-up} we reduce this to the nearly optimal $zidetilde O(mr + {\mathbf{p}}oly{n})$. (Note that $O(mr)$ is the size of the input.) Our first step is the common trick of using a faster sparsification algorithm, but one which produces a larger output, to preprocess the input hypergraph. We use the algorithm of~{\mathbf{c}}ite{Bansal2019} which -- with small modifications -- can be made to run in the desired $zidetilde O(mr + {\mathbf{p}}oly{n})$ time. The resulting hypergraph has only polynomially many hyperedges (in $n$); however, the aspect ratio of edge weights (that is the ratio between the largest and smallest edge weights) can naturally be exponential in $n$.

Unfortunately, Algorithm~\ref{alg:greedy-approx-balanced} scales linearly in the aspect ratio of edge weights (see Theorem~\ref{thm:greedy-approx-balanced}) and so we propose another algorithm for finding a balanced weight assignment -- one specifically designed for the setting when the input graph is polynomially sparse, but has exponential aspect ratio.

Suppose our input hypergraph, $H=(V,E,w)$ has edge weights in the range $[1,{\mathbf{e}}xp(n)]$. We then divide hyperedges into weight categories such as $E_i=\{e\in E|w(e)\in[n^{10(i-1)},n^{10i})\}$. We then bisect $H$ into two hypergraphs $H_1$ and $H_2$, where $H_1$ contains all hyperedges in odd numbered categories, and $H_2$ all those in even numbered categories. This results in hyergraphs ($H_1$ and $H_2$) where hyperedges fall into extremely well-separated categories; so extremely in fact, that the weight of a hyperedge in a higher category (for example $e\in E_i{\mathbf{s}}ubseteq H_1$) has higher weight than all hyperedges of all lower categories {\mathbf{e}}mph{combined}, that is
$$w(e)\gg{\mathbf{s}}um_{e'\in E_{<i}{\mathbf{c}}ap H_1}w(e').$$

We use this property to independently find weight assignments on $H_1$ and $H_2$. Informally, we go through the categories of hyperedges, from heaviest to lightest, resolving all instances of imbalance. We never return to a category once we moved on, and we prove that no amount of changes to the weight assignment of lower categories can disrupt the balance of a higher category, due to the huge discrepency in weights. For a more detailed and formal argument see Section~\ref{sec:separated}.

{\mathbf{s}}ection{Warm-Up: Ordinary Graphs}\label{sec:warm-up}

We begin by reproving the famous theorem of Spielman and Srivastava~{\mathbf{c}}ite{Spielman2011a}, which states that sampling edges of a graph with probability proportional to their effective resistance (and then reweighting appropriately) results in a spectral sparsifier with high probability.
We prove a somewhat weaker version of the theorem, where we oversample by an $O({\mathbf{e}}psilon^{-4}\log^3 n)$ factor, as opposed to the ${\mathbf{e}}psilon^{-2}\log n$ factor in the original.
Another slight difference is that our version samples every edge independently,
instead of sampling a predetermined number of edges with replacement in~{\mathbf{c}}ite{Spielman2011a}. More recent proofs of the theorem of~{\mathbf{c}}ite{Spielman2011a} that use the matrix Bernstein inequality as opposed to~{\mathbf{c}}ite{RudelsonV07} also use the same distribution as ours. 

{\mathbf{b}}egin{theorem}[A slightly weaker version of~{\mathbf{c}}ite{Spielman2011a}]\label{thm:ordinary-sparsification}
Let $G=(V,F,z)$ be a weighted ordinary graph with $n$ vertices
and let $1/n\le{\mathbf{e}}psilon\le1/2$.
For every edge $f\in F$, let $p(f)=\min(1,\lambda{\mathbf{c}}dotz(f){\mathbf{c}}dot R_G(f))$
for a sufficiently large factor $\lambda = \textsc{T}heta({\mathbf{e}}psilon^{-4}\log^3 n)$.
Sample each edge $f\in F$ independently with probability $p(f)$,
and give it weight $zidetildez(f)=z(f)/p(f)$ if sampled.
The resulting graph, $zidetilde G=(V,zidetilde F,zidetildez)$ is an ${\mathbf{e}}psilon$-spectral sparsifier of $G$ with probability at least $1-O(\log n/n)$.
{\mathbf{e}}nd{theorem}

The original proof of this theorem used a concentration bound for matrices~{\mathbf{c}}ite{RudelsonV07}
(later simplified to use the matrix Bernstein inequality)
to prove that $x^{\mathbf{t}}op L_{zidetilde G}x$ is close to its expectation simultaneously for all $x\in\mathbb{R}^n$, as required by Definition~\ref{def:sparsifier}.
This type of argument is difficult to adapt to hypergraph sparsification,
because the extension of quadratic forms to hypergraphs is highly non-linear.
We thus present an alternative proof that uses more primitive techniques
to bypass the reliance on linear algebra.

{\mathbf{b}}egin{proofof}{Theorem~\ref{thm:ordinary-sparsification}}
  By Definition~\ref{def:sparsifier}, we must prove that for every $x\in\mathbb R^V$,

	{\mathbf{b}}egin{equation}\label{eq:ordinary-main}
		x^{\mathbf{t}}op L_{zidetilde G}x \in (1 {\mathbf{p}}m {\mathbf{e}}psilon){\mathbf{c}}dot x^{\mathbf{t}}op L_G x.
	{\mathbf{e}}nd{equation}

	We may assume without loss of generality that $x^{\mathbf{t}}op L_G x = 1$. We denote the set of vectors $x$ where this is satisfied as $S^G{\mathbf{s}}ubseteq\mathbb R^V$.
  Furthermore, we simplify notation by denoting $L_G$ as $L$, and $L_{zidetilde G}$ as $zidetilde L$.
        Moreover, for any subset of edges $F'{\mathbf{s}}ubseteq F$,
        we denote the Laplacian of the subgraph of $G$ corresponding to $F'$ by $L_{F'}$,
        and similarly for the subgraph of $zidetilde G$ by $zidetilde L_{F'}$.

	It is clear from the construction of $zidetilde G$ that
	$$\mathbb E\left(x^{\mathbf{t}}op zidetilde Lx\right)=x^{\mathbf{t}}op Lx.$$
	Therefore, we are in effect trying to prove the concentration of a random variable around its expectation in Equation~{\mathbf{e}}qref{eq:ordinary-main}.
        Indeed, for any specific $x$, Equation~{\mathbf{e}}qref{eq:ordinary-main} holds with high probability by Chernoff bound (Theorem~\ref{thm:chernoff}). (One can consider $x^{\mathbf{t}}op Lx$ as the sum of independent random variables of the form $zidetildez(u,v){\mathbf{c}}dot(x_u-x_v)^2$.)

	In order to prove the concentration for all $x\in S^G$ simultaneously,
        we employ a net argument,
        where we ``round'' $x$ to some vector from a finite set 
        and apply a union bound on the rounded vectors.
        However, our rounding scheme is progressive 
        and has $O(\log n)$ ``levels'' with increasingly finer resolution. 
        Each $x$ will then determine a partition of the edges into levels,
        and we will prove concentration for each rounded vector
        and each level (subset of edges),
        and then apply a union bound over all these choices.

The existence of these rounding functions is guaranteed by the following lemma, which we will prove in Section~\ref{subsec:lem:rounding}.
{\mathbf{b}}egin{lemma}\label{lem:rounding}
Let $G=(V,F,z)$ be a connected weighted graph.
Then for every $i\in\mathbb N$ there exists a rounding function
$$\varphi_i:S^G{\mathbf{t}}o\mathbb R^V$$
such that for all $x\in S^G$, denoting $x^{(i)}:=\varphi_i(x)$, we have:
{\mathbf{b}}egin{enumerate}
\item
  The image of $\varphi_i$ is a finite set of cardinality
  $|\varphi_i(S^G)| \leq {\mathbf{e}}xp\left(800C\log n{\mathbf{c}}dot2^i/{\mathbf{e}}psilon^2\right)$,
  where $C>0$ is the absolute constant from Theorem~\ref{thm:rounding}.
\item
  For every edge $f=(u,v)\in F$ such that $\max\left((x_u-x_v)^2,(x_u^{(i)}-x_v^{(i)})^2\right)\ge2^{-i}{\mathbf{c}}dot R_G(f)$,
  $$(x_u-x_v)^2 \in \left(1 {\mathbf{p}}m {\mathbf{f}}rac{{\mathbf{e}}psilon}{7}\right) {\mathbf{c}}dot (x^{(i)}_u-x_v^{(i)})^2.$$

{\mathbf{e}}nd{enumerate}
{\mathbf{e}}nd{lemma}

The second guarantee of Lemma~\ref{lem:rounding} can be expressed in terms of the Laplacian of a single edge, resulting in the following corollary.
	{\mathbf{b}}egin{corollary}\label{cor:rounding}
		For a rounding function $\varphi$ satisfying the guarantees of Lemma~\ref{lem:rounding}, and an edge $f=(u,v)\in F$ such that $\max\left((x_u-x_v)^2,(x_u^{(i)}-x_v^{(i)})^2\right)\ge2^{-i}{\mathbf{c}}dot R_G(f)$,
		$$x^{\mathbf{t}}op L_{\{f\}}x \in \left(1 {\mathbf{p}}m {\mathbf{f}}rac{\mathbf{e}}psilon7\right){\mathbf{c}}dot x^{(i){\mathbf{t}}op}L_{\{f\}}x^{(i)} .$$

	{\mathbf{e}}nd{corollary}

Let us take a sequence of the rounding functions $\varphi_i$ guaranteed by Lemma~\ref{lem:rounding} for $i=1,\ldots, I := \log_2(7n/{\mathbf{e}}psilon)\le3\log n$.
For each $x\in S^G$, it yields a sequence of rounded vectors $x^{(i)}=\varphi_i(x)$ for $i=1,\ldots,I$.
Furthermore, we use $x^{(i)}$ to define the subset of edges $F_i'{\mathbf{s}}ubseteq F$ by
	$$F_i' := \left\{f=(u,v)\in F\ \middle|\ \left(x_u^{(i)}-x_v^{(i)}\right)^2\ge2^{-i}{\mathbf{c}}dot R_G(f)\right\}.$$
	That is, the second guarantee of Lemma~\ref{lem:rounding} holds for $\varphi_i$ on edges in $F_i'$.
	Finally, we use ${\mathbf{s}}et{F_i'}_i$ to partition $F$ as follows.
        Let the base case be $F_0=F_0' := {\mathbf{s}}et{ f\in F \mid p(f)=1}$,
        where we recall that $p(f)=\min(1,\lambda{\mathbf{c}}dotz(f){\mathbf{c}}dot R_G(f))$.
        For each $i \in [I]$, let $F_i:=F_i'{\mathbf{s}}etminus{\mathbf{b}}igcup_{j=0}^{i-1}F'_j$, and finally let $F_{I+1}=F{\mathbf{s}}etminus{\mathbf{b}}igcup_{i=0}^I F_i'$.

	
	Thus we have partitioned $F$ in such a way that the second guarantee of Lemma~\ref{lem:rounding} applies to edges in $F_i$, with respect to $\varphi_i$. Furthermore, $F_i$ are defined in terms of $x^{(i)}$ (and $x^{(j)}$ for $j<i$) instead of $x$, so that the number of possible sets $F_i$ is finite, and bounded thanks to the first guarantee of Lemma~\ref{lem:rounding}.
	
	We establish the following claim for later use.

{\mathbf{b}}egin{claim}\label{cl:power-bound}
  For all $i \in [I]$ and $f=(u,v)\in F_i$, we have
  $$(x_u^{(i)}-x_v^{(i)})^2\le3{\mathbf{c}}dot2^{-i}{\mathbf{c}}dot R_G(f).$$
{\mathbf{e}}nd{claim}

{\mathbf{b}}egin{proof}
The second guarantee of Lemma~\ref{lem:rounding} for $\varphi_i$ applies to $f$,
and thus $(x_u^{(i)}-x_v^{(i)})^2\le(x_u-x_v)^2{\mathbf{c}}dot(1-{\mathbf{e}}psilon/7)^{-1}$.

Consider first the case $i=1$.
By Fact~\ref{fact:eff-res} and since $x\in S^G$, we have
$(x_u-x_v)^2\le R_G(f){\mathbf{c}}dot x^{\mathbf{t}}op Lx=R_G(f)$, 
and we indeed get
$(x^{(i)}_u-x^{(i)}_v)^2\le R_G(f){\mathbf{c}}dot(1-{\mathbf{e}}psilon/7)^{-1}\le3{\mathbf{c}}dot2^{-1}{\mathbf{c}}dot R_G(f)$.

Now consider $i>1$,
and suppose towards contradiction that
$(x^{(i)}_u-x^{(i)}_v)^2>3{\mathbf{c}}dot2^{-i}{\mathbf{c}}dot R_G(f)$.
Notice that the second guarantee of Lemma~\ref{lem:rounding} also applies to $f$ for $\varphi_{i-1}$,
and thus
$(x_u^{(i-1)}-x_v^{(i-1)})^2\ge(x^{(i)}_u-x_v^{(i)})^2{\mathbf{c}}dot(1+{\mathbf{e}}psilon/7)^{-1}{\mathbf{c}}dot(1-{\mathbf{e}}psilon/7)\ge2^{-i+1}{\mathbf{c}}dot R_G(f)$.
This implies that $f\in F'_{i-1}$,
which contradicts the assumption $f\in F_i=F_i'{\mathbf{s}}etminus{\mathbf{b}}igcup_{j=0}^{i-1}F_j'$.
{\mathbf{e}}nd{proof}

We will consider each group of edges $F_i$ separately,
and prove that $x^{{\mathbf{t}}op}zidetilde L_{F_i}x$ concentrates around its expectation, $x^{\mathbf{t}}op L_{F_i}x$.
More precisely, we will first prove concentration for every specific $(x^{(i)}, F_i)$,
and then extend the concentration to all possibilities simultaneously via union bound.
This is well-defined because each $F_i$ depends on $x^{(1)},\ldots,x^{(i)}$ but not directly on $x$. 

{\mathbf{p}}aragraph{Edges in $F_0$.}
By definition, every edge $f\in F_0$ has $p(f)=1$,
and thus $x^{\mathbf{t}}opzidetilde L_{F_0}x$ is completely deterministic and equal to $x^{\mathbf{t}}op L_{F_0}x$.

{\mathbf{p}}aragraph{Edges in $F_i$ for $i\in[I]$.}
Note that $F_i$ is designed so that, by Corollary~\ref{cor:rounding},
for every edge $f\in F_i$ we have
$\left|x^{\mathbf{t}}op L_{\{f\}}x-x^{(i){\mathbf{t}}op}L_{\{f\}}x^{(i)}\right|\le{\mathbf{e}}psilon/7{\mathbf{c}}dot x^{(i){\mathbf{t}}op}L_{\{f\}}x^{(i)}$,
and since $zidetilde L_{\{f\}}$ is a multiple of $L_{\{f\}}$ similarly have $\left|x^{\mathbf{t}}opzidetilde L_{\{f\}}x-x^{(i){\mathbf{t}}op}zidetilde L_{\{f\}}x^{(i)}\right|\le{\mathbf{e}}psilon/7{\mathbf{c}}dot x^{(i){\mathbf{t}}op}zidetilde L_{\{f\}}x^{(i)}$.
Informally, this allows us to prove concentration only for vectors $x^{(i)}$
instead of all $x$, and thus we next aim to bound the error
$$\left|x^{(i){\mathbf{t}}op}L_{F_i}x^{(i)}-x^{(i){\mathbf{t}}op}zidetilde L_{F_i}x^{(i)}\right|$$
for each $i\in[I]$ with high probability.
It will then remain to bound the error introduced on the remaining edges (the ones in $F_{I+1}$).

Fix $i\in[I]$ and notice that over all possible vectors $x\in S^G$,
there are only finitely many possible values for $(x^{(i)}, F_i)$.
Therefore, we can focus on a single value of $x^{(i)}$ and $F_i$,
and then use a union bound over all settings.

Let us therefore fix also $x^{(i)}$ and $F_i$.
We will use Chernoff bounds to prove that with high probability,
over the randomness of sampling edges to $zidetilde G$,
{\mathbf{b}}egin{equation}\label{eq:medium-i-main}
  \left|x^{(i){\mathbf{t}}op}L_{F_i}x^{(i)}-x^{(i){\mathbf{t}}op}zidetilde L_{F_i}x^{(i)}\right|\le{\mathbf{f}}rac{{\mathbf{e}}psilon}{7I}.
{\mathbf{e}}nd{equation}

Indeed, note that
$$
  x^{(i){\mathbf{t}}op}zidetilde L_{F_i}x^{(i)}
  =
  {\mathbf{s}}um_{f=(u,v)\in F_i}zidetildez(f){\mathbf{c}}dot(x^{(i)}_u-x^{(i)}_v)^2,
$$
where $zidetildez(f)$ are independent random variables with expectation $\mathbb E(zidetildez(f))=z(f)$.
Therefore, we can apply the Chernoff bound from Theorem~\ref{thm:chernoff}
with ${\mathbf{s}}et{Z_i}_i$ being $zidetildez(f){\mathbf{c}}dot(x_u-x_v)^2$ for each $f=(u,v) \in F_i$,
and their sum being $Z=x^{(i){\mathbf{t}}op}zidetilde L_{F_i}x^{(i)}$
with $\mathbb E(Z)=x^{(i){\mathbf{t}}op}L_{F_i}x^{(i)}$.
We need to set $a$ as an upper bound on $zidetildez(f){\mathbf{c}}dot(x^{(i)}_u-x^{(i)}_v)^2$.
Observe that $zidetildez(f)$ is maximal when $f$ is sampled,
in which case it equals $z(f)/p(f)$ where $p(f)=\lambda{\mathbf{c}}dotz(f){\mathbf{c}}dot R_G(f)$,
since $f\not\in F_0$.
We thus get, using Claim~\ref{cl:power-bound},
$$
  {\mathbf{f}}orall f=(u,v)\in F_i,
  {\mathbf{q}}quad
  {\mathbf{f}}rac{z(f){\mathbf{c}}dot(x_u^{(i)}-x_v^{(i)})^2}{\lambda{\mathbf{c}}dotz(f){\mathbf{c}}dot R_G(f)}
  = {\mathbf{f}}rac1\lambda{\mathbf{c}}dot{\mathbf{f}}rac{(x_u^{(i)}-x_v^{(i)})^2}{R_G(f)}
  \le{\mathbf{f}}rac{3{\mathbf{c}}dot2^{-i}}\lambda
  =: a.
$$
We let ${\mathbf{d}}elta := {\mathbf{e}}psilon/(14I)$, we can bound 
$$
  x^{(i){\mathbf{t}}op}L_{F_i}x^{(i)}
  \le \left(1+{\mathbf{f}}rac{{\mathbf{e}}psilon}{7}\right){\mathbf{c}}dot x^{\mathbf{t}}op L_{F_i}x
  \le \left(1+{\mathbf{f}}rac{{\mathbf{e}}psilon}{7}\right){\mathbf{c}}dot x^{\mathbf{t}}op Lx=1+{\mathbf{f}}rac{{\mathbf{e}}psilon}{7}
  \le 2
  =: \mu.
$$
(This is true for an arbitrary preimage $x\in\varphi_i^{-1}(x^{(i)})$.)

Finally, Theorem~\ref{thm:chernoff} implies
{\mathbf{b}}egin{align*}
  \mathbb P\left(\left|x^{(i){\mathbf{t}}op}L_{F_i}x^{(i)}-x^{(i){\mathbf{t}}op}zidetilde L_{F_i}x^{(i)}\right|\ge{\mathbf{f}}rac{{\mathbf{e}}psilon}{7I}\right)

   &\le2{\mathbf{e}}xp\left(-{\mathbf{f}}rac{{\mathbf{d}}elta^2\mu}{3{\mathbf{c}}dot a}\right)\\
   &=2{\mathbf{e}}xp\left(-{\mathbf{f}}rac{{\mathbf{t}}frac{{\mathbf{e}}psilon^2}{196I^2}{\mathbf{c}}dot2}{9{\mathbf{c}}dot 2^{-i}/ \lambda}\right)\\
   &\le2{\mathbf{e}}xp\left(-{\mathbf{f}}rac{{\mathbf{e}}psilon^2{\mathbf{c}}dot2^i{\mathbf{c}}dot\lambda}{10000\log^2(n)}\right)\\
   &=2{\mathbf{e}}xp\left(-{\mathbf{f}}rac{2000C\log n{\mathbf{c}}dot2^i}{{\mathbf{e}}psilon^2}\right),
{\mathbf{e}}nd{align*}
where the last step by setting $\lambda = 2{\mathbf{c}}dot10^7{\mathbf{c}}dot C\log^3 n/{\mathbf{e}}psilon^4$,
where $C>0$ is the absolute constant from Theorem~\ref{thm:rounding}.

We can now use a union bound to bound the probability that Equation~{\mathbf{e}}qref{eq:medium-i-main} holds simultaneously for all values of $(x^{(i)},F_i)$.
$F_i$ depends only on $F'_j$ for $j \in [i]$, which in turn depend on $x^{(j)}$ for the same values of $j$.
By the first guarantee of Lemma~\ref{lem:rounding}, the number of possible vectors $x^{(j)}$ is at most ${\mathbf{e}}xp\left(800C\log n{\mathbf{c}}dot2^j/{\mathbf{e}}psilon^2\right)$, where $C>0$ is the absolute constant from Theorem~\ref{thm:rounding}.
Therefore, the number of possible pairs $(x^{(i)},F_i)$ is at most
$$
  {\mathbf{p}}rod_{j=1}^i{\mathbf{e}}xp\left({\mathbf{f}}rac{800C\log n{\mathbf{c}}dot2^j}{{\mathbf{e}}psilon^2}\right)
  ={\mathbf{e}}xp\left({\mathbf{s}}um_{j=1}^i{\mathbf{f}}rac{800C\log n{\mathbf{c}}dot2^j}{{\mathbf{e}}psilon^2}\right)
  \le{\mathbf{e}}xp\left({\mathbf{f}}rac{1600C\log n{\mathbf{c}}dot2^i}{{\mathbf{e}}psilon^2}\right).
$$
Finally, the probability that Equation~{\mathbf{e}}qref{eq:medium-i-main} {\mathbf{e}}mph{does not} hold simultaneously for all pairs $(x^{(i)},F_i)$ is at most
$$
  {\mathbf{e}}xp\left({\mathbf{f}}rac{1600C\log n{\mathbf{c}}dot2^i}{{\mathbf{e}}psilon^2}\right){\mathbf{c}}dot2{\mathbf{e}}xp\left(-{\mathbf{f}}rac{2000C\log n{\mathbf{c}}dot2^i}{{\mathbf{e}}psilon^2}\right)
  = 2{\mathbf{e}}xp\left(-{\mathbf{f}}rac{400C\log n{\mathbf{c}}dot2^i}{{\mathbf{e}}psilon^2}\right)
  \le{\mathbf{f}}rac1n.
$$

{\mathbf{p}}aragraph{Edges in $F_{I+1}$.}
First we show that for any $x\in S^G$ and any edge $f=(u,v)\in F_{I+1}$ we have that $(x_u-x_v)^2\le{\mathbf{e}}psilon{\mathbf{c}}dot R_G(f)/(6n)$. Suppose for contradiction that this is not the case.
Then the second guarantee of Lemma~\ref{lem:rounding} applies and $(x^{(I)}_u-x^{(I)}_v)^2\ge(x_u-x_v)^2{\mathbf{c}}dot(1-{\mathbf{e}}psilon/7)\ge{\mathbf{e}}psilon{\mathbf{c}}dot R_G(e)/(6n){\mathbf{c}}dot(1-{\mathbf{e}}psilon/7)\ge{\mathbf{e}}psilon{\mathbf{c}}dot R_G(e)/(7n)$.
Therefore $f\in F_I'$,
which contradicts the assumption $f\in F_{I+1}$. (Here we used that $I$ was defined to be $\log_2(7n/{\mathbf{e}}psilon)$.)

Next, we would like to bound
$\left|x^{{\mathbf{t}}op}zidetilde L_{F_{I+1}}x-x^{\mathbf{t}}op L_{F_{I+1}}x\right|$
by showing that both terms are small.
First,
	{\mathbf{b}}egin{align*}
		x^{\mathbf{t}}op L_{F_{I+1}}x&={\mathbf{s}}um_{f=(u,v)\in F_{I+1}}z(f){\mathbf{c}}dot(x_u-x_v)^2
		&\le{\mathbf{s}}um_{f\in F_{I+1}}z(f){\mathbf{c}}dot{\mathbf{e}}psilon{\mathbf{c}}dot {\mathbf{f}}rac{R_G(f)}{6n}
		&\le{\mathbf{f}}rac{{\mathbf{e}}psilon}{6n}{\mathbf{c}}dot{\mathbf{s}}um_{f\in F}z(f){\mathbf{c}}dot R_G(f)
		&\le{\mathbf{f}}rac{{\mathbf{e}}psilon}{6},
	{\mathbf{e}}nd{align*}
where the last inequality uses Fact~\ref{fact:eff-res-sum}.

Second, we start similarly,
	{\mathbf{b}}egin{align*}
		x^{\mathbf{t}}opzidetilde L_{F_{I+1}}x&={\mathbf{s}}um_{f=(u,v)\in F_{I+1}}zidetildez(f){\mathbf{c}}dot(x_u-x_v)^2
		&\le{\mathbf{s}}um_{f\in F_{I+1}}zidetildez(f){\mathbf{c}}dot{\mathbf{e}}psilon{\mathbf{c}}dot {\mathbf{f}}rac{R_G(f)}{6n}
		&\le{\mathbf{f}}rac{{\mathbf{e}}psilon}{6n}{\mathbf{c}}dot{\mathbf{s}}um_{f\in F}zidetildez(f){\mathbf{c}}dot R_G(f),
	{\mathbf{e}}nd{align*}
and ideally we would like to show that ${\mathbf{s}}umzidetildez(f){\mathbf{c}}dot R_G(f)\le2n$.
This is not always true, but it is a random event, independent of the choice of $x$, and can be shown to hold with high probability using our Chernoff bound from Theorem~\ref{thm:chernoff}.
Indeed, $zidetildez(f){\mathbf{c}}dot R_G(f)$ are independent random variables with maximum value when $f$ is sampled, in which case $zidetildez(f)=z(f)/p(f)$,
and thus
{\mathbf{b}}egin{align*}
  zidetildez(f){\mathbf{c}}dot R_G(f)
  &\le {\mathbf{f}}rac{z(f){\mathbf{c}}dot R_G(f)}{p(f)}
  = {\mathbf{f}}rac{z(f){\mathbf{c}}dot R_G(f)}{\min(1,\lambda{\mathbf{c}}dotz(f){\mathbf{c}}dot R_G(f))}
  =\max\left(z(f){\mathbf{c}}dot R_G(f),1/\lambda\right)
  \le1
  =:a  ,
{\mathbf{e}}nd{align*}
where the last inequality uses Fact~\ref{fact:w-R}.

We apply Theorem~\ref{thm:chernoff} by setting ${\mathbf{d}}elta:=1$ and $\mu:=n$
(which we may do by Fact~\ref{fact:eff-res-sum}), and obtain
	{\mathbf{b}}egin{align*}
		\mathbb P\left({\mathbf{s}}um_{f\in F}zidetildez(f){\mathbf{c}}dot R_G(f)\ge2n\right)&\le2{\mathbf{e}}xp\left(-{\mathbf{f}}rac{n}{3}\right).
	{\mathbf{e}}nd{align*}
Therefore, with probability at least $1-O(1/n)$,
{\mathbf{b}}egin{equation}\label{eq:I+1-main}
  \left|x^{\mathbf{t}}opzidetilde L_{F_{I+1}}x-x^{\mathbf{t}}op L_{F_{I+1}}x \right|\le {\mathbf{f}}rac{{\mathbf{e}}psilon}{2} .
{\mathbf{e}}nd{equation}

{\mathbf{p}}aragraph{Putting everything together.}

By the above derivations, Equation~{\mathbf{e}}qref{eq:medium-i-main} holds for all $i$ and all $(x^{(i)},F_i)$ simultaneously, as well as Equation~{\mathbf{e}}qref{eq:I+1-main} holds with probability at least $1-O(\log n/n)$.
Assuming henceforth that this high probability event occurs,
we shall deduce that Equation~{\mathbf{e}}qref{eq:ordinary-main} holds for all $x\in S^G$.
Indeed, by the triangle inequality and Equation~{\mathbf{e}}qref{eq:I+1-main},
{\mathbf{b}}egin{align*}
  \left|x^{\mathbf{t}}opzidetilde Lx-x^{\mathbf{t}}op Lx\right|
  &\le{\mathbf{s}}um_{i=0}^{I+1}\left|x^{\mathbf{t}}opzidetilde L_{F_i}x-x^{\mathbf{t}}op L_{F_i}x\right|

  \leq 0 + {\mathbf{s}}um_{i=1}^I\left|x^{\mathbf{t}}opzidetilde L_{F_i}x-x^{\mathbf{t}}op L_{F_i}x\right|+ {\mathbf{f}}rac{{\mathbf{e}}psilon}{2}.
{\mathbf{e}}nd{align*}
Now for each $i\in[I]$,
we can approximate terms involving $x$ by $x^{(i)}$ and vice versa,
formalized by the aforementioned fact that for every $(u,v)\in F_i$ we have
$|(x_u-x_v)^2-(x^{(i)}_u-x^{(i)}_v)^2|\le{\mathbf{e}}psilon/7{\mathbf{c}}dot(x^{(i)}_u-x^{(i)}_v)^2$ (see the second condition of Lemma~\ref{lem:rounding} and the definition of $F_i'{\mathbf{s}}ubseteq F_i$),
and get
{\mathbf{b}}egin{align*}
  \left|x^{\mathbf{t}}opzidetilde L_{F_i}x-x^{\mathbf{t}}op L_{F_i}x\right|
  &\le\left|x^{\mathbf{t}}opzidetilde L_{F_i}x-x^{(i){\mathbf{t}}op}zidetilde L_{F_i}x^{(i)}\right|+\left|x^{(i){\mathbf{t}}op}zidetilde L_{F_i}x^{(i)}-x^{(i){\mathbf{t}}op}L_{F_i}x^{(i)}\right|+\left|x^{(i){\mathbf{t}}op}L_{F_i}x^{(i)}-x^{\mathbf{t}}op L_{F_i}x\right|\\
  &\le {\mathbf{f}}rac{{\mathbf{e}}psilon}{7}{\mathbf{c}}dot x^{(i){\mathbf{t}}op}zidetilde L_{F_i}x^{(i)}+\left|x^{(i){\mathbf{t}}op}zidetilde L_{F_i}x^{(i)}-x^{(i){\mathbf{t}}op}L_{F_i}x^{(i)}\right|+{\mathbf{f}}rac{{\mathbf{e}}psilon}{7}{\mathbf{c}}dot x^{(i){\mathbf{t}}op}L_{F_i}x^{(i)}\\
\intertext{now we use the triangle inequality,  }
  &\le {\mathbf{f}}rac{{\mathbf{e}}psilon}{7}{\mathbf{c}}dot x^{(i){\mathbf{t}}op}L_{F_i}x^{(i)} + \left(1+{\mathbf{f}}rac{{\mathbf{e}}psilon}{7}\right){\mathbf{c}}dot\left|x^{(i){\mathbf{t}}op}zidetilde L_{F_i}x^{(i)}-x^{(i){\mathbf{t}}op}L_{F_i}x^{(i)}\right|+{\mathbf{f}}rac{{\mathbf{e}}psilon}{7}{\mathbf{c}}dot x^{(i){\mathbf{t}}op}L_{F_i}x^{(i)}\\
\intertext{and now we crucially use Equation~{\mathbf{e}}qref{eq:medium-i-main}, }
  &\le\left(1+{\mathbf{f}}rac{{\mathbf{e}}psilon}{7}\right){\mathbf{c}}dot{\mathbf{f}}rac{{\mathbf{e}}psilon}{7I}+{\mathbf{f}}rac{2{\mathbf{e}}psilon}{7}{\mathbf{c}}dot \left(1-{\mathbf{f}}rac{{\mathbf{e}}psilon}{7}\right)^{-1}{\mathbf{c}}dot x^{\mathbf{t}}op L_{F_i}x\\
  &\le{\mathbf{f}}rac{{\mathbf{e}}psilon}{6I}+{\mathbf{f}}rac{2{\mathbf{e}}psilon}{6}{\mathbf{c}}dot x^{\mathbf{t}}op L_{F_i}x.
{\mathbf{e}}nd{align*}
Substituting this into our previous bound, we obtain
{\mathbf{b}}egin{align*}
  \left|x^{\mathbf{t}}opzidetilde Lx-x^{\mathbf{t}}opzidetilde Lx\right|
  &\le{\mathbf{s}}um_{i=1}^I\left({\mathbf{f}}rac{{\mathbf{e}}psilon}{6I}+{\mathbf{f}}rac{{\mathbf{e}}psilon}{3}{\mathbf{c}}dot x^{\mathbf{t}}op L_{F_i}x\right) + {\mathbf{f}}rac{{\mathbf{e}}psilon}{2}
  \le{\mathbf{f}}rac{{\mathbf{e}}psilon}{6}+{\mathbf{f}}rac{{\mathbf{e}}psilon}{3}{\mathbf{c}}dot x^{\mathbf{t}}op Lx+{\mathbf{f}}rac{{\mathbf{e}}psilon}{2}
  ={\mathbf{e}}psilon{\mathbf{c}}dot x^{\mathbf{t}}op Lx,
{\mathbf{e}}nd{align*}
where the last equality uses $x^{\mathbf{t}}op Lx = 1$.
This completes the proof of Theorem~\ref{thm:ordinary-sparsification}.
{\mathbf{e}}nd{proofof}

{\mathbf{s}}ubsection{Proof of Lemma~\ref{lem:rounding}}\label{subsec:lem:rounding}

To prove Lemma~\ref{lem:rounding}, we use the following Theorem:

{\mathbf{b}}egin{theorem}[Theorem VI.1 of~{\mathbf{c}}ite{AK17}]\label{thm:rounding}
	Let $a_1,\ldots,a_m \in \mathbb R^n$ be vectors of norm at most $1$ and let ${\mathbf{e}}ta\in(0,1)$.
	Then, over all vectors $y \in \mathbb R^n$ of norm at most $1$,
        the number of possible values of the ``rounded vector'' 
	$$\left(\left\lfloor{\mathbf{f}}rac{\langle a_1,y\rangle}{{\mathbf{e}}ta}\right{\mathbf{\rt{\cdot}}}loor,\left\lfloor{\mathbf{f}}rac{\langle a_2,y\rangle}{{\mathbf{e}}ta}\right{\mathbf{\rt{\cdot}}}loor,\ldots,\left\lfloor{\mathbf{f}}rac{\langle a_k,y\rangle}{{\mathbf{e}}ta}\right{\mathbf{\rt{\cdot}}}loor\right)$$
	is at most
	${\mathbf{e}}xp\left({\mathbf{f}}rac{C\log m}{{\mathbf{e}}ta^2}\right)$
	for some absolute constant $C>0$.
{\mathbf{e}}nd{theorem}

{\mathbf{b}}egin{remark}
	In fact, the original theorem (Theorem 6.1 in~{\mathbf{c}}ite{AK17}) is stated with stronger requirements on $m$ and ${\mathbf{e}}ta$, and a stronger consequence. However, we can easily get the weaker upper bound of ${\mathbf{e}}xp(O(\log m/{\mathbf{e}}ta^2))$ stated in Theorem~\ref{thm:rounding} of this paper, by setting the variables appropriately: $\varepsilon:={\mathbf{e}}ta$, $n:=\max(m,1/{\mathbf{e}}ta^2)$, and $k:=n$, where the left hand side always represents their variable names and the right hand side ours.
{\mathbf{e}}nd{remark}

{\mathbf{b}}egin{proofof}{Lemma~\ref{lem:rounding}}
We use the idea of resistive embedding introduced in~{\mathbf{c}}ite{}.
Note that $L=L_G$ is a positive semidefinite matrix, and we denote by $L^{+/2}$  the square root of its Moore-Penrose pseudo-inverse.
For each (unordered) vertex pair $(u,v)$, let $b_{u,v}\in\mathbb R^V$ be the vector with all zero coordinates, except for the coordinates associated with $u$ and $v$, which are $1$ and $-1$ (ordered arbitrarily).
With each vertex pair $(u,v)$, we associate the vector
$$a_{u,v}={\mathbf{f}}rac{L^{+/2}b_{u,v}}{\|L^{+/2}b_{u,v}\|_2}.$$
Furthermore, we associate with each $x\in S^G$ the vector $y_x=L^{1/2}x$.

We can then apply Theorem~\ref{thm:rounding} to ${\mathbf{s}}et{a_{u,v} \mid (u,v)\in{\mathbf{b}}inom{V}{2} }$ and all possible $y_x$,
setting ${\mathbf{e}}ta={\mathbf{e}}psilon{\mathbf{c}}dot2^{-i/2}/20$.
Indeed, $a_{u,v}$ is normalized by definition,
and also $y_x$ is normalized because $x\in S^G$ and thus
$$\|y_x\|_2^2=x^{\mathbf{t}}op L^{1/2}L^{1/2}x=x^{\mathbf{t}}op Lx=1. $$
For each possible value of the rounded vector
$$\left(\left\lfloor{\mathbf{f}}rac{\langle a_{u,v},y_x\rangle}{{\mathbf{e}}ta}\right{\mathbf{\rt{\cdot}}}loor\right)_{(u,v)\in{\mathbf{b}}inom{V}{2}}$$
choose a representative $x\in S^G$, 
and let $\varphi_i$ map each $x\in S^G$ to its representative
(i.e., with the same rounded vector).
Then by Theorem~\ref{thm:rounding}, the image of $\varphi_i$ is of size
$|\varphi_i(S^G)| \leq {\mathbf{e}}xp\left(800C\log n{\mathbf{c}}dot2^i/{\mathbf{e}}psilon^2\right)$,
as claimed.
Recall that we denote $\varphi_i(x)$ by $x^{(i)}$; then
$$\left(\left\lfloor{\mathbf{f}}rac{\langle a_{u,v},y_x\rangle}{{\mathbf{e}}ta}\right{\mathbf{\rt{\cdot}}}loor\right)_{(u,v)\in{\mathbf{b}}inom{V}{2}}=\left(\left\lfloor{\mathbf{f}}rac{\langle a_{u,v},y_{x^{(i)}}\rangle}{{\mathbf{e}}ta}\right{\mathbf{\rt{\cdot}}}loor\right)_{(u,v)\in{\mathbf{b}}inom{V}{2}}. $$
It follows that for all $f=(u,v)\in F$ and all $x\in S^G$,
{\mathbf{b}}egin{equation}\label{eq:rounding-add-error}          
  \left|\langle a_{u,v},y_x\rangle-\langle a_{u,v},y_{x^{(i)}}\rangle\right|\le{\mathbf{e}}ta .
{\mathbf{e}}nd{equation}
Furthermore, $b_{u,v}$ is perpendicular to the null-space of $L$
(which is spanned by the all-ones vector because $G$ is connected),
thus $L^{1/2}L^{+/2}b_{u,v}=b_{u,v}$ 
and
{\mathbf{b}}egin{equation}  \label{eq:auvyx}
  \langle a_{u,v},y_x\rangle^2
  = {\mathbf{f}}rac{\left(x^{{\mathbf{t}}op}L^{1/2}L^{+/2}b_{u,v}\right)^2}{b_{u,v}^{\mathbf{t}}op L^{+/2}L^{+/2}b_{u,v}}
  = {\mathbf{f}}rac{\left(x^{{\mathbf{t}}op}b_{u,v}\right)^2}{b_{u,v}^{\mathbf{t}}op L^+b_{u,v}}
  = {\mathbf{f}}rac{(x_u-x_v)^2}{R_G(u,v)}.
{\mathbf{e}}nd{equation}

To prove the second guarantee of Lemma~\ref{lem:rounding},
let $f=(u,v)\in F$ and $x\in S^G$ and consider first the case
$\left(x_u^{(i)}-x_v^{(i)}\right)^2\ge2^{-i}{\mathbf{c}}dot R_G(f)$,
which by~{\mathbf{e}}qref{eq:auvyx} is equivalent to $\langle a_{u,v},y_{x^{(i)}}\rangle^2\ge2^{-i}$. 
This means that the absolute error bound ${\mathbf{e}}ta$ in Equation~{\mathbf{e}}qref{eq:rounding-add-error} implies a relative error bound, namely, 

$$
  \left|\langle a_{u,v},y_x\rangle - \langle a_{u,v},y_{x^{(i)}}\rangle\right|
  \le {\mathbf{e}}ta
  = {\mathbf{f}}rac{{\mathbf{e}}psilon{\mathbf{c}}dot2^{-i/2}}{20}
  \le {\mathbf{f}}rac{{\mathbf{e}}psilon}{20}{\mathbf{c}}dot \left|\langle a_{u,v},y_{x^{(i)}}\rangle\right| .
$$
The other case $\left(x_u-x_v\right)^2 \ge 2^{-i}{\mathbf{c}}dot R_G(f)$
is similar up to constants;
by~{\mathbf{e}}qref{eq:auvyx}, this case is equivalent to $\langle a_{u,v},y_x\rangle^2\ge2^{-i}$,
and thus 
{\mathbf{b}}egin{align*}
  \left|\langle a_{u,v},y_x\rangle - \langle a_{u,v},y_{x^{(i)}}\rangle\right|
  &\le {\mathbf{e}}ta
  = {\mathbf{f}}rac{{\mathbf{e}}psilon{\mathbf{c}}dot2^{-i/2}}{20}
  \le {\mathbf{f}}rac{{\mathbf{e}}psilon}{20}{\mathbf{c}}dot \left|\langle a_{u,v},y_x\rangle\right| ,
  \\
\intertext{which implies}
  \left|\langle a_{u,v},y_x\rangle - \langle a_{u,v},y_{x^{(i)}}\rangle\right|
  &\le {\mathbf{f}}rac{{\mathbf{e}}psilon}{20}{\mathbf{c}}dot \left(1-{\mathbf{f}}rac{{\mathbf{e}}psilon}{20}\right)^{-1} \left|\langle a_{u,v},y_x\rangle\right| 
  \le {\mathbf{f}}rac{{\mathbf{e}}psilon}{16}{\mathbf{c}}dot \left|\langle a_{u,v},y_{x^{(i)}}\rangle\right| .
{\mathbf{e}}nd{align*}

Now in both cases, 
{\mathbf{b}}egin{align*}
  \left|\langle a_{u,v},y_x\rangle^2 - \langle a_{u,v},y_{x^{(i)}}\rangle^2\right|
  &=\left|\langle a_{u,v},y_x\rangle-\langle a_{u,v},y_{x^{(i)}}\rangle\right|{\mathbf{c}}dot\left|\langle a_{u,v},y_x\rangle+\langle a_{u,v},y_{x^{(i)}}\rangle\right|
  \\
  &\le{\mathbf{f}}rac{{\mathbf{e}}psilon}{16} {\mathbf{c}}dot |\langle a_{u,v},y_{x^{(i)}}\rangle| {\mathbf{c}}dot\left(2+{\mathbf{f}}rac{{\mathbf{e}}psilon}{16}\right) {\mathbf{c}}dot |\langle a_{u,v},y_{x^{(i)}}\rangle| \\
  &\le{\mathbf{f}}rac{{\mathbf{e}}psilon}{7}{\mathbf{c}}dot\langle a_{u,v},y_{x^{(i)}}\rangle^2. 

{\mathbf{e}}nd{align*}
Using~{\mathbf{e}}qref{eq:auvyx} and scaling by $R_G(u,v)$, we can write this as
$(x_u-x_v)^2\in (1 {\mathbf{p}}m {\mathbf{e}}psilon/7){\mathbf{c}}dot (x^{(i)}_u-x_v^{(i)})^2$,
which completes the proof of Lemma~\ref{lem:rounding}. 
{\mathbf{e}}nd{proofof}

{\mathbf{s}}ection{$\gamma$-Balanced Weight Assignments}\label{sec:balanced}

Our strategy for generalizing the techniques of Section~\ref{sec:warm-up} to hypergraphs is similar to that of~{\mathbf{c}}ite{Chen2020}.
Intuitively, we wish to replace each hyperedge of the input hypergraph with a weighted clique in such a way that the ``importance'' of each edge in the same clique is roughly the same.
However, our measure of importance is effective resistance, whereas in~{\mathbf{c}}ite{Chen2020} it is the {\mathbf{e}}mph{strength} of the edge (see~{\mathbf{c}}ite{Benczur2015}), which is a measure particularly useful to cut sparsification.
Specifically, we use the following definition.

{\mathbf{b}}egin{definition}\label{def:balanced}
	Given a hypergraph $H=(V,E,w)$, a weight assignment of $H$ is a weighted (ordinary) graph $G=(V,F,z)$ such that
	{\mathbf{b}}egin{itemize}
	\item $F$ is the multiset ${\mathbf{b}}igcup_{e \in E} F_e$, where $F_e$ is a set of edges forming a clique on the support of $e$\;
	\item ${\mathbf{s}}um_{f\in F_e}z(f)=w(e)$.
	{\mathbf{e}}nd{itemize}

	Note that this definition allows for parallel edges in $G$.
	
	
	Moreover, if $G$ satisfies
	$$\gamma{\mathbf{c}}dot\min_{g\in F_e:\ z(g)>0}R_G(g)\ge\max_{f\in F_e}R_G(f)$$
	for $\gamma > 1$, then we call it $\gamma$-balanced.
{\mathbf{e}}nd{definition}

The goal of this section is to show the existence of constant-balanced weight assignments for all weighted hypergraphs, and to define an efficient algorithm that outputs such a weight assignment.

{\mathbf{s}}ubsection{Spanning Tree Potential}

In order to show the existence (and give an efficient construction) of $\gamma$-balanced weight assignments we introduce the concept of spanning tree potentials for weighted ordinary graphs.
{\mathbf{b}}egin{definition}[Spanning tree potential, ST-potential for short]
	For a connected weighted graph $G=(V,F,z)$ let $\mathbb{T}(G)$ be the set of all spanning trees of $G$.
	Then we define the spanning tree potential of $G$ as
	{\mathbf{b}}egin{equation}\label{eq:Psi-formula}
		\Psi(G)=\log\left[{\mathbf{s}}um_{T\in\mathbb{T}(G)}{\mathbf{p}}rod_{f\in T}z(f)\right].
	{\mathbf{e}}nd{equation}

{\mathbf{e}}nd{definition}
{\mathbf{b}}egin{remark}
  Note that the value of ST-potential stays the same after replacing parallel edges $f_1$ and $f_2$ with a single edge $f$ of weight $z(f) := z(f_1) + z(f_2)$.
{\mathbf{e}}nd{remark}

We formalize the concept of edge updates to graphs and see how those updates affect ST-potential.
{\mathbf{b}}egin{definition}
	If $G=(V,F,z)$ is a weighted graph, $\lambda\in\mathbb R$, and $f\in{\mathbf{b}}inom{V}{2}$, then $G+\lambda{\mathbf{c}}dot f$ is the weighted graph $(V,F',z')$,  where the weight of $f$ is increased by $\lambda$. Formally,
	{\mathbf{b}}egin{itemize}
		\item $F'=F$, $z'(f)=z(f)+\lambda$, and $z'(g)=z(g)$ for all $g\neq f$, if $f\in F$,
		\item or $F'=F+\{f\}$, $z'(f)=\lambda$, and $z'(g)=z(g)$ for all $g\neq f$, if $f\not\in F$.
	{\mathbf{e}}nd{itemize}
	Note that the definition applies to $\lambda<0$ as well, but in this case $f$ must be present in the graph with weight at least $|\lambda|$ in order for $G+\lambda{\mathbf{c}}dot f$ to be valid.
{\mathbf{e}}nd{definition}

{\mathbf{b}}egin{lemma}\label{lem:Psi-update}
  For any weighted graph $G$, $\lambda\in\mathbb R$ and $f\in{\mathbf{b}}inom{V}{2}$ such that $G+\lambda{\mathbf{c}}dot f$ is well defined, we have
		{\mathbf{b}}egin{equation}\label{eq:Psi-main}\Psi(G+\lambda{\mathbf{c}}dot f)=\Psi(G)+\log\left(\lambda R_G(f) + 1\right),{\mathbf{e}}nd{equation}
{\mathbf{e}}nd{lemma}
{\mathbf{b}}egin{proof}

	We use the famous result that if we sample a spanning tree $\mathcal T$ randomly from $\mathbb{T}(G)$ such that
	$$\mathbb P(\mathcal T = T){\mathbf{p}}ropto{\mathbf{p}}rod_{g\in T}z(g),$$
	then the marginal probability $\mathbb P(f\in T)$ is $z(f){\mathbf{c}}dot R(f)$ for all $f\in F$ (see, e.g.,~{\mathbf{c}}ite{lovasz1993random}).
	Let $\mathcal T$ be a random variable drawn from such a distribution. By the definition of the distribution of $\mathcal T$ we have that
	{\mathbf{b}}egin{equation}\label{eq:mathcal-t}
	\mathbb P(f\in\mathcal T)={\mathbf{s}}um_{T \in \mathbb{T}(G):T\ni f}\mathbb P(\mathcal T = T)={\mathbf{f}}rac{{\mathbf{s}}um_{T \in \mathbb{T}(G):T\ni f}{\mathbf{p}}rod_{g\in T}z(g)}{{\mathbf{s}}um_{T\in\mathbb{T}(G)}{\mathbf{p}}rod_{g\in T}z(g)}
	{\mathbf{e}}nd{equation}
	Therefore, we have for the weight function $z'$ of $G + \lambda {\mathbf{c}}dot f$,
	{\mathbf{b}}egin{align*}
		\Psi(G + \lambda {\mathbf{c}}dot f)
		& = \log\left[{\mathbf{s}}um_{T\in\mathbb{T}(G')}{\mathbf{p}}rod_{g\in T}z'(g)\right] \\
		&=\log\left[{\mathbf{s}}um_{T\in\mathbb{T}(G)}{\mathbf{p}}rod_{g\in T}z(g){\mathbf{c}}dot \left(1+{\mathbf{f}}rac{\lambda}{z(f)}\right)^{\mathbbm1(g=f)}\right] \\
		&=\log\left[{\mathbf{s}}um_{T\in\mathbb T}\left(1+{\mathbf{f}}rac{\lambda}{z(f)}\right)^{\mathbbm1(f\in T)}{\mathbf{p}}rod_{g\in T}z(g)\right] \\
		&=\log\left[{\mathbf{s}}um_{T\in\mathbb{T}(G)}{\mathbf{p}}rod_{g\in T}z(g)+{\mathbf{f}}rac{\lambda}{z(f)}{\mathbf{c}}dot{\mathbf{s}}um_{T \in \mathbb{T}(G):T\ni f}{\mathbf{p}}rod_{g\in T}z(g)\right]. \\
		\intertext{We can transform the second term by Equation~{\mathbf{e}}qref{eq:mathcal-t} to continue:}
		&=\log\left[{\mathbf{s}}um_{T\in\mathbb{T}(G)}{\mathbf{p}}rod_{g\in T}z(g)+{\mathbf{f}}rac{\lambda}{z(f)}{\mathbf{c}}dot\mathbb P(f\in\mathcal T){\mathbf{c}}dot{\mathbf{s}}um_{T\in\mathbb{T}(G)}{\mathbf{p}}rod_{g\in T}z(g)\right] \\
		&=\log\left[{\mathbf{s}}um_{T\in\mathbb{T}(G)}{\mathbf{p}}rod_{g\in T}z(g)\right] + \log\left({\mathbf{f}}rac{\lambda}{z(f)}{\mathbf{c}}dot\mathbb P(f\in\mathcal T) + 1\right) \\
		&=\Psi(G) + \log(\lambda R_G(f) + 1)

	{\mathbf{e}}nd{align*}
	as claimed. Note that the above calculation is legitimate for positive $\lambda$ as well as negative.

{\mathbf{e}}nd{proof}

{\mathbf{s}}ubsection{Existence of $\gamma$-Balanced Weight Assignments}

We will now use ST-potential to construct a $\gamma$-balanced weight assignment of an arbitrary hypergraph. We can analyze a simple greedy algorithm, which identifies edge pairs contradicting the $\gamma$-balancedness condition in Definition~\ref{def:balanced}, and simply shifts weight from the one with smaller effective resistance to the one with the larger effective resistance (see Algorithm~\ref{alg:greedy-balanced}).
One can show that such an step can be designed to only increase the ST-potential of a weight assignment, and thus the algorithm eventually terminates, returning a $\gamma$-balanced weight assignment.

{\mathbf{b}}egin{algorithm}[H]
	{\mathbf{b}}egin{algorithmic}[1]
		{\mathbf{c}}aption{Algorithm for constructing a $\gamma$-balanced weight assignment.}\label{alg:greedy-balanced}
		\Procedure{GreedyBalancing}{$H=(V,E,w),\gamma$}
		\State For all $e\in E$ and for all $f\in F_e$, initialize $z(f)$ to $w(e)/{\mathbf{b}}inom{|e|}{2}$
		\State $G\gets(V,{\mathbf{b}}igcup_{e \in E} F_e,z)$
		\While{$G$ is not a $\gamma$-balanced weight assignment of $H$}
		\State Select $e\in E$, and $f,g\in F_e$, such that $R_G(f)>\gamma{\mathbf{c}}dot R_G(g)$ and $z(g)>0$
		\State $\lambda\gets\min\left(z(g),(\gamma - 1)/(2\gamma{\mathbf{c}}dot R_G(g))\right)$\label{line:select-problem-edge}
		\State $z(f)\gets z(f)+\lambda$
		\State $z(g)\gets z(g)-\lambda$
		\EndWhile
		\State {{\mathbf{c}}al R}eturn $G$
		\EndProcedure
	{\mathbf{e}}nd{algorithmic}
{\mathbf{e}}nd{algorithm}

The following tells how much the effective resistance of an edge changes by updating the weight of another edge.
Although the proof is simple and this result is already known, we include the proof for completeness.
{\mathbf{b}}egin{lemma}\label{lem:update-formula}
	If $G=(V,F,z)$ is a weighted graph, let $\lambda\in\mathbb R$, and $f\in{\mathbf{b}}inom{V}{2}$, then for any $g\in{\mathbf{b}}inom{V}{2}$
	$$R_{G+\lambda{\mathbf{c}}dot f}(g)=R_G(g)-{\mathbf{f}}rac{\lambda{\mathbf{c}}dot\left(b_g^{\mathbf{t}}op L_G^+b_f\right)^2}{1+\lambda{\mathbf{c}}dot R_G(f)}.$$
{\mathbf{e}}nd{lemma}

{\mathbf{b}}egin{proof}
	Note that
	$$L_{G+\lambda{\mathbf{c}}dot f}=L_G+\lambda b_f b_f^{\mathbf{t}}op.$$
	Therefore, by the Sherman-Morrison formula for Moore-Penrose pseudoinverse (see for example~{\mathbf{c}}ite{Meyer73}), we can expand the formula for the effective resistance of $g$:
	{\mathbf{b}}egin{align*}
		R_{G+\lambda{\mathbf{c}}dot f}(g)&=b_g^{\mathbf{t}}op L_{G+\lambda{\mathbf{c}}dot f}^+b_g
		=b_g^{\mathbf{t}}op{\left(L_G+\lambda b_f b_f^{\mathbf{t}}op\right)}^+b_g
		=b_g^{\mathbf{t}}op\left(L_G^+-{\mathbf{f}}rac{L_G^+b_f\lambda b_f^{\mathbf{t}}op L_G^+}{1+\lambda b_f^{\mathbf{t}}op L_G^+b_f}\right)b_g\\
		&=b_g^{\mathbf{t}}op L_G^+b_g-{\mathbf{f}}rac{\lambda b_g^{\mathbf{t}}op L_G^+b_f b_f^{\mathbf{t}}op L_G^+b_g}{1+\lambda b_f^{\mathbf{t}}op L_G^+b_f}
		=R_G(g)-{\mathbf{f}}rac{\lambda{\mathbf{c}}dot\left(b_g^{\mathbf{t}}op L_G^+b_f\right)^2}{1+\lambda{\mathbf{c}}dot R_G(f)}.
		{\mathbf{q}}edhere
	{\mathbf{e}}nd{align*}
{\mathbf{e}}nd{proof}

{\mathbf{b}}egin{lemma}\label{lem:greedy-step}
	Let $G=(V,F,z)$ be a weighted graph and let $\gamma>1$. Let $f,g$ be two edges in $F$ such that $R_G(f)>\gamma{\mathbf{c}}dot R_G(g)$. Then for any $\lambda\lez(g)$, shifting $\lambda$ weight from $g$ to $f$ results in an increase of at least
	$$\log\left(1+\lambda\gamma{\mathbf{c}}dot R_G(g)-\lambda{\mathbf{c}}dot R_G(g)-\lambda^2\gamma{\mathbf{c}}dot R_G(g)^2\right)$$
	in the ST-potential of $G$.
{\mathbf{e}}nd{lemma}

{\mathbf{b}}egin{proof}

We simply apply the update formula for ST-potential (Lemma~\ref{lem:Psi-update}) twice, along with Lemma~\ref{lem:update-formula}. For simplicity, we use $t_{fg}$ to denote $b_f^{\mathbf{t}}op L_G^+b_g$.
Then the increase in ST-potential is
	{\mathbf{b}}egin{align*}&\log\left(\lambda{\mathbf{c}}dot R_G(f)+1\right)+\log\left(-\lambda{\mathbf{c}}dot R_{G+\lambda{\mathbf{c}}dot f}(g)+1\right)\\
=&\log\left(\lambda{\mathbf{c}}dot R_G(f)+1\right)+\log\left(-\lambda{\mathbf{c}}dot\left(R_G(g)-{\mathbf{f}}rac{\lambda t_{fg}^2}{1+\lambda R_G(f)}\right)+1\right)\\
=&\log\left[\left(\lambda{\mathbf{c}}dot R_G(f)+1\right){\mathbf{c}}dot\left(-\lambda{\mathbf{c}}dot\left(R_G(g)-{\mathbf{f}}rac{\lambda t_{fg}^2}{1+\lambda R_G(f)}\right) + 1\right)\right]\\
=&\log\left(1+\lambda{\mathbf{c}}dot R_G(f)-\lambda{\mathbf{c}}dot R_G(g)-\lambda^2{\mathbf{c}}dot R_G(f)R_G(g)+\lambda^2t_{fg}^2\right)\\
\ge&\log\left(1+\lambda\gamma{\mathbf{c}}dot R_G(g)-\lambda{\mathbf{c}}dot R_G(g)-\lambda^2\gamma{\mathbf{c}}dot R_G(g)^2\right),
{\mathbf{e}}nd{align*}
as claimed.
{\mathbf{e}}nd{proof}

{\mathbf{b}}egin{theorem}\label{thm:greedy-balanced}
	For $\gamma>1$, Algorithm~\ref{alg:greedy-balanced} terminates and returns a $\gamma$-balanced weight assignment of $H$.
{\mathbf{e}}nd{theorem}

{\mathbf{b}}egin{proof}
	It is clear by the condition of the while-loop that if Algorithm~\ref{alg:greedy-balanced} terminates, it returns a $\gamma$-balanced weight assignment.
	Also, the condition ${\mathbf{s}}um_{f\in F_e}z(f)=w(e)$ is never violated.
	Therefore, in Line~\ref{line:select-problem-edge}, there must indeed always be some $e\in E$ and some $f,g\in F_e$ such that $R_G(f)>\gamma{\mathbf{c}}dot R_G(g)$ and $z(g)>0$, otherwise $G$ would already be $\gamma$-balanced.
	It remains to prove that Algorithm~\ref{alg:greedy-balanced} always terminates.

	Let us examine the evolution of $\Psi(G)$ throughout the algorithm. First, note that $G$ never becomes disconnected, and hence $\Psi(G)$ always remains defined. Indeed, in order for $G$ to become disconnected, we would have to set $\lambda$ to $z(g)$ for a {\mathbf{e}}mph{bridge} $g$. However, if $g$ is a bridge, $R_G(g)=1/z(g)$ by Fact~\ref{fact:w-R}, and $\lambda$ is set instead to $(\gamma-1)z(g)/(2\gamma)<z(g)$.
	
	In each iteration of the while-loop (which we call a step) we move $\lambda$ weight from some edge $g$ to some other edge $f$. By Lemma~\ref{lem:greedy-step} this results in a change of
	$$\log\left(1+\lambda\gamma{\mathbf{c}}dot R_G(g)-\lambda{\mathbf{c}}dot R_G(g)-\lambda^2\gamma{\mathbf{c}}dot R_G(g)^2\right).$$

	Here we distinguish between the following two cases: If $\lambda=(\gamma-1)/(2\gamma{\mathbf{c}}dot R_G(g))$ exactly, then the increase in $\Psi(G)$ is at least $\log(1+(\gamma-1)^2/(2\gamma) - (\gamma-1)^2/(4\gamma))\ge\log(1+(\gamma-1)^2/(4\gamma))=:c_\gamma$. On the other hand, if $\lambda=z(g)\le(\gamma-1)/(2\gamma{\mathbf{c}}dot R_G(g))$ then the increase in $\Psi(G)$ is at least $\log(1+\lambda\gamma{\mathbf{c}}dot R_G(g)-\lambda{\mathbf{c}}dot R_G(g)-\lambda(\gamma-1){\mathbf{c}}dot R_G(g)/2)>\log(1)=0$.

	Overall there are two possibilities each step:
	{\mathbf{b}}egin{enumerate}
		\item $\Psi(G)$ increases by at least $c_\gamma>0$,
		\item or $z(g)$ becomes $0$, and $\Psi(G)$ increases by a positive amount.
	{\mathbf{e}}nd{enumerate}

	Let the initial setting of $G$ (before the while-loop) be $G_0$. Let $G_\infty$ be the complete graph on $V$ with uniform edge weights of ${\mathbf{s}}um_{e\in E}w(e)$ on each edge. Since $G$ always satisfies
	$${\mathbf{s}}um_{f\in F}z(f)={\mathbf{s}}um_{e\in E}{\mathbf{s}}um_{f\in F_e}z(f)={\mathbf{s}}um_{e\in E}w(e),$$
	$\Psi(G)$ will always be less than $\Psi(G_\infty)$ by monotonicity of $\Psi$.

	Thus, there can be at most $(\Psi(G_\infty)-\Psi(G_0))/c_\gamma$ steps of type 1. Therefore, after a certain point, there can only be steps of type 2; we focus on this stage of the algorithm.

	We further categorize steps of type 2 based on the initial weight of $f$:

	{\mathbf{b}}egin{UR}
		\item The initial weight of $f$ is greater than $0$,
		\item the initial weight of $f$ is exactly $0$.
	{\mathbf{e}}nd{UR}

	 Steps of type 2a increase the total number of edges of weight exactly $0$, since by definition, neither $f$ nor $g$ starts out with weight $0$, but $z(g)$ becomes $0$. On the other hand, steps of type 2b do not decrease the total number of edges of weight $0$. Therefore, after a certain point, there can only be steps of type 2b; we focus on this stage of the algorithm.

	At this point, the set of all edge weight values, that is
	$${\mathbf{b}}igcup_{f\in F}\{z(f)\},$$
	remains unchanged. Indeed at every step we simply switch the values of $z(f)$ and $z(g)$. Therefore, there are only a finite number of possible states for $G$ to be in. None of these can be repeated, as $\Psi(G)$ increases by a positive amount after each step, and therefore, Algorithm~\ref{alg:greedy-balanced} must terminate, returning a $\gamma$-balanced weight assignment of $H$.
{\mathbf{e}}nd{proof}

This proves the existence of $\gamma$-balanced weight assignment, which suffices to show the existence of nearly-linear-sized spectral sparsifiers (as we will see in Section~\ref{sec:main}). Unfortunately, the above proof shows no bound on the running time of Algorithm~\ref{alg:greedy-balanced} beyond $2^{O(m)}$.

{\mathbf{s}}ubsection{Polynomial-Time Construction}

In this section, we introduce a relaxation of the concept of $\gamma$-balanced weight assignment. This will still be sufficient to get spectral sparsifiers of nearly linear size, while also allowing the greedy algorithm to terminate in a polynomial number of steps.

{\mathbf{b}}egin{definition}\label{def:weighted-approx-balanced}
	For $0<{\mathbf{e}}ta \le1$ and $\gamma > 1$, an ${\mathbf{e}}ta$-approximate $\gamma$-balanced weight assignment of $H=(V,E,w)$ is defined exactly as above in Definition~\ref{def:balanced}, except with the final condition relaxed to
	$$\gamma{\mathbf{c}}dot\min_{g\in F_e:\ z(g)\geq {\mathbf{e}}ta{\mathbf{c}}dot w(e)}R_G(g)\ge\max_{f\in F_e}R_G(f).$$
	That is, we allow edges not only of weight $0$, but also of weight less than ${\mathbf{e}}ta {\mathbf{c}}dot w(e)$ to be small outliers in terms of effective resistance.
{\mathbf{e}}nd{definition}

We modify Algorithm~\ref{alg:greedy-balanced} to search for approximate $\gamma$-balanced weight assignments.

{\mathbf{b}}egin{algorithm}[H]
	{\mathbf{b}}egin{algorithmic}[1]
		{\mathbf{c}}aption{Algorithm for constructing an ${\mathbf{e}}ta$-approximate $\gamma$-balanced weight assignment.}\label{alg:greedy-approx-balanced}
		\Procedure{GreedyApproxBalancing}{$H=(V,E,w),\gamma,{\mathbf{e}}ta$}
		\State For all $e\in E$ and for all $f\in F_e$, initialize $z(f)$ to $w(e)/{\mathbf{b}}inom{|e|}{2}$
		\State $G\gets(V,{\mathbf{b}}igcup F_e,z)$
		\While{$G$ is not an ${\mathbf{e}}ta$-approximate $\gamma$-balanced weight assignment of $H$}
		\State Select $e\in E$, and $f,g\in F_e$, such that $R_G(f)>\gamma{\mathbf{c}}dot R_G(g)$ and $z(g)>{\mathbf{e}}ta{\mathbf{c}}dot w(e)$\label{line:greedy-approx:select-problem-edge}
		\State $\lambda\gets\min\left(z(g),1/(2R_G(g))\right)$
		\State $z(f)\getsz(f)+\lambda$
		\State $z(g)\getsz(g)-\lambda$
		\EndWhile
		\State {{\mathbf{c}}al R}eturn $G$
		\EndProcedure
	{\mathbf{e}}nd{algorithmic}
{\mathbf{e}}nd{algorithm}

{\mathbf{b}}egin{theorem}\label{thm:greedy-approx-balanced}
	Let $H=(V,E,w)$ be a weighted hypergraph Then for $\gamma\ge4$ and ${\mathbf{e}}ta > 0$, Algorithm~\ref{alg:greedy-approx-balanced} terminates {\mathbf{e}}mph{within $M/({\mathbf{e}}ta w_{\min}){\mathbf{c}}dot{\mathbf{p}}oly{n\log(M/w_{\min})}$ rounds} and returns an ${\mathbf{e}}ta$-approximate $\gamma$-balanced weight assignment for $H$, where $w_{\min} := \min_{e\in E}w(e)$ and $M :={\mathbf{s}}um_{e\in E}w(e)$.
{\mathbf{e}}nd{theorem}

{\mathbf{b}}egin{proof}
	It is clear by the condition of the while-loop that if Algorithm~\ref{alg:greedy-approx-balanced} terminates, then it returns an ${\mathbf{e}}ta$-approximate $\gamma$-balanced weight assignment.
	Also, the condition ${\mathbf{s}}um_{f\in F_e}z(f)=w(e)$ is never violated.
	Therefore, in Line~\ref{line:greedy-approx:select-problem-edge}, there must indeed always be some $e\in E$ and some $f,g\in F_e$ such that $R_G(f)>\gamma$ and $z(g)>{\mathbf{e}}ta{\mathbf{c}}dot w(e)$, otherwise $G$ would already be ${\mathbf{e}}ta$-approximately $\gamma$-balanced.
	It remains to prove that Algorithm~\ref{alg:greedy-approx-balanced} terminates within $M/({\mathbf{e}}ta w_{\min}){\mathbf{c}}dot{\mathbf{p}}oly{n\log(M/w_{\min})}$ rounds.

	Let $G_0$ be the starting graph of Algorithm~\ref{alg:greedy-approx-balanced}, and $G_\infty$ be the complete graph on $V$ with uniform edge weights of $M$. Since $\Psi(G_\infty)$ is always greater than $\Psi(G)$ at every moment in the algorithm, we can upper bound the total increase in ST-potential throughout the algorithm by $\Psi(G_\infty)-\Psi(G_0)$. Let us upper bound $\Psi(G_\infty)-\Psi(G_0)$. To this end we will produce a sequence of updates to $G_0$ resulting in $G_\infty$, and we will upper bound the contribution of each update.

	Since $\min_{e\in E}w(e)=w_{\min}$, $\min_{f\in F}z(f)\ge w_{\min}/n^2$ in $G_0$. Furthermore, since $H$ is connected, $G_0$ is connected as well and must contain a spanning tree with edges of weight at least $w_{\min}/n^2$ and therefore $\min_{u,v\in V}R_{G_0}(u,v)\le n/(w_{\min}/n^2) = n^3/w_{\min}$.

	To transform $G_0$ to $G_\infty$, we simply add to each vertex pair $(u,v)$ a sufficient amount of weight to make $w(u,v)=M$. This is an update of $+\lambda{\mathbf{c}}dot(u,v)$ with $\lambda\le M$ and $R(u,v)\le n^3/w_{\min}$, which contributes by at most $\log(Mn^3/w_{\min}+1)$ to $\Psi$ by Lemma~\ref{lem:Psi-update}.
	The total contribution of all such updates on the way from $G_0$ to $G_\infty$ is at most
	$${\mathbf{s}}um_{u,v\in V}\log\left({\mathbf{f}}rac{Mn^3}{w_{\min}} + 1\right)={\mathbf{p}}oly{n\log\left({\mathbf{f}}rac{M}{w_{\min}}\right)}.$$

	We now lower bound the minimum increase of $\Psi$ after each step of Algorithm~\ref{alg:greedy-approx-balanced}. We are able to do this thanks to the modification in Definition~\ref{def:weighted-approx-balanced} of {\mathbf{e}}mph{approximate} $\gamma$-balanced weight assignment.

	Due to Lemma~\ref{lem:greedy-step}, the contribution of each update to the potential $\Psi(G)$ is at least
	$$\log\left(1+\lambda\gamma{\mathbf{c}}dot R_G(g)-\lambda{\mathbf{c}}dot R_G(g)-\lambda^2\gamma{\mathbf{c}}dot R_G(g)^2\right)$$
	At each step, $\lambda$ is set to either $z(g)$ or $1/(2R_G(g))$.
	If $\lambda = 1/(2R_G(g))$, the increase in $\Psi(G)$ is at least $\log(1+(\gamma-1)/2 - \gamma/4)\ge\log(5/4)$. On the other hand, if $\lambda = z(g)\le1/(2R_G(g))$, then the increase in $\Psi(G)$ is at least
	{\mathbf{b}}egin{align*}
		\log(1+\lambda\gamma{\mathbf{c}}dot R_G(g)-\lambda{\mathbf{c}}dot R_G(g)-\lambda\gamma{\mathbf{c}}dot R_G(g)/2)&\ge\log(1+\lambda{\mathbf{c}}dot R_G(g))\\
		&=\log(1+z(g){\mathbf{c}}dot R_G(g))\\
		&\ge\log(1+{\mathbf{e}}ta{\mathbf{c}}dot w_{\min}{\mathbf{c}}dot R_G(g)).
	{\mathbf{e}}nd{align*}
	To lower bound this, note that for all $g$
	$$R_G(g)\ge R_{G_\infty}(g)={\mathbf{f}}rac2{Mn}.$$
	This gives us that after each round of the algorithm $\Psi(G)$ increases by at least
	\[
		\log(1+{\mathbf{e}}ta{\mathbf{c}}dot w_{\min}{\mathbf{c}}dot R_G(g)) \geq {\mathbf{f}}rac{2 {\mathbf{c}}dot 2{\mathbf{e}}ta w_{\min}/(nM)}{2 + 	2{\mathbf{e}}ta w_{\min}/(nM)} \geq {\mathbf{f}}rac{4{\mathbf{e}}ta w_{\min}/(nM)}{4} = {\mathbf{f}}rac{{\mathbf{e}}ta w_{\min}}{nM},
	\]
	where we used $\log(1+x) \geq (2x)/(2+x)$ for $x \geq 0$ in the first inequality and we assumed $n$ is sufficiently large in the second inequality.
	Thus the algorithm takes at most $M/({\mathbf{e}}ta w_{\min}){\mathbf{c}}dot{\mathbf{p}}oly{n\log(M/w_{\min})}$ steps.
{\mathbf{e}}nd{proof}

{\mathbf{s}}ection{Hypergraph Sparsification}\label{sec:main}
In this section, we prove the existence of a spectral sparsifier with a nearly linear number of hyperedges, that is, the first part of Theorem~\ref{thm:main}.
We discuss efficient construction of spectral sparsifier in Section~\ref{sec:speed-up}.

To construct a spectral sparsifier, we first produce a $1/n^2$-approximate $\gamma$-balanced weight assignment for the input hypergraph, where $\gamma \geq 4$.
We can use Algorithm~\ref{alg:greedy-approx-balanced} for this. We then assign to each hyperedge $e$ importance equal to the maximum effective resistance in $F_e$ (see Definition~\ref{def:balanced}). We then perform typical importance sampling on the hyperedges, oversampling by a factor of $\lambda$ (to be set later).
A formal description is given in Algorithm~\ref{alg:main}.

{\mathbf{b}}egin{algorithm}[H]
  {\mathbf{c}}aption{${\mathbf{e}}psilon$-spectral sparsification for a hypergraph, using importance sampling.}\label{alg:main}
	{\mathbf{b}}egin{algorithmic}[1]
		\Procedure{Sparsification}{$H=(V,E,w),G=(V,F,z),{\mathbf{e}}psilon,\lambda$}

		\State $zidetilde H=(V,zidetilde E,zidetilde w)\gets(V,{\mathbf{e}}mptyset,0)$
		{{\mathbf{c}}al F}orAll{$e\in E$}
			\State $R^{\max}(e)\gets\max_{f\in F_e}R_G(f)$
			\State $p(e)\gets\min(1,w(e){\mathbf{c}}dot R^{\max}(e){\mathbf{c}}dot\lambda)$
			\State With probability $p(e)$, $zidetilde E\gets E{\mathbf{c}}up\{e\}$ and $zidetilde w(e)\gets w(e)/p(e)$
		\EndFor
		\State {{\mathbf{c}}al R}eturn $zidetilde H$
		\EndProcedure
	{\mathbf{e}}nd{algorithmic}
{\mathbf{e}}nd{algorithm}

In the rest of this section, we show the correctness of this approach. We first bound the size of the hypergraph output by Algorithm~\ref{alg:main}. We then prove that the output $zidetilde H$ is indeed an ${\mathbf{e}}psilon$-spectral sparsifier of $H$---this is the technical core of the section.

{\mathbf{b}}egin{lemma}\label{lem:hypergraph_size}
Let $H=(V,E, w)$ be a weighted hypergraph and let $G=(V,F,z)$ be its $1/n^2$-approximate $\gamma$-balanced weight assignment for $\gamma\ge4$.
Then, Algorithm~\ref{alg:main} returns a hypergraph of expected size
${\mathbb E}(|zidetilde E|) \leq2\lambda\gamma n$.
{\mathbf{e}}nd{lemma}

{\mathbf{b}}egin{proof}
Each hyperedge $e$ contributes $p(e)\le w(e){\mathbf{c}}dot R^{\max}(e){\mathbf{c}}dot\lambda$ to ${\mathbb E}(|zidetilde E|)$,
and it thus suffices to bound
{\mathbf{b}}egin{align} \label{eq:hyper-eff-res-sum}
  {\mathbf{s}}um_{e\in E}w(e){\mathbf{c}}dot R^{\max}(e)\le2\gamma{\mathbf{c}}dot n.
{\mathbf{e}}nd{align}

We proceed to prove this inequality.
For each $e\in E$, let us partition $F_e$ into two groups,
$F_e^{(1)} = {\mathbf{s}}et{f\in F_e \mid \gamma{\mathbf{c}}dot R_G(f)\ge R^{\max}(e)}$
and the remaining edges $F_e^{(2)} = F_e{\mathbf{s}}etminus F_e^{(1)}$.
By Definition~\ref{def:weighted-approx-balanced},
these remaining edges $f\in F_e^{(2)}$ satisfy $z(f)\le w(e)/n^2$.
Then, by Fact~\ref{fact:eff-res-sum}, we have

{\mathbf{b}}egin{align*}
  n-1
  &={\mathbf{s}}um_{f\in F}z(f){\mathbf{c}}dot R_G(f)
  ={\mathbf{s}}um_{e\in E}{\mathbf{s}}um_{f\in F_e}z(f){\mathbf{c}}dot R_G(f)

  \ge{\mathbf{s}}um_{e\in E}{\mathbf{s}}um_{f\in F_e^{(1)}}z(f){\mathbf{c}}dot{\mathbf{f}}rac1\gamma{\mathbf{c}}dot R^{\max}(e) ,
{\mathbf{e}}nd{align*}
where the second equality is due to the fact that $F$ is the multiset ${\mathbf{b}}igcup_{e \in E} F_e$ by Definition~\ref{def:balanced}.
For the inner summation, we can bound
{\mathbf{b}}egin{align*}
  {\mathbf{s}}um_{f\in F_e^{(1)}}z(f)
  \ge {\mathbf{s}}um_{f\in F_e}z(f) - {\mathbf{s}}um_{f\in F_e^{(2)}} {\mathbf{f}}rac{w(e)}{n^2}
  \ge w(e) - {\mathbf{f}}rac12{\mathbf{c}}dot w(e)
  = {\mathbf{f}}rac12{\mathbf{c}}dot w(e),
{\mathbf{e}}nd{align*}
\iffalse
\rnote{I shortened and slightly simplified what was a lengthy manipulation (I kept the old version commented out). }
	{\mathbf{b}}egin{align*}
	n-1&={\mathbf{s}}um_{f\in F}z(f){\mathbf{c}}dot R_G(f)\\
	&={\mathbf{s}}um_{e\in E}{\mathbf{s}}um_{f\in F_e}z(f){\mathbf{c}}dot R_G(f)\\
	&={\mathbf{s}}um_{e\in E}\left({\mathbf{s}}um_{f\in F_e^{(1)}}z(f){\mathbf{c}}dot R_G(f)+{\mathbf{s}}um_{f\in F_e^{(2)}}z(f){\mathbf{c}}dot R_G(f)\right)\\
	&\ge{\mathbf{s}}um_{e\in E}\left({\mathbf{s}}um_{f\in F_e^{(1)}}z(f){\mathbf{c}}dot{\mathbf{f}}rac1\gamma{\mathbf{c}}dot R^{\max}(e)+{\mathbf{s}}um_{f\in F_e^{(2)}}z(f){\mathbf{c}}dot R_G(f)\right)\\
	&={\mathbf{s}}um_{e\in E}\left({\mathbf{s}}um_{f\in F_e}z(f){\mathbf{c}}dot{\mathbf{f}}rac1\gamma{\mathbf{c}}dot R^{\max}(e)-{\mathbf{s}}um_{f\in F_e^{(2)}}z(f){\mathbf{c}}dot \left({\mathbf{f}}rac1\gamma{\mathbf{c}}dot R(e)-R_G(f)\right)\right)\\
	&\ge{\mathbf{f}}rac1\gamma{\mathbf{c}}dot {\mathbf{s}}um_{e\in E}R(e){\mathbf{c}}dot{\mathbf{s}}um_{f\in F_e}z(f)-{\mathbf{f}}rac1\gamma{\mathbf{c}}dot {\mathbf{s}}um_{e\in E}R(e){\mathbf{c}}dot{\mathbf{s}}um_{f\in F_e^{(2)}}z(f)\\
	&\ge{\mathbf{f}}rac1\gamma{\mathbf{c}}dot{\mathbf{s}}um_{e\in E}w(e){\mathbf{c}}dot R(e)-{\mathbf{f}}rac1\gamma{\mathbf{s}}um_{e\in E}R(e){\mathbf{c}}dot{\mathbf{s}}um_{f\in F_e^{(2)}}{\mathbf{f}}rac{w(e)}{n^2}\\
	&\ge{\mathbf{f}}rac1\gamma{\mathbf{c}}dot{\mathbf{s}}um_{e\in E}w(e){\mathbf{c}}dot R(e)-{\mathbf{f}}rac1{2\gamma}{\mathbf{s}}um_{e\in E}w(e){\mathbf{c}}dot R(e)\\
	&={\mathbf{f}}rac1{2\gamma}{\mathbf{c}}dot{\mathbf{s}}um_{e\in E}w(e){\mathbf{c}}dot R(e).
	{\mathbf{e}}nd{align*}
{\mathbf{f}}i
and altogether we obtain
${\mathbf{s}}um_{e\in E}w(e){\mathbf{c}}dot R^{\max}(e)\le2\gamma{\mathbf{c}}dot (n-1)$, which completes the proof. 
{\mathbf{e}}nd{proof}

Setting $\gamma=4$, for example, thus produces a linear-size output.
We now prove that the output is indeed a spectral sparsifier of $H$.

{\mathbf{b}}egin{lemma}\label{lem:main}
Let $H=(V,E, w)$ be a weighted hypergraph and let $G=(V,F,z)$ be its $1/n^2$-approximate $\gamma$-balanced weight assignment for some {\mathbf{e}}mph{constant} $\gamma\ge4$. Then executing Algorithm~\ref{alg:main} on $H$, $G$, $1/n\le{\mathbf{e}}psilon<1$, and $\lambda=O(\log^3(n)/{\mathbf{e}}psilon^4)$,
returns with probability at least $1-O(\log(n)/n)$
an ${\mathbf{e}}psilon$-spectral sparsifier of $H$.
{\mathbf{e}}nd{lemma}

{\mathbf{b}}egin{proof}
We proceed similarly to our proof of Theorem~\ref{thm:ordinary-sparsification} in Section~\ref{sec:warm-up}.
By Definition~\ref{def:hyper-sparsifier},
we must prove that for every $x\in\mathbb R^V$,
{\mathbf{b}}egin{equation}\label{eq:hyper-main}
  \left|Q_H(x)-Q_{zidetilde H}(x)\right|\le{\mathbf{e}}psilon{\mathbf{c}}dot Q_H(x),
{\mathbf{e}}nd{equation}
Since Equation~{\mathbf{e}}qref{eq:hyper-main} is invariant to scaling,
we may assume without loss of generality that $x^{\mathbf{t}}op L_G x = 1$,
and we denote the set of such vectors by $S^G{\mathbf{s}}ubseteq\mathbb R^V$. Notice that $S^G$ is defined with respect to $L_G$ and not $Q_H$,
however it implies that $Q_H(x)\ge1$ because for all $x\in S^G$, 
	{\mathbf{b}}egin{align}\label{eq:hyper-Q-bound}
		Q_H(x)&={\mathbf{s}}um_{e\in E}w(e){\mathbf{c}}dot\max_{u^*,v^*\in e}(x_{u^*}-x_{v^*})^2={\mathbf{s}}um_{e\in E}{\mathbf{s}}um_{f\in F_e}z(f) {\mathbf{c}}dot \max_{u^*,v^*\in e}(x_{u^*}-x_{v^*})^2\\
		&\ge{\mathbf{s}}um_{e\in E}{\mathbf{s}}um_{f=(u,v)\in F_e}z(f){\mathbf{c}}dot(x_u-x_v)^2\label{eq:G-vs-H}={\mathbf{s}}um_{f=(u,v)\in F}z(f){\mathbf{c}}dot(x_u-x_v)^2\nonumber=x^{\mathbf{t}}op L_G x\nonumber=1.\nonumber
	{\mathbf{e}}nd{align}

For any $E'{\mathbf{s}}ubseteq E$, we denote the quadratic form $Q(x)$ restricted only to the hyperedges $E'$ in $H$ by $Q_{E'}(x)$,
and similarly in the hypergraph $zidetilde H$ by $zidetilde Q_{E'}(x)$.
If $E'=E$, we omit the subscript.
It is clear by the construction of $zidetilde H$ that
$$\mathbb E\left(zidetilde Q(x)\right)=Q(x).$$
Therefore, for any specific vector $x$, Equation~{\mathbf{e}}qref{eq:hyper-main} holds by Chernoff bound (Theorem~\ref{thm:chernoff}). In order to prove it simultaneously for all $x\in S^G$, we again use progressively finer and finer roundings of $x$, as guaranteed by Lemma~\ref{lem:rounding}.

Indeed, fix a sequence of the rounding functions $\varphi_i$ guaranteed by Lemma~\ref{lem:rounding} for $i=1,\ldots,I:=\log_2(14\gamma n/{\mathbf{e}}psilon)\le3\log n$ (since $\gamma$ is a fixed constant and $n$ is sufficiently large),
and denote the sequence of rounded vectors for $x\in S^G$ by $x^{(i)}=\varphi_i(x)$.
We define for each $x^{(i)}$ the set of hyperedges 
$$E_i':=\left\{e\in E\;\middle|\;\max_{u,v\in e}\left(x_u^{(i)}-x_v^{(i)}\right)^2\ge2^{-i}{\mathbf{c}}dot R^{\max}(e)\right\},$$
where by definition $R^{\max}(e) = \max_{f\in F_e}R_G(f)$.
This set $E'_i$ is designed such that the rounding $\varphi_i$ will conserve (to within a small multiplicative error) $Q_{\{e\}}(x)$ for any $e\in E_i'$ (we will see a proof of this fact later on).
We can now define a partition of $E$ based on the sets $E_i'$.
First, recall that $p(e)=\min(1,\lambda{\mathbf{c}}dot w(e){\mathbf{c}}dot R^{\max}(e))$,
and let the base case be $E_0 = E_0' := {\mathbf{s}}et{e\in E \mid p(e) = 1}$.
Then for each $i=1,\ldots,I$, let
$$
E_i:=E_i'{\mathbf{s}}etminus{\mathbf{b}}igcup_{j=0}^{i-1}E_j'.
$$
Finally, let $E_{I+1}:=E{\mathbf{s}}etminus{\mathbf{b}}igcup_{i=0}^I E_i'$.

	We begin with two useful claims that will help us bridge the gap between the ordinary graph and the hypergraph settings. First, we extend the second guarantee of Lemma~\ref{lem:rounding} to hyperedges.

{\mathbf{b}}egin{claim}\label{claim:hyper-rounding}
For all $x\in S^G$ and $e\in E$ such that
$$\max\left(\max_{u,v\in e}(x_u-x_v)^2,\max_{u,v\in e}(x_u^{(i)}-x_v^{(i)})^2\right)\ge2^{-i}{\mathbf{c}}dot R^{\max}(e),$$
we have
{\mathbf{b}}egin{equation}\label{eq:hyper-rounding}
\max_{u,v\in e}(x_u-x_v)^2 \in \left(1 {\mathbf{p}}m {\mathbf{f}}rac{\mathbf{e}}psilon7\right){\mathbf{c}}dot \max_{u,v\in e}(x_u^{(i)}-x_v^{(i)})^2.
{\mathbf{e}}nd{equation}
{\mathbf{e}}nd{claim}
{\mathbf{b}}egin{proof}
We focus on the case when $\max_{u,v\in e}(x_u^{(i)}-x_v^{(i)})^2\ge2^{-i}{\mathbf{c}}dot R^{\max}(e)$. The case when $\max_{u,v\in e}(x_u-x_v)^2\ge2^{-i}{\mathbf{c}}dot R^{\max}(e)$ follows by an identical argument.
	

For one direction,
let the pair $u^*,v^*\in e$ maximize $(x^{(i)}_{u}-x^{(i)}_{v})^2$.
Now
$$(x^{(i)}_{u^*}-x^{(i)}_{v^*})^2=\max_{u,v\in E}(x^{(i)}_u-x^{(i)}_v)^2\ge2^{-i}{\mathbf{c}}dot R^{\max}(e)=2^{-i}{\mathbf{c}}dot\max_{f\in F_e}R_G(f)\ge2^{-i}{\mathbf{c}}dot R_G(u^*,v^*),$$
hence the second guarantee of Lemma~\ref{lem:rounding} holds for $(u^*,v^*)$,
and consequently
$$(x^{(i)}_{u^*}-x^{(i)}_{v^*})^2\le\left(1-{\mathbf{f}}rac{\mathbf{e}}psilon7\right)^{-1}{\mathbf{c}}dot(x_{u^*}-x_{v^*})^2\le\left(1-{\mathbf{f}}rac{\mathbf{e}}psilon7\right)^{-1}{\mathbf{c}}dot\max_{u,v\in e}(x_u-x_v)^2.$$

The other direction follows by a similar argument, but is slightly more complicated. The asymmetry is due to our assumption (that $\max_{u,v\in e}(x_u^{(i)}-x_v^{(i)})\ge2^{-i}{\mathbf{c}}dot R^{\max}(e)$) being in terms of $x^{(i)}$ instead of $x$.

Let $u^*,v^*$ be a vertex pair $u,v\in e$ that maximizes $(x_u-x_v)^2$. Here we distinguish two cases: If $(x_{u^*}-x_{v^*})^2<2^{-i}{\mathbf{c}}dot R^{\max}(e)$, we are immediately done, since
$$\max_{u,v\in e}(x_u-x_v)^2=(x_{u^*}-x_{v^*})^2\le2^{-i}{\mathbf{c}}dot R^{\max}(e)\le\max_{u,v\in e}(x_u^{(i)}-x_v^{(i)})^2.$$

On the other hand, if $(x_{u^*}-x_{v^*})^2\ge2^{-i}{\mathbf{c}}dot R^{\max}(e)$, we proceed identically to the first half of the proof:
$$(x_{u^*}-x_{v^*})^2\ge2^{-i}{\mathbf{c}}dot R^{\max}(e)=2^{-i}{\mathbf{c}}dot\max_{f\in F_e}R_G(f)\ge2^{-i}{\mathbf{c}}dot R_G(u^*,v^*).$$
Therefore, the second guarantee of Lemma~\ref{lem:rounding} holds for $(u^*,v^*)$ in $G$, and in particular
\[
(x_{u^*}-x_{v^*})^2\le\left(1+{\mathbf{f}}rac{\mathbf{e}}psilon7\right){\mathbf{c}}dot(x_{u^*}^{(i)}-x_{v^*}^{(i)})^2\le\left(1+{\mathbf{f}}rac{\mathbf{e}}psilon7\right){\mathbf{c}}dot\max_{u,v\in e}(x_u^{(i)}-x_v^{(i)})^2.
{\mathbf{q}}edhere
\]
{\mathbf{e}}nd{proof}

We thus obtain an analogue to Corollary~\ref{cor:rounding} from Section~\ref{sec:warm-up}.

{\mathbf{b}}egin{corollary}\label{cor:hyper-rounding}
For every edge $e\in E_i$,
$$Q_{\{e\}}(x)\in \left(1 {\mathbf{p}}m {\mathbf{f}}rac{\mathbf{e}}psilon7\right){\mathbf{c}}dot Q_{\{e\}}(x^{(i)}).$$
The same holds also for $zidetilde Q_{\{e\}}$ (because it is a multiple of $Q_{\{e\}}$).
{\mathbf{e}}nd{corollary}

{\mathbf{b}}egin{proof}
	We have that $e\in E_i{\mathbf{s}}ubseteq E_i'$ and hence $\max_{u,v\in e}(x_u^{(i)}-x_v^{(i)})^2\ge2^{-i}{\mathbf{c}}dot R^{\max}(e)$. We can therefore apply Claim~\ref{claim:hyper-rounding} and scale up by $w(e)$ to get the desired result.
{\mathbf{e}}nd{proof}

Next, we prove an analogue to Claim~\ref{cl:power-bound} from Section~\ref{sec:warm-up}.

{\mathbf{b}}egin{claim}\label{cl:hyper-power-bound}
For all $i\in[I]$ and $e\in E_i$, we have
$$\max_{u,v\in e}(x_u^{(i)}-x_v^{(i)})^2\le3{\mathbf{c}}dot2^{-i}{\mathbf{c}}dot R^{\max}(e) .$$
{\mathbf{e}}nd{claim}

{\mathbf{b}}egin{proof}
The proof proceeds nearly identically to that of Claim~\ref{cl:power-bound}.

The condition of Claim~\ref{claim:hyper-rounding} holds for $e\in E_i$ and hence we have $\max_{u,v\in e}(x_u^{(i)}-x_v^{(i)})^2\le(1-{\mathbf{e}}psilon/7)^{-1}{\mathbf{c}}dot\max_{u,v\in e}(x_u-x_v)^2$.

Consider first the case $i=1$.
Let $u^*,v^*\in e$ maximize $(x_u-x_v)^2$.
Then by Fact~\ref{fact:eff-res} and since $x\in S^G$, we have
$\max_{u,v\in e}(x_u-x_v)^2=(x_{u^*}-x_{v^*})^2\le R_G(u^*,v^*){\mathbf{c}}dot x^{\mathbf{t}}op L_G x = R_G(u^*,v^*)$,
and we indeed get
{\mathbf{b}}egin{equation*}
{\mathbf{b}}egin{split}
\max_{u,v\in e}(x_u^{(i)}-x_v^{(i)})^2&\leq \max_{u,v\in e}(x_u-x_v)^2{\mathbf{c}}dot \left(1-{\mathbf{f}}rac{{\mathbf{e}}psilon}{7}\right)^{-1}\\
&\le R_G(u^*,v^*){\mathbf{c}}dot \left(1-{\mathbf{f}}rac{{\mathbf{e}}psilon}{7}\right)^{-1}\\
&\le R^{\max}(e){\mathbf{c}}dot \left(1-{\mathbf{f}}rac{{\mathbf{e}}psilon}{7}\right)^{-1}\\
&\le3{\mathbf{c}}dot 2^{-1}{\mathbf{c}}dot R^{\max}(e).
{\mathbf{e}}nd{split}
{\mathbf{e}}nd{equation*}

Now consider $i>1$, and suppose towards contradiction that
$\max_{u,v\in e} (x_u^{(i)}-x_v^{(i)})^2>3{\mathbf{c}}dot2^{-i}{\mathbf{c}}dot R^{\max}(e)$.
Notice that since $\max_{u,v\in e}(x_u-x_v)^2\ge2^{-i+1}{\mathbf{c}}dot R^{\max}(e)$, Claim~\ref{claim:hyper-rounding} still applies to $e$ with respect to $\varphi_{i-1}$.
Thus

{\mathbf{b}}egin{equation*}
{\mathbf{b}}egin{split}
\max_{u,v\in e}(x_u^{(i-1)}-x_v^{(i-1)})^2&\ge\max_{u,v\in e}(x_u-x_v)^2{\mathbf{c}}dot \left(1+{\mathbf{f}}rac{{\mathbf{e}}psilon}{7}\right)^{-1}\\
&\geq \max_{u,v\in e}(x_u^{(i)}-x_v^{(i)})^2{\mathbf{c}}dot \left(1-{\mathbf{f}}rac{{\mathbf{e}}psilon}{7}\right){\mathbf{c}}dot \left(1+{\mathbf{f}}rac{{\mathbf{e}}psilon}{7}\right)^{-1}\\
&\ge2^{-i+1}{\mathbf{c}}dot R^{\max}(e).
{\mathbf{e}}nd{split}
{\mathbf{e}}nd{equation*}

This implies that $e\in E_{i-1}'$,
which contradicts the assumption $e\in E_i$. 
{\mathbf{e}}nd{proof}

	\if 0

	As the final claim, we relate the total energy of $H$ and its weight assignment $G$ to each other. (Recall that the latter is exactly $1$ by definition.)

	{\mathbf{b}}egin{claim}\label{claim:H-vs-G}
		Let $H$ be a weighted hypergraph, and $G$ its weight assignment (see Definition~\ref{def:balanced}). Then for any $x\in\mathbb R^V$
		$$Q_{\{e\}}(x)\ge x^{\mathbf{t}}op L_G x.$$
	{\mathbf{e}}nd{claim}

	{\mathbf{b}}egin{proof}
		{\mathbf{b}}egin{align*}
			Q_{\{e\}}(x)&={\mathbf{s}}um_{e\in E}w(e){\mathbf{c}}dot\max_{u,v\in e}(x_u-x_v)^2\\
			&={\mathbf{s}}um_{e\in E}\max_{u,v\in E}(x_u-x_v)^2{\mathbf{s}}um_{f\in F_e}z(f)\\
			&\ge{\mathbf{s}}um_{e\in E}{\mathbf{s}}um_{f=(u,v)\in F_e}(x_u-x_v)^2\\
			&={\mathbf{s}}um_{f\in F}(x_u-x_v)^2\\
			&=x^{\mathbf{t}}op L_G x.
		{\mathbf{e}}nd{align*}
	{\mathbf{e}}nd{proof}

	{\mathbf{f}}i

We consider each group of hyperedges $E_i$ separately,
and prove that the quadratic form is well approximated on this subset with high probability, that is
$$zidetilde Q_{E_i}(x){\mathbf{a}}pprox Q_{E_i}(x).$$

{\mathbf{p}}aragraph{Hyperedges in $E_0$.}
By definition, for all $e\in E_0$, we have $p(e)=1$.
Therefore, $zidetilde Q_{E_0}(x) = Q_{E_0}(x)$ deterministically.

{\mathbf{p}}aragraph{Hyperedges in $E_i$ for $i\in[I]$.} Similarly to the case of ordinary graphs in Section~\ref{sec:warm-up}, we want to consider $x^{(i)}$ instead of $x$. We may do this due to Corollary~\ref{cor:hyper-rounding}.

Therefore, we can focus on proving that $Q_{E_i}(x^{(i)}){\mathbf{a}}pproxzidetilde Q_{E_i}(x^{(i)})$.

Consider a specific $i\in[I]$.
We wish to prove that with high probability,
simultaneously for all values of $x^{(i)}$ and $E^{(i)}$,
{\mathbf{b}}egin{equation}\label{eq:hyper-mid-i-main}
  \left|zidetilde Q_{E_i}(x^{(i)})-Q_{E_i}(x^{(i)})\right|\le{\mathbf{f}}rac{{\mathbf{e}}psilon{\mathbf{c}}dot Q(x)}{7I} .
{\mathbf{e}}nd{equation}
Since (by the first guarantee of Lemma~\ref{lem:rounding})
there are only finitely many values $(x^{(i)},E_i)$,
we can prove that Equation~{\mathbf{e}}qref{eq:hyper-mid-i-main} holds with high probability individually for each such pair,
and then use a union bound over all pairs.

The former can be done using Chernoff bounds (Theorem~\ref{thm:chernoff}); we begin with this.
Let us fix $x^{(i)}$ and $E_i$.
Recall that
$$zidetilde Q_{E_i}(x^{(i)})={\mathbf{s}}um_{e\in E_i}zidetilde w(e){\mathbf{c}}dot\max_{u,v\in e}(x_u^{(i)}-x_v^{(i)})^2$$
is the sum of independent random variables 
with expectation ${\mathbb E}(zidetilde Q_{E_i}(x^{(i)})) = Q_{E_i}(x^{(i)})$
because $\mathbb E(zidetilde w(e))=w(e)$ by definition.

To apply Chernoff bounds (Theorem~\ref{thm:chernoff}), we need to set the variables $a$, ${\mathbf{d}}elta$ and $\mu$.
We set ${\mathbf{d}}elta:={\mathbf{e}}psilon/(14I)$,
and using Corollary~\ref{cor:hyper-rounding},
we can bound
$$
  Q_{E_i}(x^{(i)})
  \le\left(1-{\mathbf{f}}rac{{\mathbf{e}}psilon}{7}\right)^{-1}{\mathbf{c}}dot Q_{E_i}(x)\le2Q(x)
  =: \mu.
$$
(This is true for an arbitrary preimage $x\in\varphi_i^{-1}(x^{(i)})$.)

We also need to set $a$ as an upper bound on the largest possible value of any variable of the form $zidetilde w(e){\mathbf{c}}dot\max_{u,v\in e}(x_u^{(i)}-x_v^{(i)})^2$ for $e\in E_i$.
Such a variable takes its maximum value when $e$ is sampled to the sparsifier $zidetilde H$, in which case $zidetilde w(e)=w(e)/p(e)=w(e)/(\lambda{\mathbf{c}}dot w(e){\mathbf{c}}dot R^{\max}(e))=1/(\lambda{\mathbf{c}}dot R^{\max}(e))$, since $e\not\in E_0$.
Therefore, the random variable in question is upper bounded,
using Claim~\ref{cl:hyper-power-bound}, by
$$
  \max_{e\in E_i}{\mathbf{f}}rac{\max_{u,v\in e}(x_u^{(i)}-x_v^{(i)})^2}{\lambda{\mathbf{c}}dot R^{\max}(e)}
  \le{\mathbf{f}}rac{3{\mathbf{c}}dot2^{-i}}{\lambda}
 =: a .
$$

Finally, Theorem~\ref{thm:chernoff} implies
{\mathbf{b}}egin{align*}
  \mathbb P\left(\left|Q_{E_i}(x^{(i)}-zidetilde Q_{E_i}(x^{(i)}))\right|\ge{\mathbf{f}}rac{{\mathbf{e}}psilon{\mathbf{c}}dot Q(x)}{7I}\right)

   &\le2{\mathbf{e}}xp\left(-{\mathbf{f}}rac{{\mathbf{d}}elta^2\mu}{3a}\right)\\
   &=2{\mathbf{e}}xp\left(-{\mathbf{f}}rac{{\mathbf{t}}frac{{\mathbf{e}}psilon^2}{196I^2}{\mathbf{c}}dot Q(x)}{3{\mathbf{c}}dot3{\mathbf{c}}dot2^{-i} / \lambda}\right)\\
   &\le2{\mathbf{e}}xp\left(-{\mathbf{f}}rac{{\mathbf{e}}psilon^2{\mathbf{c}}dot2^{i}{\mathbf{c}}dot\lambda}{10000\log^2(n)}\right)\\
   &=2{\mathbf{e}}xp\left(-{\mathbf{f}}rac{2000C\log(n){\mathbf{c}}dot2^i}{{\mathbf{e}}psilon^2}\right),
{\mathbf{e}}nd{align*}
where the last step is by setting $\lambda = 2{\mathbf{c}}dot10^7{\mathbf{c}}dot C\log^3(n)/{\mathbf{e}}psilon^4$.

We now turn to applying a union bound over all possible values of $(x^{(i)},E_i)$. Much like $F_i$ in the proof of Theorem~\ref{thm:ordinary-sparsification}, $E_i$ depends on all $E_j'$ for $j\le i$, which in turn depend on all $x^{(j)}$ for $j\le i$. Since $x^{(j)}=\varphi_j(x)$, by the first guarantee of Lemma~\ref{lem:rounding}, there are at most ${\mathbf{e}}xp(800C\log(n){\mathbf{c}}dot2^{j}/{\mathbf{e}}psilon^2)$ possible vectors $x^{(j)}$ (where $C$ is the absolute constant from Theorem~\ref{thm:rounding}). Therefore, the number of possible pairs $(x^{(i)},E_i)$ is at most
$${\mathbf{p}}rod_{j=1}^i{\mathbf{e}}xp\left({\mathbf{f}}rac{800C\log(n){\mathbf{c}}dot2^j}{{\mathbf{e}}psilon^2}\right)={\mathbf{e}}xp\left({\mathbf{s}}um_{j=1}^i{\mathbf{f}}rac{800C\log(n){\mathbf{c}}dot2^j}{{\mathbf{e}}psilon^2}\right)\le{\mathbf{e}}xp\left({\mathbf{f}}rac{1600C\log(n){\mathbf{c}}dot2^i}{{\mathbf{e}}psilon^2}\right).$$

Putting together the Chernoff bound and the union bound, we get that
Equation~{\mathbf{e}}qref{eq:hyper-mid-i-main} holds simultaneously for all values of $(x^{(i)},E_i)$ except with probability at most
$${\mathbf{e}}xp\left({\mathbf{f}}rac{1600C\log(n){\mathbf{c}}dot2^i}{{\mathbf{e}}psilon^2}\right){\mathbf{c}}dot2{\mathbf{e}}xp\left(-{\mathbf{f}}rac{2000C\log(n){\mathbf{c}}dot2^i}{{\mathbf{e}}psilon^2}\right)=2{\mathbf{e}}xp\left(-{\mathbf{f}}rac{400C\log(n){\mathbf{c}}dot2^i}{{\mathbf{e}}psilon^2}\right)\le{\mathbf{f}}rac1n.$$

{\mathbf{p}}aragraph{Hyperedges in $E_{I+1}$.}
Recall that $I=\log_2(14\gamma{\mathbf{c}}dot n/{\mathbf{e}}psilon)$. First we show that for any hyperedge $e\in E_{I+1}$,
we have that $\max_{u,v\in e}(x_u-x_v)^2\le{\mathbf{e}}psilon{\mathbf{c}}dot R^{\max}(e)/(12\gamma{\mathbf{c}}dot n)$.
Indeed, suppose for contradiction that this is not the case,
and let $u^*,v^*\in e$ be a vertex pair that maximizes $(x_u-x_v)^2$.
Then, by the second guarantee of Lemma~\ref{lem:rounding}, we have that $(x^{(I)}_{u^*}-x_{v^*}^{(I)})^2\ge(x_{u^*}-x_{v^*})^2{\mathbf{c}}dot(1-{\mathbf{e}}psilon/7)\ge{\mathbf{e}}psilon{\mathbf{c}}dot R^{\max}(e){\mathbf{c}}dot(1-{\mathbf{e}}psilon/7)/(12\gamma{\mathbf{c}}dot n)\ge{\mathbf{e}}psilon{\mathbf{c}}dot R^{\max}(e)/(14\gamma{\mathbf{c}}dot n)$.
Therefore, $e \in E_I'$, which contradicts $e\in E_{I+1}$.

We show that $|zidetilde Q_{E_{I+1}}-Q_{E_{I+1}}|$ is small by showing that each of the two terms is individually small.

First,
{\mathbf{b}}egin{align*}
  Q_{E_{I+1}}(x)
  ={\mathbf{s}}um_{e\in E_{I+1}}w(e){\mathbf{c}}dot\max_{u,v\in e}(x_u-x_v)^2
  \le{\mathbf{s}}um_{e\in E_{I+1}}w(e){\mathbf{c}}dot{\mathbf{f}}rac{{\mathbf{e}}psilon{\mathbf{c}}dot R^{\max}(e)}{12\gamma{\mathbf{c}}dot n}
  \le{\mathbf{f}}rac{{\mathbf{e}}psilon}{12\gamma{\mathbf{c}}dot n}{\mathbf{c}}dot{\mathbf{s}}um_{e\in E}w(e){\mathbf{c}}dot R^{\max}(e)
  \le{\mathbf{f}}rac{{\mathbf{e}}psilon}{6},
{\mathbf{e}}nd{align*}
where the last inequality uses Equation~{\mathbf{e}}qref{eq:hyper-eff-res-sum}.

Second, we start similarly,
{\mathbf{b}}egin{align*}
  zidetilde Q_{E_{I+1}}(x)
  ={\mathbf{s}}um_{e\in E_{I+1}}zidetilde w(e){\mathbf{c}}dot\max_{u,v\in e}(x_u-x_v)^2
  \le{\mathbf{s}}um_{e\in E_{I+1}}zidetilde w(e){\mathbf{c}}dot{\mathbf{f}}rac{{\mathbf{e}}psilon{\mathbf{c}}dot R^{\max}(e)}{12\gamma{\mathbf{c}}dot n}
  \le{\mathbf{f}}rac{{\mathbf{e}}psilon}{12\gamma{\mathbf{c}}dot n}{\mathbf{c}}dot{\mathbf{s}}um_{e\in E}zidetilde w(e){\mathbf{c}}dot R^{\max}(e),
{\mathbf{e}}nd{align*}
and ideally we would like to show that ${\mathbf{s}}umzidetilde w(e){\mathbf{c}}dot R^{\max}(e)\le4\gamma{\mathbf{c}}dot n$.
This is a random event, independent of the choice of $x$,
whose probability we can bound using the Chernoff bound (Theorem~\ref{thm:chernoff}).
Recall that $E_0 = {\mathbf{s}}et{e\in E \mid p(e)=1}$,
and denote its complement by
$\overline E_0 := {\mathbf{s}}et{e\in E \mid p(e)=\lambda{\mathbf{c}}dot w(e){\mathbf{c}}dot R^{\max}(e)}$.
Since ${\mathbb E}({\mathbf{s}}umzidetilde w(e){\mathbf{c}}dot R^{\max}(e))={\mathbf{s}}um w(e){\mathbf{c}}dot R^{\max}(e)\le2\gamma{\mathbf{c}}dot n$
(using Equation~{\mathbf{e}}qref{eq:hyper-eff-res-sum})
and ${\mathbf{s}}um_{e\in E_0}zidetilde w(e){\mathbf{c}}dot R^{\max}(e)$ is deterministic by definition of $E_0$,
we have that
{\mathbf{b}}egin{align*}
  \mathbb P\left({\mathbf{s}}um_{e\in E}zidetilde w(e){\mathbf{c}}dot R^{\max}(e)\ge4\gamma{\mathbf{c}}dot n\right)
  &\le\mathbb P\left(\left|{\mathbf{s}}um_{e\in E}zidetilde w(e){\mathbf{c}}dot R^{\max}(e)-\mathbb E\left({\mathbf{s}}um_{e\in E}zidetilde w(e){\mathbf{c}}dot R^{\max}(e)\right)\right|\ge2\gamma{\mathbf{c}}dot n\right)\\
  &=\mathbb P\left(\left|{\mathbf{s}}um_{e\in\overline E_0}zidetilde w(e){\mathbf{c}}dot R^{\max}(e)-\mathbb E\left({\mathbf{s}}um_{e\in\overline E_0}zidetilde w(e){\mathbf{c}}dot R^{\max}(e)\right)\right|\ge2\gamma{\mathbf{c}}dot n\right).
{\mathbf{e}}nd{align*}

We bound this by applying Theorem~\ref{thm:chernoff} for the independent random variables $zidetilde w(e){\mathbf{c}}dot R^{\max}(e)$ where $e\in\overline E_0$.
The maximum value of such a variable occurs when $e$ is sampled, in which case it is exactly $zidetilde w(e){\mathbf{c}}dot R^{\max}(e)=R^{\max}(e){\mathbf{c}}dot w(e)/p(e)=1/\lambda\le1 =:a$.
Setting ${\mathbf{d}}elta := 1$ and $\mu := 2\gamma{\mathbf{c}}dot n$
(we may do this due to Equation~{\mathbf{e}}qref{eq:hyper-eff-res-sum}),
we get
$$\mathbb P\left({\mathbf{s}}um_{e\in E}zidetilde w(e){\mathbf{c}}dot R^{\max}(e) \ge 4\gamma{\mathbf{c}}dot n\right)\le2{\mathbf{e}}xp\left(-{\mathbf{f}}rac{2\gamma{\mathbf{c}}dot n}{3}\right)\le{\mathbf{f}}rac1n.$$

In conclusion, with probability at least $1-O(1/n)$,
{\mathbf{b}}egin{equation}\label{eq:hyper-I+1-main}
  \left|zidetilde Q_{E_{I+1}}(x)-Q_{E_{I+1}}(x)\right|\le{\mathbf{f}}rac{{\mathbf{e}}psilon}{2} .
{\mathbf{e}}nd{equation}

{\mathbf{p}}aragraph{Putting everything together.}
The final part of the proof proceeds identically to that of Theorem~\ref{thm:ordinary-sparsification}.
We have seen that Equation~{\mathbf{e}}qref{eq:hyper-mid-i-main} holds simultaneously for all $i$ and $(x^{(i)},E_i)$,
as well as Equation~{\mathbf{e}}qref{eq:hyper-I+1-main} holds with probability at least $1-O(\log(n)/n)$.
Conditioning on these events, we can deduce Equation~{\mathbf{e}}qref{eq:hyper-main},
thus concluding the proof of Lemma~\ref{lem:main}.

For completeness we repeat the derivation:
{\mathbf{b}}egin{align*}
	\left|Q_{E_i}(x)-zidetilde Q_{E_i}(x)\right|
	\le&\left|Q_{E_i}(x)-Q_{E_i}(x^{(i)})\right|+\left|Q_{E_i}(x^{(i)})-zidetilde Q_{E_i}(x^{(i)})\right|+\left|zidetilde Q_{E_i}(x^{(i)})-zidetilde Q_{E_i}(x)\right|\\
	\le&{\mathbf{f}}rac{{\mathbf{e}}psilon}{7}{\mathbf{c}}dot Q_{E_i}(x^{(i)}) + \left|Q_{E_i}(x^{(i)})-zidetilde Q_{E_i}(x^{(i)})\right| + {\mathbf{f}}rac{{\mathbf{e}}psilon}{7}{\mathbf{c}}dotzidetilde Q_{E_i}(x^{(i)}) {\mathbf{t}}ag{by Corollary~\ref{cor:hyper-rounding}}\\
	\le& {\mathbf{f}}rac{2{\mathbf{e}}psilon}{7}{\mathbf{c}}dot Q_{E_i}(x^{(i)}) + \left(1+{\mathbf{f}}rac{{\mathbf{e}}psilon}{7}\right){\mathbf{c}}dot\left|Q_{E_i}(x^{(i)})-zidetilde Q_{E_i}(x^{(i)})\right|\\
	\le& {\mathbf{f}}rac{2{\mathbf{e}}psilon}{7}{\mathbf{c}}dot \left(1-{\mathbf{f}}rac{{\mathbf{e}}psilon}{7}\right)^{-1}{\mathbf{c}}dot Q_{E_i}(x)+\left(1+{\mathbf{f}}rac{{\mathbf{e}}psilon}{7}\right){\mathbf{c}}dot{\mathbf{f}}rac{{\mathbf{e}}psilon{\mathbf{c}}dot Q(x)}{7I} {\mathbf{t}}ag{by Corollary~\ref{cor:hyper-rounding} and Equation~{\mathbf{e}}qref{eq:hyper-mid-i-main}}\\
	\le& {\mathbf{f}}rac{{\mathbf{e}}psilon}{3}{\mathbf{c}}dot Q_{E_i}(x)+{\mathbf{f}}rac{{\mathbf{e}}psilon{\mathbf{c}}dot Q(x)}{6I}.
{\mathbf{e}}nd{align*}
Therefore, we have
{\mathbf{b}}egin{align*}
	\left|Q(x)-zidetilde Q(x)\right|\le&\left|Q_{E_0}(x)-zidetilde Q_{E_0}(x)\right| +{\mathbf{s}}um_{i=1}^I \left| Q_{E_i}(x)-zidetilde Q_{E_i}(x)\right|+\left|Q_{E_{I+1}}(x)-zidetilde Q_{E_{I+1}}(x)\right|\\
	\le&0+{\mathbf{s}}um_{i=1}^I\left({\mathbf{f}}rac{{\mathbf{e}}psilon}{3}{\mathbf{c}}dot Q_{E_i}(x)+{\mathbf{f}}rac{{\mathbf{e}}psilon{\mathbf{c}}dot Q(x)}{6I}\right)+{\mathbf{f}}rac{{\mathbf{e}}psilon}{2} {\mathbf{t}}ag{by Equation~{\mathbf{e}}qref{eq:hyper-I+1-main}}\\
	\le&{\mathbf{f}}rac{{\mathbf{e}}psilon}{3}{\mathbf{c}}dot Q(x)+{\mathbf{f}}rac{{\mathbf{e}}psilon}{6}{\mathbf{c}}dot Q(x)+{\mathbf{f}}rac{{\mathbf{e}}psilon}{2}\\
	\le&{\mathbf{e}}psilon{\mathbf{c}}dot Q(x), {\mathbf{t}}ag{by Equation~{\mathbf{e}}qref{eq:hyper-Q-bound}}
{\mathbf{e}}nd{align*}
as claimed.
{\mathbf{e}}nd{proof}
Combining Theorem~\ref{thm:greedy-approx-balanced} and Lemmas~\ref{lem:hypergraph_size} and~\ref{lem:main}, we get the first part of Theorem~\ref{thm:main}.

{\mathbf{s}}ection{Nearly Optimal Speed-Up}\label{sec:speed-up}

In the previous section, we have proved the existence of nearly linear sized spectral sparsifiers for hypergraphs. We have also provided an method for constructing such sparsifiers: we construct an approximate balanced weight assignment of the input hypergraph using Algorithm~\ref{alg:greedy-approx-balanced}, and then construct a sparsifier using Algorithm~\ref{alg:main}. However, the running time of Algorithm~\ref{alg:greedy-approx-balanced} on an unweighted hypergraph is $m{\mathbf{c}}dot{\mathbf{p}}oly{n}$, which is large; in this section we improve this to $zidetilde{O}(mr) + {\mathbf{p}}oly{n}$, that is, we prove the second part of Theorem~\ref{thm:main}.
As we mentioned in the introduction, with a small modification, this leads to an algorithm with time complexity $zidetilde{O}({\mathbf{s}}um_{e \in E}|e| + {\mathbf{p}}oly{n})$ that constructs an ${\mathbf{e}}psilon$-spectral-sparsifier of nearly linear size.
This running time is optimal to within polylogarithmic factors in $n$, unless the size of the input hypergraph is polynomially small in $n$.

Our algorithm consists of two steps. First we apply the algorithm of~{\mathbf{c}}ite{Bansal2019}, which---with small modifications---can be shown to run in $zidetilde{O}(mr) + {\mathbf{p}}oly{n}$ time, but which produces a larger spectral sparsifier. We then aim to sparsify the resulting weighted hypergraph using our methods. Unfortunately, even though the resulting hypergraph has only polynomially many hyperedges (in $n$), the range of edge weights may still be exponential, meaning that Algorithm~\ref{alg:greedy-approx-balanced} is not efficient for finding an approximate balanced weight assignment on it (recall Theorem~\ref{thm:greedy-approx-balanced}). We propose a variation of Algorithm~\ref{alg:greedy-approx-balanced} adapted for this setting which runs in polynomial time.

{\mathbf{s}}ubsection{Fast Algorithm for Constructing Polynomial-Sized Sparsifiers}

In this section, we recall and slightly modify the algorithm of~{\mathbf{c}}ite{Bansal2019} for producing polynomial-sized spectral sparsifiers for hypergraphs.

{\mathbf{b}}egin{definition}\label{def:associated-graph}
	For a weighted hypergraph $H=(V,E)$, let $G(H)$ denote the ``associated  graph'' of $H$, which is defined as follows: Replace each hyperedge $e$ of $E$ with a clique of uniform weight $w(e)$ on the support of $e$. (Note that this may produce parallel edges.)
{\mathbf{e}}nd{definition}

{\mathbf{b}}egin{theorem}[{\mathbf{c}}ite{Bansal2019}]\label{thm:ola-sparsifiaction}
	Let $H=(V,E,w)$ be a hypergraph where all hyperedges have size between $r/2$ and $r$. Then, for some absolute constant $c$, the following process produces an ${\mathbf{e}}psilon$-spectral sparsifier for $H$ with probability at least $1-1/n$: Let $G(H)$ be the associated graph of $H$. For each hyperedge $e\in E$, let
	$$R^{\max}(e)=\max_{u,v \in e}R_{G(H)}(u,v).$$
	Sample each hyperedge $e$ independently with some probability
	{\mathbf{b}}egin{equation}\label{eq:bansal-et-al}
	p(e)\ge\min\left(1, {\mathbf{f}}rac{w(e){\mathbf{c}}dot R^{\max}(e){\mathbf{c}}dot r^4\log n}{c{\mathbf{e}}psilon^2}\right),
	{\mathbf{e}}nd{equation}
	and if sampled give it weight $zidetilde w(e)=w(e)/p(e)$.
{\mathbf{e}}nd{theorem}

{\mathbf{b}}egin{remark}
	In fact, in~{\mathbf{c}}ite{Bansal2019}, the result is stated slightly less generally, for unweighted hypergraphs, and without allowing oversampling (that is $p(e)$ is set {\mathbf{e}}mph{exactly} to the right hand side in Equation~\ref{eq:bansal-et-al}, instead of being lower bounded by it). However, this version holds by an identical proof.
{\mathbf{e}}nd{remark}

The trivial implementation of this takes time $\Omega(mr^2)$ in general for two different reasons: First, it takes $\Omega(mr^2)$ time to replace each of the $m$ hyperedges with a clique of size $r^2$. Second, it takes $\Omega(mr^2)$ time to find $\max_{u,v\in e}R_{G(H)}(u, v)$ for all $m$ hyperedges. However, with some simple tricks in the implementation both bottlenecks can be avoided to reduce the running time to $zidetilde O(mr+{\mathbf{p}}oly{n})$.

To achieve this, we first replace cliques in the associated graph of the input hypergraph with sparse graphs guaranteed by the following fact:

{\mathbf{b}}egin{fact}\label{fact:g-star}
	It follows by Theorem~\ref{thm:ordinary-sparsification} that for every $r$, there exists a (weighted) graph $G^*_r$ with $r$ vertices and $zidetilde O(r)$ edges such that $G^*_r$ is a $1/2$-spectral sparsifier to the $r$-clique.
{\mathbf{e}}nd{fact}
Second, to calculate $R^{\max}(e)$ approximately, we do not take the maximum over all pairs of vertices in $e$, but only over $(u_0,v)$ for all $v\in e$ but for some fixed $u_0$. Since effective resistance is a metric (see Fact~\ref{fact:eff-res-metric}), this provides a $2$-approximation to $R^{\max}(e)$ by triangle inequality.

{\mathbf{b}}egin{algorithm}[H]
	{\mathbf{c}}aption{Fast algorithm for computing a polynomial-sized spectral sparsifier for an approximately uniform hypergraph.}\label{alg:uniform-sparsification}
	{\mathbf{b}}egin{algorithmic}[1]
		\Procedure{UniformSparsification}{$H=(V,E,w),r,{\mathbf{e}}psilon$}
		\State $G=(V,F,z)\gets(V,{\mathbf{e}}mptyset,0)$
		{{\mathbf{c}}al F}orAll{$e\in E$}
			\State Add a copy of $G^*_{|e|}$ to $G$, supported on $e$, with weights scaled up by $w(e)$\label{line:bottleneck-1}
		\EndFor
		\State Calculate $R_G(u,v)$ for all $u,v\in V$
		\State $zidetilde H=(V,zidetilde E,zidetilde w)\gets(V,{\mathbf{e}}mptyset,0)$
		{{\mathbf{c}}al F}orAll{$e\in E$}
			\State $u_0\gets$ an arbitrary vertex in $e$
			\State $zidetilde R^{\max}(e)\gets\max_{v\in e}R_{G}(u_0,v)$\label{line:bottleneck-2}
			\State $p(e)\gets\min\left(1, {\mathbf{f}}rac{4w(e){\mathbf{c}}dot zidetilde R^{\max}(e){\mathbf{c}}dot r^4\log n}{c{\mathbf{e}}psilon^2}\right)$
			\State Add $e$ to $zidetilde{E}$ with probability $p(e)$ with weight $zidetilde w(e)\gets w(e)/p(e)$
		\EndFor
		\State {{\mathbf{c}}al R}eturn $zidetilde H$
		\EndProcedure
	{\mathbf{e}}nd{algorithmic}
{\mathbf{e}}nd{algorithm}

{\mathbf{b}}egin{lemma}\label{lem:uniform-sparsification}
	If the input hypergraph $H=(V,E,w)$ only has hyperedges of size between $r/2$ and $r$, then Algorithm~\ref{alg:uniform-sparsification} runs in $zidetilde O(mr)+{\mathbf{p}}oly{n}$ time, returning an ${\mathbf{e}}psilon$-spectral sparsifier to $H$ with probability at least $1-1/n$. Furthermore, the output has at most $4n^5\log n/(c{\mathbf{e}}psilon^2)$ hyperedges in expectation, where $c$ is the absolute constant from Theorem~\ref{thm:ola-sparsifiaction}.
{\mathbf{e}}nd{lemma}

{\mathbf{b}}egin{proof}
	It takes $zidetilde{O}(mr)$ time to construct the graph $G$ (here Line~\ref{line:bottleneck-1} takes $zidetilde O(r)$ time) and its Laplacian. All pairs effective resistances can then be calculated in ${\mathbf{p}}oly{n}$ time and stored in a table, resulting in an $O(r)$ time bound for the calculation of $zidetilde R^{\max}(e)$ in Line~\ref{line:bottleneck-2}.
	
	To show that the output is an ${\mathbf{e}}psilon$-spectral sparsifier of $H$ with high probability, it suffices to verify Equation~\ref{eq:bansal-et-al} of Theorem~\ref{thm:ola-sparsifiaction}, ie. that $p(e)$ is always at least $$w(e){\mathbf{c}}dot\max_{u,v\in e}R_{G(H)}(u,v){\mathbf{c}}dot {\mathbf{f}}rac{r^4\log n}{c{\mathbf{e}}psilon^2}.$$
	For this, it suffices to show that $zidetilde R^{\max}(e)$ (as defined in Line~\ref{line:bottleneck-2} of Algorithm~\ref{alg:uniform-sparsification}) is at least $\max_{u,v\in e}{\mathbf{a}}llowbreak R_{G(H)}(u, v)/4$. Since $w(e){\mathbf{c}}dot G_{|e|}^*$ is a $1/2$-spectral sparsifier of the clique on $e$ (of uniform edge weight $w(e)$), it follows by the additivity of Laplacians that $G$ from Algorithm~\ref{alg:uniform-sparsification} is a $1/2$-spectral sparsifier of $G(H)$ from Definition~\ref{def:associated-graph}. Therefore, $R_G(u, v)\ge R_{G(H)}(u,v)/2$ for all $u, v\in V$ (recall Definition~\ref{def:eff-res}). Finally, since $R_G$ is a metric on $V$ (by Fact~\ref{fact:eff-res-metric}),
	$$\max_{v\in e}R_G(u_0,v)\ge\max_{u,v\in e}R_G(u,v)/2.$$
	Indeed, if $(u^*,v^*)$ maximizes $R_G(u,v)$, then by triangle inequality $R_G(u^*,v^*)\le R_G(u^*,u_0) + R_G(u_0,v^*)$; one of the latter two must be at least $R_G(u^*,v^*)/2$.
	
	This concludes the proof of correctness; we must finally prove the upper bound on the expected size of the output $zidetilde H$.
	Since $r^4\le n^4$, it suffices to show that
	${\mathbf{s}}um_{e\in E}w(e){\mathbf{c}}dotzidetilde R^{\max}(e)\le n$. First note that
	$${\mathbf{s}}um_{e\in E}w(e){\mathbf{c}}dotzidetilde R^{\max}(e)\le{\mathbf{s}}um_{e\in E}w(e){\mathbf{c}}dot\max_{u,v\in e}R_G(u,v)\le2{\mathbf{s}}um_{e\in E}w(e){\mathbf{c}}dot R_{G(H)}(u,v),$$
	since $G$ is a $1/2$-spectral sparsifier of $G(H)$. Then, since the weight of $(u,v)$ in $G(H)$ is exactly $w(e)$ by definition, we have that
	$${\mathbf{s}}um_{e\in E}w(e){\mathbf{c}}dotzidetilde R^{\max}(e)\le{\mathbf{s}}um_{f\in F(H)}z_{G(H)}(f){\mathbf{c}}dot R_{G(H)}(f)=n-1,$$
	by Fact~\ref{fact:eff-res-sum}, where $F(H)$ denotes the edge-set of $G(H)$ and $z_{G(H)}$ denotes the weight function of $G(H)$.
{\mathbf{e}}nd{proof}

Algorithm~\ref{alg:uniform-sparsification} only works under the constraint that the input hypergraph is approximately uniform -- that is, the sizes of hyperedges all fall into the range $[r/2,r]$. This is easily circumvented, however: Given an arbitrary input hypergraph, one can simply partition the hyperedges into a logarithmic number of parts based on cardinality. We then sparsify the parts, and combine the resulting sparsifiers, losing only a $\log n$ factor in size.

We formalize this in the following algorithm and corollary.

{\mathbf{b}}egin{algorithm}[H]
	{\mathbf{c}}aption{Fast algorithm for computing a polynomial-sized spectral sparsifier for an arbitrary hypergraph.}\label{alg:poly-sparsification}
	{\mathbf{b}}egin{algorithmic}[1]
		\Procedure{PolynomialSizeSparsification}{$H=(V,E,w),{\mathbf{e}}psilon$}
		{{\mathbf{c}}al F}or{$i$ from $1$ to $\log n$}
			\State $E_i\gets\{e\in E{\mathbf{b}}ig||e|\in[2^i,2^{i+1})\}$
			\State $H_i\gets(V,E_i,w)$
			\State $zidetilde H_i\gets{\mathbf{t}}extsc{UniformSparsification}(H_i,2^{i+1},{\mathbf{e}}psilon)$\Comment{Algorithm~\ref{alg:uniform-sparsification}}
		\EndFor
		\State {{\mathbf{c}}al R}eturn $zidetilde H\gets{\mathbf{c}}up_{i=1}^{\log n}zidetilde H_i$
		\EndProcedure
	{\mathbf{e}}nd{algorithmic}
{\mathbf{e}}nd{algorithm}
Here the final line means that we take all hyperedges (with associated weights) from all of $zidetilde H_1,\ldots,zidetilde H_{\log n}$.

{\mathbf{b}}egin{corollary}\label{cor:poly-sparsification}
	Algorithm~\ref{alg:poly-sparsification} runs in $zidetilde O(mr)+{\mathbf{p}}oly{n}$ time, returning an ${\mathbf{e}}psilon$-spectral sprasifier of the input $H$ with probability at least $1-\log n/n$. Furthermore, the output has at most $4n^5\log^2(n)/(c{\mathbf{e}}psilon^2)$ hyperedges in expectation, where $c$ is the absolute constant from Theorem~\ref{thm:ola-sparsifiaction}.
{\mathbf{e}}nd{corollary}

{\mathbf{s}}ubsection{Even Faster Construction for $\gamma$-Balanced Weight Assignments}\label{sec:separated}

It is difficult to get a stronger bound on the number of rounds of Algorithm~\ref{alg:greedy-approx-balanced}, than that of Theorem~\ref{thm:greedy-approx-balanced}, at least in its full generality.
Instead, here we define a specific class of hypergraphs for which a better algorithm exists.

{\mathbf{b}}egin{definition}\label{def:separated}
A weighted hypergraph $H=(V,E,w)$ is called {\mathbf{e}}mph{$({\mathbf{a}}lpha,{\mathbf{b}}eta)$-separated}
for parameters ${\mathbf{a}}lpha\geq 1$ and ${\mathbf{b}}eta\geq 1$ if the hyperedge set $E$ is partitioned into $E_1,\ldots,E_{\mathbf{e}}ll$,
satisfying the two requirements:
{\mathbf{b}}egin{align*}
  &{\mathbf{t}}ext{for all~}i\in \{1,2,\ldots, {\mathbf{e}}ll\},
  &\max_{e\in E_i}w(e)\le{\mathbf{a}}lpha{\mathbf{c}}dot\min_{e\in E_i}w(e),
  \\
  &{\mathbf{t}}ext{for all~}i, j\in \{1,2,\ldots, {\mathbf{e}}ll\}, i<j,
  &\min_{e\in E_i}w(e)\ge{\mathbf{b}}eta{\mathbf{c}}dot\max_{e\in E_j}w(e).
{\mathbf{e}}nd{align*}
{\mathbf{e}}nd{definition}

Our next algorithm exploits the structure of separated hypergraphs in order to more efficiently construct approximate balanced weight assignments on them. Intuitively, one can think of the different weight classes in separated hypergraphs as only weakly interacting, which is the source of our speedup. In particular, it is important to note that we will get a speedup for hypergraphs where the total number of hyperedges is small in comparison to the amount of separation between the weight classes (i.e., hypergraphs that are produced by the sparsification procedure from the previous section)---this is what ultimately ensures that the different weight classes only interact in a limited manner.

{\mathbf{b}}egin{algorithm}[H]
	{\mathbf{c}}aption{Computing an ${\mathbf{e}}ta$-approximate $\gamma$-balanced weight assignment for an $({\mathbf{a}}lpha,{\mathbf{b}}eta)$-separated hypergraph.}\label{alg:separated-approx-balanced}
	{\mathbf{b}}egin{algorithmic}[1]
		\Procedure{SeparatedApproxBalancing}{$H=(V,E,w)$,$(E_i)_{i=1}^{\mathbf{e}}ll,{\mathbf{a}}lpha,{\mathbf{b}}eta,\gamma,{\mathbf{e}}ta$}
		\State For all $e\in E$ and for all $f\in F_e$ initialize $z(f) \gets w(e)/{\mathbf{b}}inom{|e|}{2}$
		\State $G\gets(V,{\mathbf{b}}igcup F_e,z)$
		{{\mathbf{c}}al F}or{$i = 1,\ldots,{\mathbf{e}}ll$}
		\While{there exists $e\in E_i$ violating the conditions of ${\mathbf{e}}ta$-approximate $\gamma$-balancedness}
		\State Select such $e\in E_i$ and $f,g\in F_e$, such that $R_G(f)>\gamma{\mathbf{c}}dot R_G(g)$ and $z(g)>{\mathbf{e}}ta{\mathbf{c}}dot w(e)$
		\State $\lambda\gets\min\left(z(g),1/(2R_G(g))\right)$
		\State $z(f)\getsz(f)+\lambda$
		\State $z(g)\getsz(g)-\lambda$
		\EndWhile
		\EndFor
		\State {{\mathbf{c}}al R}eturn $G$.\label{line:separated-return}
		\EndProcedure
	{\mathbf{e}}nd{algorithmic}
{\mathbf{e}}nd{algorithm}

In fact, Algorithm~\ref{alg:separated-approx-balanced} is very similar to Algorithm~\ref{alg:greedy-approx-balanced}. However, it corrects discrepancies in heavier hyperedges first, and once a category of hyperedges ($E_i$) has been corrected, the algorithm never goes back to it, {\mathbf{e}}mph{not even if the approximate balancedness becomes violated}. For this reason, the resulting output, $G$, will not necessarily be $\gamma$-balanced. However, the structure of separated hypergraphs will allow us to bound the number of rounds using ${\mathbf{a}}lpha$, instead of the global aspect ratio of weights, which could be much larger.

The crucial property of separated hypergraphs (and their weight assignments) which we exploit is that the heavier edges have a much greater influence on the effective resistance of a vertex pair than the lighter edges. More specifically, for some $i\in[{\mathbf{e}}ll]$ we can define the subgraph $G_+$ containing only edges in $F_e$ for $e\in E_j$ where $j\le i$. Then, when calculating the effective resistance $R_G(u,v)$---under certain circumstances---we can simply calculate $R_{G_+}(u,v)$ instead, ignoring the contribution of the remaining edges. We formalize this in the following lemma and its corollary.

{\mathbf{b}}egin{lemma}\label{lem:separated-eff-res}
	Let $G_+=(V,E_+,z_+)$ and $G_-=(V,E_-,z_-)$ be two weighted ordinary graphs on the same vertex set. Let the total weight of all edges in $G_-$ be bounded by ${\mathbf{z}}eta$. Let $G=G_+{\mathbf{c}}up G_-$ be the union of the two graphs, that is $G=(V,E_+{\mathbf{c}}up E_-,z_+{\mathbf{c}}upz_-)$. Then, for any vertex pair $(u,v)\in V$ in the same connected component of $G_+$, we can bound the effective resistance $R_G(u,v)$ in terms of $R_{G_+}$ as follows:
	$${\mathbf{f}}rac1{R_G(u,v)}\le{\mathbf{f}}rac1{R_{G_+}(u,v)}+{\mathbf{z}}eta.$$
{\mathbf{e}}nd{lemma}

{\mathbf{b}}egin{proof}
	To prove this inequality, we use the alternate definition of effective resistance from Fact~\ref{fact:eff-res}. That is
	$$R_{G_+}(u,v)=\max_{x\in\mathbb R^V}{\mathbf{f}}rac{(x_u-x_v)^2}{x^{\mathbf{t}}op L_{G_+}x}.$$
	Let $x^*$ maximize the above formula. We may assume without loss of generality that $x_u^*=0$ and $x_v^*=1$ since the formula is both shift and scale invariant. From this it follows that $x^{*{\mathbf{t}}op}L_{G_+}x^*=1/R_{G_+}(u,v)$. We can further assume without loss of generality that $x_a^*\in[0,1]$ for all $a\in V$. Indeed, let the connected component of $u$ and $v$ in $G_+$ be $C{\mathbf{s}}ubseteq V$. Then for $a\in V{\mathbf{s}}etminus C$, we may simply assume that $x^*_a$ is always $0$. To see that $x_a^*\in[0,1]$ for all $a\in C$, suppose for contradiction that $\max_{a\in C}x_a^*>1$. Let the highest value of $x^*$ in $C$ be $\mu_1>1$ and the second highest distinct value be $\mu_2$. Then one can change the $x^*$-value of vertices from $\mu_1$ to $\mu_2$, thereby strictly increasing the value of $(x^*_u-x^*_v)^2/x^{*{\mathbf{t}}op}L_{G_+}x^*$. This is a contradiction, since $x^*$ maximizes the formula by definition. An identical argument by contradiction rules out that $\min_{a\in C}x_a^*<0$.
	
	We can now upper bound $1/R_G(u,v)$ using the same alternate definition from Fact~\ref{fact:eff-res}:
	{\mathbf{b}}egin{align*}
	R_G(u,v)=&\max_{x\in\mathbb R^V}{\mathbf{f}}rac{(x_u-x_v)^2}{x^{\mathbf{t}}op L_G x}\ge{\mathbf{f}}rac{(x_u^*-x_v^*)^2}{x^{*{\mathbf{t}}op}L_G x^*}={\mathbf{f}}rac{1}{1/R_{G_+}(u,v)+x^{*{\mathbf{t}}op}L_{G_-}x^*}.
	{\mathbf{e}}nd{align*}
	Now
	$$x^{*{\mathbf{t}}op}L_{G_-}x^*={\mathbf{s}}um_{(a,b)\in E_-}z_-(a,b){\mathbf{c}}dot(x_a^*-x_b^*)^2\le{\mathbf{s}}um_{(a,b) \in E_-}z_-(a,b)\le{\mathbf{z}}eta.$$
	Therefore
	$${\mathbf{f}}rac1{R_G(u,v)}\le{\mathbf{f}}rac1{R_{G_+}(u,v)}+{\mathbf{z}}eta,$$
	as claimed.
{\mathbf{e}}nd{proof}

{\mathbf{b}}egin{corollary}\label{cor:separated-eff-res}
	Let $G_+=(V,E_+,z_+)$ and $G_-=(V,E_-,z_-)$ be two weighted ordinary graphs on the same vertex set. Let the total weight of all edges in $G_-$ be bounded by ${\mathbf{z}}eta$. Let $G=G_+{\mathbf{c}}up G_-$ be the union of the two graphs, that is $G=(V,E_+{\mathbf{c}}up E_-,z_+{\mathbf{c}}upz_-)$. Then for any vertex pair $u,v\in V$, if $R_G(u,v)\le1/(5{\mathbf{z}}eta)$ then we can bound the effective resistance $R_G(u,v)$ in terms of $R_{G_+}(u, v)$ as follows:
	$$R_G(u,v)\ge{\mathbf{f}}rac45{\mathbf{c}}dot R_{G_+}(u,v).$$
{\mathbf{e}}nd{corollary}

{\mathbf{b}}egin{proof}
	We wish to apply Lemma~\ref{lem:separated-eff-res}, for which we must first show that $u$ and $v$ are in the same connected component in $G_+$. This is indeed the case: If $u$ and $v$ are in different connected components of $G_+$, we can use the alternate definition of effective resistance from Fact~\ref{fact:eff-res}:
	$$R_G(u,v)=\max_{x\in\mathbb R^V}{\mathbf{f}}rac{(x_u-x_v)^2}{x^{\mathbf{t}}op L_G x}\ge{\mathbf{f}}rac{(x_u^0-x_v^0)^2}{x^{0{\mathbf{t}}op}L_G x^0},$$
	where $x^0$ is $0$ on the connected component of $u$ in $G_+$, and $1$ everywhere else (including $v$). Now
	$${\mathbf{f}}rac{(x_u^0-x_v^0)^2}{x^{0{\mathbf{t}}op}L_G x^0}={\mathbf{f}}rac{1}{x^{0{\mathbf{t}}op}L_{G_+}x^0+x^{0{\mathbf{t}}op}L_{G_-}x^0}={\mathbf{f}}rac{1}{x^{0{\mathbf{t}}op}L_{G_-}x^0}={\mathbf{f}}rac{1}{{\mathbf{s}}um_{(a,b)\in E_-}z_-(a,b){\mathbf{c}}dot(x_a^0-x_b^0)^2}\ge{\mathbf{f}}rac1{\mathbf{z}}eta.$$
	This is a contradiction; therefore, $u$ and $v$ are indeed in the same connected component of $G_+$.
	
	We can now apply Lemma~\ref{lem:separated-eff-res}:
	$${\mathbf{f}}rac1{R_{G_+}(u,v)}\ge{\mathbf{f}}rac1{R_G(u,v)} - {\mathbf{z}}eta\ge{\mathbf{f}}rac45{\mathbf{c}}dot{\mathbf{f}}rac1{R_G(u,v)},$$
	as claimed.
{\mathbf{e}}nd{proof}

We are now ready to analyze Algorithm~\ref{alg:separated-approx-balanced}.

{\mathbf{b}}egin{theorem}\label{thm:separated-approx-balanced}
Let $H=(V,E,w)$ be an $({\mathbf{a}}lpha,{\mathbf{b}}eta)$-separated weighted hypergraph with ${\mathbf{b}}eta\ge5|E|{\mathbf{c}}dot\gamma/{\mathbf{e}}ta$.
Let $M=w(E)$ be the total hyperedge weight in $H$,
and let $w_{\min}$ the minimum hyperedge weight.
Then for $\gamma\ge4$, Algorithm~\ref{alg:separated-approx-balanced} terminates {\mathbf{e}}mph{within ${\mathbf{a}}lpha/{\mathbf{e}}ta{\mathbf{c}}dot|E|^2{\mathbf{c}}dot{\mathbf{p}}oly{n\log(M/w_{\min})}$ rounds} and returns an ${\mathbf{e}}ta$-approximate $2\gamma$-balanced weight assignment for $H$.
{\mathbf{e}}nd{theorem}

{\mathbf{b}}egin{proof}
  We call executions of the while-loop rounds and executions of the for-loop phases. It will be useful to denote $w_{i,\min} := \min_{e\in E_i}w(e)$ and $w_{i,\max} := \max_{e\in E_i}w(e)$.
  The definition of separated hypergraphs (Definition~\ref{def:separated}) then ensures that $w_{i,\max}\le{\mathbf{a}}lpha{\mathbf{c}}dot w_{i,\min}$ and $w_{i,\min}\ge{\mathbf{b}}eta{\mathbf{c}}dot w_{i+1,\max}$.

\if 0
	The crucial property of separated hypergraphs (for sufficiently large ${\mathbf{a}}lpha$) is that the the effective resistance of a give vertex pair is dominated by the contribution of high weight edges and the contribution of low weight edges can be safely ignored. More formally, consider any phase $i$, and any intermediate weight assignment $G=(V,F,z)$. We can partition the edges of $G$ based on the weight of the corresponding hyperedge. Let $E_{\le i}$ and $E_{>i}$ denote ${\mathbf{c}}up_{j=1}^i E_j$ and ${\mathbf{c}}up_{j=i+1}^{\mathbf{e}}ll E_j$ respectively, Similarly, let $F_{\le i}$ and $F_{>i}$ denote ${\mathbf{c}}up_{e\in E_{\le i}}F_e$ and ${\mathbf{c}}up_{e\in E_{>i}}F_e$ respectively. Finally, let $G_{\le i}$ and $G_{>i}$ be $G$ restricted to $F_{\le i}$ and $F_{>i}$. Note that one can then calculate $R_G$ based on $G_{G_{\le i}}$ and $R_{G_{>i}}$ based on the formula of Fact~\ref{fact:parallel}.

	{\mathbf{b}}egin{claim}
		For any $i$, intermediate weight assignment $G$ from Algorithm~\ref{alg:separated-approx-balanced}, vertex pair $u,v\in V$, the following holds: Either $R_{G_{\le i}}(f)=\infty$ (that is the $u$ and $v$ are disconnected in $G_{\le i}$) or
		$${\mathbf{f}}rac45{\mathbf{c}}dot R_{G_{\le i}}(f)\le R_G(f)\le R_{G_{\le i}}(f).$$
	{\mathbf{e}}nd{claim}
	\jnote{this is not true}
{\mathbf{f}}i

{\mathbf{p}}aragraph{Algorithm Correctness.}
We first prove that upon termination, Algorithm~\ref{alg:separated-approx-balanced} indeed returns an ${\mathbf{e}}ta$-approximate $2\gamma$-balanced weight assignment.
Consider a hyperedge $e$ and edges $f,g\in F_e$, with $z(g)\geq {\mathbf{e}}ta{\mathbf{c}}dot w(e)$. We will show that $R_{G^*}(f)\le2\gamma{\mathbf{c}}dot R_{G^*}(g)$, where $G^*$ is the final weight assignment returned by the algorithm at Line~\ref{line:separated-return}. This is exactly what is required by the definition of approximate balancedness, i.e. Definition~\ref{def:weighted-approx-balanced}.
Suppose $e\in E_i$.
Note that by the condition of the while-loop, at the termination of the $i^{\mathbf{t}}ext{th}$ phase, $e$, $f$, and $g$ satisfied even the stronger condition of ${\mathbf{e}}ta$-approximate $\gamma$-balancedness.
Let us denote by $G'$ the weight assignment graph at the end of phase $i$.

Let us partition the edges of $G^*$ and $G'$ based on the weight of the corresponding hyperedge.
Denote $E_{\le i} := {\mathbf{b}}igcup_{j=1}^i E_j$ and $E_{>i} := {\mathbf{b}}igcup_{j=i+1}^{\mathbf{e}}ll E_j$.
Similarly, let $F_{\le i} := {\mathbf{b}}igcup_{e\in E_{\le i}}F_e$ and $F_{>i} := {\mathbf{b}}igcup_{e\in E_{>i}}F_e$.
Finally, let $G^*_{\le i}$ and $G^*_{>i}$ be $G^*$ restricted to $F_{\le i}$ and $F_{>i}$ respectively, and define $G'_{\le i}$ and $G'_{>i}$ similarly.
Note that $G^*_{\le i}=G'_{\le i}$, since the algorithm never alters the weight assignments of $E_{\le i}$ after phase $i$.

From here, we will use two applications of Corollary~\ref{cor:separated-eff-res}. First, set $G_+:=G_{\le i}'$, $G_-:=G_{>i}'$ (which makes $G=G'$), and $(u,v):=f$. Then ${\mathbf{z}}eta$ is the total weight of all edges in $G_{>i}'$, which is the total weight of all hyperedges in $E_{>i}$, which is at most $w_{i+1,\max}{\mathbf{c}}dot|E|$. We verify the condition on $R_{G'}(f)$ from Corollary~\ref{cor:separated-eff-res}: $R_{G'}(f)\le\gamma{\mathbf{c}}dot R_{G'}(g)$, by the approximate $\gamma$-balancedness condition on $e$ in $G'$. Since $z(g)\ge{\mathbf{e}}ta{\mathbf{c}}dot w(e)$ (in both $G^*$ and $G'$), we have that $z(g)\ge{\mathbf{e}}ta{\mathbf{c}}dot w_{i,\min}$, and hence by Fact~\ref{fact:w-R} $R_{G'}(g)\le1/({\mathbf{e}}ta{\mathbf{c}}dot w_{i,\min})$. Finally, putting these together, as well as using the $({\mathbf{a}}lpha,{\mathbf{b}}eta)$-separated quality of $H$, we get
$$R_{G'}(f)\le{\mathbf{f}}rac{\gamma}{{\mathbf{e}}ta{\mathbf{c}}dot w_{i,\min}}\le{\mathbf{f}}rac{\gamma}{{\mathbf{e}}ta{\mathbf{b}}eta{\mathbf{c}}dot w_{i+1,\max}}\le{\mathbf{f}}rac1{5{\mathbf{z}}eta},$$
by assumption on ${\mathbf{b}}eta$. We can indeed apply Corollary~\ref{cor:separated-eff-res}, which gives us
{\mathbf{b}}egin{equation}\label{eq:rgf-bound}
	R_{G'}(f)\ge{\mathbf{f}}rac45{\mathbf{c}}dot R_{G_{\le i}}(f).
{\mathbf{e}}nd{equation}

We apply Corollary~\ref{cor:separated-eff-res} again, this time setting $G_+:=G^*_{\le i}$, $G_-:=G^*_{>i}$ (which makes $G=G^*$), and $(u,v):=g$. Then ${\mathbf{z}}eta\le w_{i+1,\max}{\mathbf{c}}dot|E|$ by an identical argument to the previous setting. We verify the condition on $R_{G^*}(g)$ from Corollary~\ref{cor:separated-eff-res}: $R_{G^*}(g)\le1/({\mathbf{e}}ta{\mathbf{c}}dot w_{i,\min})$ by Fact~\ref{fact:w-R}, since $z(g)\ge{\mathbf{e}}ta{\mathbf{c}}dot w(e)\ge{\mathbf{e}}ta{\mathbf{c}}dot w_{i,\min}$ by assumption (in both $G^*$ and $G'$). Therefore, by an identical derivation to the previous case $R_{G^*}(g)\le1/(5{\mathbf{z}}eta)$. We can indeed apply Corollary~\ref{cor:separated-eff-res}, which gives us
{\mathbf{b}}egin{equation}\label{eq:rgg-bound}
	R_{G^*}(g)\ge{\mathbf{f}}rac45{\mathbf{c}}dot R_{G_{\le i}}(g).
{\mathbf{e}}nd{equation}

Putting together Equations~{\mathbf{e}}qref{eq:rgf-bound} and~{\mathbf{e}}qref{eq:rgg-bound}, along with the fact that $f$ and $g$ satisfied the condition of approximate $\gamma$-balancedness at the time of $G'$ (that is at the end of phase $i$), we get
{\mathbf{b}}egin{align*}
R_{G^*}(f)
&\le R_{G_{\le i}}(f)
\le{\mathbf{f}}rac54{\mathbf{c}}dot R_{G'}(f)
\le{\mathbf{f}}rac{5\gamma}4{\mathbf{c}}dot R_{G'}(g)
\le{\mathbf{f}}rac{5\gamma}{4}{\mathbf{c}}dot R_{G_{\le i}}(g)
\le{\mathbf{f}}rac{25\gamma}{16}{\mathbf{c}}dot R_{G^*}(g)
\le2\gamma{\mathbf{c}}dot R_{G^*}(g),
{\mathbf{e}}nd{align*}
which concludes the proof that $G^*$ is ${\mathbf{e}}ta$-approximately $2\gamma$-balanced.

\if 0

Note that by assumption $z(g)\ge{\mathbf{e}}ta{\mathbf{c}}dot w(e)$ (in both $G$ and $G'$). Since $e\in E_i$, this means that $z(g)\ge{\mathbf{e}}ta{\mathbf{c}}dot w_{i,\min}$.
Therefore, by Fact~\ref{fact:w-R}, $R_{G'}(g)\le1/({\mathbf{e}}ta{\mathbf{c}}dot w_{i,\min})$,
and we get
$$
  \max(R_{G'}(f), R_{G'}(g))
  \le
  \gamma{\mathbf{c}}dot R_{G'}(g)
  \le
  {\mathbf{f}}rac{\gamma}{{\mathbf{e}}ta{\mathbf{c}}dot w_{i,\min}}.
$$
We can show that $R_{G_{>i}}(f)$, $R_{G_{>i}}(g)$, $R_{G'_{>i}}(f)$, and $R_{G'_{>i}}(g)$ must all be much greater, specifically at least $5$ times greater.
This is because both $G_{>i}$ and $G'_{>i}$ contain a total weight of at most $w_{i+1,\max}{\mathbf{c}}dot|E|$, and are dominated by $w_{i+1,\max}{\mathbf{c}}dot|E|{\mathbf{c}}dot K_V$ (that is the complete graph of uniform weight $w_{i+1,\max}{\mathbf{c}}dot|E|$).
Since all effective resistances decrease (or at least do not increase) with the augmentation of edge weights, it suffices to bound the effective resistances in $w_{i+1,\max}{\mathbf{c}}dot|E|{\mathbf{c}}dot K_V$.
The effective resistance of {\mathbf{e}}mph{any} vertex pair in $w_{i+1,\max}{\mathbf{c}}dot|E|{\mathbf{c}}dot K_V$
is at least $${\mathbf{f}}rac1{w_{i+1,\max}{\mathbf{c}}dot|E|{\mathbf{c}}dot n}\ge{\mathbf{f}}rac{{\mathbf{b}}eta}{w_{i,\min}{\mathbf{c}}dot|E|}\ge{\mathbf{f}}rac{5\gamma}{{\mathbf{e}}ta{\mathbf{c}}dot w_{i,\min}}\ge5{\mathbf{c}}dot\max(R_{G'}(f),R_{G'}(g)).$$
{\mathbf{y}}note{Why is the $n$ in the denominator dropped in the first inequality?}

Using this discrepancy and Fact~\ref{fact:parallel},
we can prove that the effective resistances of $f$ and $g$ in $G$
are dominated by the respective ones in $G_{\le i}$.

For $f$, we have
	{\mathbf{b}}egin{align}\label{eq:opt-speed-1}
		R_{G'}(f)&={\mathbf{f}}rac{1}{1/R_{G_{\le i}}(f)+1/R_{G'_{>i}}(f)}\nonumber\\
		R_{G_{\le i}}(f)&={\mathbf{f}}rac{1}{1/R_{G'}(f)-1/R_{G'_{>i}}(f)}\nonumber\\
		&={\mathbf{f}}rac{R_{G'}(f){\mathbf{c}}dot R_{G'_{>i}}(f)}{R_{G'_{>i}}(f)-R_{G'}(f)}\\
		&\le{\mathbf{f}}rac{R_{G'}(f){\mathbf{c}}dot R_{G'_{>i}}(f)}{{\mathbf{t}}frac45{\mathbf{c}}dot R_{G'_{>i}}(f)}\nonumber\\
		&={\mathbf{f}}rac{5R_{G'}(f)}{4}.\nonumber
	{\mathbf{e}}nd{align}
  {\mathbf{b}}egin{equation}\label{eq:opt-speed-1}
{\mathbf{f}}rac{1}{R_{G_{\le i}}(f)} = {\mathbf{f}}rac{1}{R_{G'}(f)} - {\mathbf{f}}rac{1}{R_{G_{>i}}(f)} \geq {\mathbf{f}}rac45 {\mathbf{c}}dot {\mathbf{f}}rac{1}{R_{G'}(f)}.
  {\mathbf{e}}nd{equation}
For $g$, by an identical application of Fact~\ref{fact:parallel}, we get that $R_{G_{\le i}}(g)\le5R_{G'}(g)/4\le R_{G_{>i}}(g)/4$. Therefore,
{\mathbf{b}}egin{align}\label{eq:opt-speed-2}
  {\mathbf{f}}rac1{R_G(g)}
  &={\mathbf{f}}rac1{R_{G_{\le i}}(g)}+{\mathbf{f}}rac1{R_{G_{>i}}(g)}
    \le{\mathbf{f}}rac54{\mathbf{c}}dot{\mathbf{f}}rac1{R_{G_{\le i}}(g)}.
{\mathbf{e}}nd{align}

Putting together Equations~{\mathbf{e}}qref{eq:opt-speed-1} and~{\mathbf{e}}qref{eq:opt-speed-2},
we have
{\mathbf{b}}egin{align*}
  R_G(f)
  &\le R_{G_{\le i}}(f)
    \le{\mathbf{f}}rac54{\mathbf{c}}dot R_{G'}(f)
    \le{\mathbf{f}}rac{5\gamma}4{\mathbf{c}}dot R_{G'}(g)
    \le{\mathbf{f}}rac{5\gamma}{4}{\mathbf{c}}dot R_{G_{\le i}}(g)
    \le{\mathbf{f}}rac{25\gamma}{16}{\mathbf{c}}dot R_G(g)
    \le2\gamma{\mathbf{c}}dot R_G(g),
{\mathbf{e}}nd{align*}
where the 1st and 4th inequalities are by monotonicity of effective resistance.
This concludes the proof, that $f$ and $g$ cannot violate the $2\gamma$-balancedness condition in $G$.

{\mathbf{f}}i

{\mathbf{p}}aragraph{Running Time.}
Next, we prove that Algorithm~\ref{alg:separated-approx-balanced} terminates within ${\mathbf{a}}lpha/{\mathbf{e}}ta{\mathbf{c}}dot|E|^2{\mathbf{c}}dot{\mathbf{p}}oly{n\log(M/w_{\min})}$ rounds.
Similarly to the proof of Theorem~\ref{thm:greedy-approx-balanced}, we can bound the total growth of the ST-potential over the course of the algorithm by defining $G_0$ and $G_\infty$. Specifically, if $G_0$ is the starting graph of Algorithm~\ref{alg:separated-approx-balanced} and $G_\infty$ is the complete graph of uniform edge weight $M$,
then as before,
$$\Psi(G_\infty)-\Psi(G_0)\le{\mathbf{p}}oly{n\log(M/w_{\min})}.$$

	We will now prove that the total number of rounds in the $i^{\mathbf{t}}ext{th}$ phase is at most $|E_i|{\mathbf{c}}dot{\mathbf{a}}lpha/{\mathbf{e}}ta{\mathbf{c}}dot|E|{\mathbf{c}}dot{\mathbf{p}}oly{n\log(M/w_{\min})}$. Due to Lemma~\ref{lem:greedy-step}, the contribution of each update to the potential $\Psi(G)$ is at least
	$$\log\left(1+\lambda\gamma{\mathbf{c}}dot R_G(g)-\lambda{\mathbf{c}}dot R_G(g)-\lambda^2\gamma{\mathbf{c}}dot R_G(g)^2\right).$$ Similarly to the proof of Theorem~\ref{thm:greedy-approx-balanced}, this either means that $\lambda=1/(2R_G(g))$ and therefore the increase to $\Psi$ is at least $\log(5/4)$, or that $\lambda=z(g)\le1/(2R_G(g))$, in which case the increase to $\Psi$ is at least $\log(1+z(g){\mathbf{c}}dot R_G(g))$. In the latter case, we further distinguish based on the value of $R_G(g)$.

	{\mathbf{b}}egin{enumerate}
		\item $\lambda=1/(2R_G(g))$. In this case the ST-potential increases by at least $\log(5/4)$, and so there can be at most ${\mathbf{p}}oly{n\log(M/w_{\min})}$ such rounds.
		\item $\lambda=z(g)$ and $R_G(g)>1/(5w_{i,\max}{\mathbf{c}}dot|E|)$. In this case the ST-potential increases by at least $\log(1+z(g){\mathbf{c}}dot R_G(g))$. Since $g$ was selected in this round, $z(g) \geq {\mathbf{e}}ta{\mathbf{c}}dot w(e)\ge{\mathbf{e}}ta{\mathbf{c}}dot w_{i,\min}$, and therefore the increase in $\Psi(G)$ is at least
		$$\log(1+z(g){\mathbf{c}}dot R_G(g))\ge\log\left(1+{\mathbf{f}}rac{{\mathbf{e}}ta{\mathbf{c}}dot w_{i,\min}}{5w_{i,\max}{\mathbf{c}}dot|E|}\right)\ge\log\left(1+{\mathbf{f}}rac{{\mathbf{e}}ta}{5{\mathbf{a}}lpha{\mathbf{c}}dot|E|}\right)\ge{\mathbf{f}}rac{{\mathbf{e}}ta}{10{\mathbf{a}}lpha{\mathbf{c}}dot|E|}.$$
		Thus, there can be at most ${\mathbf{a}}lpha/{\mathbf{e}}ta{\mathbf{c}}dot|E|{\mathbf{c}}dot{\mathbf{p}}oly{n\log(M/w_{\min})}$ such rounds.
		\item $\lambda=z(g)$ and $R_G(g)\le1/(5w_{i,\max}{\mathbf{c}}dot|E|)$. This is the most complicated case to analyze and we will be focusing on this for the rest of the proof.
	{\mathbf{e}}nd{enumerate}

	Suppose we are in the $i^{\mathbf{t}}ext{th}$ phase of Algorithm~\ref{alg:separated-approx-balanced} and we have $e\in E_i$ and $f,g\in F_e$ such that $R_G(f)>\gamma{\mathbf{c}}dot R_G(g)\ge4{\mathbf{c}}dot R_G(g)$. Further suppose that $R_G(g)\le1/(5w_{i,\max}{\mathbf{c}}dot|E|)$. Similarly to before, we divide $G$ into two graphs: $G_{<i}$ consisting of edges belonging to hyperedges from $E_j$ for $j<i$, and $G_{\ge i}$ consisting of edges belonging to hyperedges from $E_j$ for $j\ge i$. (Note that earlier in this proof we used the slightly different split into $G_{\le i}$ and $G_{>i}$.) We can again use Corollary~\ref{cor:separated-eff-res} to relate $R_G$ to $R_{G_{<i}}$.

	We apply Corollary~\ref{cor:separated-eff-res}, setting $G_+:=G_{<i}$, $G_-:=G_{\ge i}$ (which makes $G$ from Corollary~\ref{cor:separated-eff-res} the current graph $G$), and $(u,v):=g$. Then ${\mathbf{z}}eta$ is the total weight of all edges in $G_{\ge i}$, which is the total weight of all hyperedges in $E_{\ge i}$, which is at most $w_{i,\max}{\mathbf{c}}dot|E|$. Our above assumption $R_G(g)\le1/(5w_{i,\max}{\mathbf{c}}dot|E|)$ exactly guarantees that $R_G(g)\le1/(5{\mathbf{z}}eta)$ is satisfied and we can therefore apply Corollary~\ref{cor:separated-eff-res}:
	$$R_{G_{<i}}(g)\le{\mathbf{f}}rac54{\mathbf{c}}dot R_{G}(g)\le{\mathbf{f}}rac{5}{4\gamma}R_G(f)\le{\mathbf{f}}rac{5}{16}R_G(f)\le{\mathbf{f}}rac5{16}R_{G_{<i}}(g)<R_{G_{<i}}(f).$$
	
	\if 0
	
	On the other hand, $G_{\ge i}$ contains a total weight of at most $w_{i,\max}{\mathbf{c}}dot|E|$, and is dominated by $w_{i,\max}{\mathbf{c}}dot|E|{\mathbf{c}}dot K_V$ (that is the complete graph of uniform weight $w_{i,\max}{\mathbf{c}}dot|E|$). The effective resistance of {\mathbf{e}}mph{any} vertex pair in $w_{i,\max}{\mathbf{c}}dot|E|{\mathbf{c}}dot K_V$ is at least $1/(w_{i,\max}{\mathbf{c}}dot|E|{\mathbf{c}}dot n)$. (Therefore, this is a lower bound on the minimum effective resistance of {\mathbf{e}}mph{any} vertex pair in $G_{\ge i}$.) Combining this with Fact~\ref{fact:parallel}, we get
	{\mathbf{b}}egin{align*}
		{\mathbf{f}}rac1{R_{G_{<i}}(g)}&={\mathbf{f}}rac1{R_G(g)}-{\mathbf{f}}rac1{R_{G_{\ge i}}(g)}\ge{\mathbf{f}}rac45{\mathbf{c}}dot{\mathbf{f}}rac1{R_G(g)}\ge{\mathbf{f}}rac{16}5{\mathbf{c}}dot{\mathbf{f}}rac1{R_G(f)}\ge{\mathbf{f}}rac{16}5{\mathbf{c}}dot{\mathbf{f}}rac1{R_{G_{<i}}(f)}>{\mathbf{f}}rac1{R_{G_{<i}}(f)}.
	{\mathbf{e}}nd{align*}
	
	{\mathbf{f}}i

	In words, such weight transfers are always from edges of lower $G_{<i}$-resistance to those of strictly higher $G_{<i}$-resistance---a metric that never changes, since $G_{<i}$ is unchanged during the $i^{\mathbf{t}}ext{th}$ stage of the algorithm. Therefore, there cannot be $n^4{\mathbf{c}}dot|E_i|$ consecutive steps of type 3 in phase $i$. We prove this formally in the following claim.
	{\mathbf{b}}egin{claim}\label{claim:type-three}
		There cannot be $n^4{\mathbf{c}}dot|E_i|$ consecutive rounds of type 3 in phase $i$.
	{\mathbf{e}}nd{claim}
{\mathbf{b}}egin{proof}
	Suppose for contradiction that there is a sequence of $n^4{\mathbf{c}}dot|E_i|$ rounds of type 3. Then there must be a hyperedge $e\in E_i$ for which at least $n^4$ of these updates take place in $F_e$. We know that updates can only shift weight from $g$ to $f$ where $R_{G_{<i}}(f)>R_{G_{<i}}(g)$. Therefore, let us order the edges of $F_e$ by $R_{G_{<i}}$, that is, let $\rho:F_e{\mathbf{t}}o\mathbb N$ be such that the $j^{\mathbf{t}}ext{th}$ largest edge in terms of $R_{G_{<i}}$, say $f$, has $\rho(f)=j$ (breaking ties arbitrarily). Then we can define a local potential function for $e$:
	$${\mathbf{p}}si_e(G)={\mathbf{s}}um_{f\in F_e}\rho(f){\mathbf{c}}dot\mathbbm1(z(f)>0).$$
	Note that ${\mathbf{p}}si_e$ starts out as at most $1 + 2 + {\mathbf{c}}dots + |F_e|\le n^4$, and after every update of type 3 it decreases by at least one.
        Since we have no updates of any type other than 3 (by assumption),
        and updates to other hyperedges do not affect ${\mathbf{p}}si_e$,
        we arrive at the contradiction that ${\mathbf{p}}si_e$ must become negative.
{\mathbf{e}}nd{proof}

	As a result of Claim~\ref{claim:type-three}, every consecutive sequence of $n^4{\mathbf{c}}dot|E_i|$ rounds must contain an update of type 1 or 2. Since we showed that there are at most ${\mathbf{a}}lpha/{\mathbf{e}}ta{\mathbf{c}}dot|E|{\mathbf{c}}dot{\mathbf{p}}oly{n\log(M/w_{\min})}$ such updates, there can be at most $|E_i|{\mathbf{c}}dot{\mathbf{a}}lpha/{\mathbf{e}}ta{\mathbf{c}}dot|E|{\mathbf{c}}dot{\mathbf{p}}oly{n\log(M/w_{\min})}$ rounds in phase $i$. Summing this over all phases, we get that there can be at most ${\mathbf{a}}lpha/{\mathbf{e}}ta{\mathbf{c}}dot|E|^2{\mathbf{c}}dot{\mathbf{p}}oly{n\log(M/w_{\min})}$ rounds overall, as claimed.
{\mathbf{e}}nd{proof}

{\mathbf{s}}ubsection{Proof of the Second Part of Theorem~\ref{thm:main}}

We are now ready to prove the second part of Theorem~\ref{thm:main}.
Specifically, we prove that {\mathbf{t}}extsc{FastSparsification} (Algorithm~\ref{alg:final} below) provides the result of Theorem~\ref{thm:main}:

{\mathbf{b}}egin{algorithm}[H]
	{\mathbf{c}}aption{Algorithm constructing nearly linear-sized spectral sparsifier, in nearly linear time.}\label{alg:final}
	{\mathbf{b}}egin{algorithmic}[1]
		\Procedure{FastSparsification}{$H=(V,E,w)$}
		\State $H'=(V,E',w')\gets\Call{PolynomialSizeSparsification}{H,{\mathbf{e}}psilon/3}$\Comment{Algorithm~\ref{alg:poly-sparsification}}
		{{\mathbf{c}}al F}or{$i$ from $1$ to $n$}
			\State $E_i'\gets\{e\in E_i' \mid w'(e)\in[n^{10(i-1)},n^{10i})\}$\label{line:E-i-def}
		\EndFor
		\State $H'_1\gets(V,{\mathbf{b}}igcup_{j \in \{1,\ldots,n\}, j{\mathbf{t}}ext{~odd}} E_i,w')$\label{line:H1-def}
		\State $H'_2\gets(V,{\mathbf{b}}igcup_{j \in \{1,\ldots,n\}, j{\mathbf{t}}ext{~even}}E_i,w')$\label{line:H2-def}
		\State $G_1\gets\Call{SeparatedApproxBalancing}{H_1',(E_j)_{j{\mathbf{t}}ext{~odd}},n^{10},n^{10},4,1/n^2}$\Comment{Algorithm~\ref{alg:separated-approx-balanced}}
		\State $G_2\gets\Call{SeparatedApproxBalancing}{H_2',(E_j)_{j{\mathbf{t}}ext{~even}},n^{10},n^{10},4,1/n^2}$
		\State $\lambda \gets \textsc{T}heta({\mathbf{e}}psilon^{-4}\log^3 n)$
		\State $zidetilde H_1\gets\Call{Sparsification}{H_1',G_1,{\mathbf{e}}psilon/3,\lambda}$ \Comment{Algorithm~\ref{alg:main}}
		\State $zidetilde H_2\gets\Call{Sparsification}{H_2',G_2,{\mathbf{e}}psilon/3,\lambda}$
		\State {{\mathbf{c}}al R}eturn $zidetilde H\getszidetilde H_1{\mathbf{c}}upzidetilde H_2$
		\EndProcedure
	{\mathbf{e}}nd{algorithmic}
{\mathbf{e}}nd{algorithm}
In the final line $zidetilde H\getszidetilde H_1{\mathbf{c}}upzidetilde H_2$ means that we take the union of hyperedges and weight functions from $zidetilde H_1$ and $zidetilde H_2$, since both are on the same vertex set $V$.

{\mathbf{b}}egin{proofof}{the second part of Theorem~\ref{thm:main}}
	Indeed, Algorithm~\ref{alg:final} does exactly that. 
	

	First note a few observations about the steps of Algorithm~\ref{alg:final}: Notice that \Call{PolynomialSizeSparsification}{} produces hyperedge weights only in the range $[1,n^{10n})$, so $E'$ is partitioned into $E_i'$ for $i$ from $1$ to $n$. Next, $H_1'$ and $H_2'$ are indeed $(n^{10},n^{10})$-separated hypergraphs by the definitions in Lines~\ref{line:E-i-def},~\ref{line:H1-def}, and~\ref{line:H2-def}. Furthermore, note that ${\mathbf{b}}eta\ge5|E|{\mathbf{c}}dot\gamma/{\mathbf{e}}ta$ holds (as required by Theorem~\ref{thm:separated-approx-balanced}), since ${\mathbf{b}}eta=n^{10}$, ${\mathbf{e}}ta=1/n^2$, and $|E|=o(n^8)$ by the size guarantee of Corollary~\ref{cor:poly-sparsification}. Finally, $G_1$ and $G_2$ are $1/n^2$-approximate $8$-balanced weight assignments of $H_1'$ and $H_2'$ respectively, by Theorem~\ref{thm:separated-approx-balanced}.
	
	Therefore, by Lemma~\ref{lem:main}, $zidetilde H_1$ and $zidetilde H_2$ are ${\mathbf{e}}psilon/3$-spectral sparsifiers of $H_1'$ and $H_2'$ respectively. By the additivity of the hypergraph quadratic form $zidetilde H$ is an ${\mathbf{e}}psilon/3$-spectral sparsifier of $H'$. Since $H'$ is itself an ${\mathbf{e}}psilon/3$-spectral sparsifier of $H$, this means that $zidetilde H$ is an ${\mathbf{e}}psilon$-spectral sparsifier of $H$, as claimed.
	
	Moreover, by Lemma~\ref{lem:hypergraph_size}, $zidetilde H_1$ and $zidetilde H_2$ are both of size at most $O(n\log^3(n)/{\mathbf{e}}psilon^4)$ (since we set $\lambda$ to be $\textsc{T}heta(\log^3(n)/{\mathbf{e}}psilon^4)$), and therefore so is $zidetilde H$.
	
	Finally, Algorithm~\ref{alg:final} runs in time $zidetilde O(mr+{\mathbf{p}}oly{n})$. Indeed \Call{PolynomialSizeSparsification}{} runs in time $zidetilde O(mr) + {\mathbf{p}}oly{n}$, as shown in Lemma~\ref{cor:poly-sparsification}; \Call{SeparatedApproxBalancing}{} runs in time ${\mathbf{p}}oly{n}$ by Theorem~\ref{thm:separated-approx-balanced}, since ${\mathbf{a}}lpha={\mathbf{p}}oly{n}$ and $M={\mathbf{e}}xp(O(n))$; \Call{Sparsification}{} runs in time ${\mathbf{p}}oly{n}$, since the input hypergraph is of ${\mathbf{p}}oly{n}$ size.
{\mathbf{e}}nd{proofof}

{\mathbf{b}}ibliographystyle{alphaurl}
{\mathbf{b}}ibliography{999-bibliography}

{\mathbf{e}}nd{document}