Schmidt Decomposition

5 hours ~8 min read

Schmidt Decomposition

Every bipartite pure state, however tangled it looks, has a hidden diagonal form: a single sum that pairs one orthonormal vector on the left with one on the right. That canonical form is the Schmidt decomposition, and it falls straight out of the singular value decomposition of the coefficient matrix. Its weights — the Schmidt coefficients — are immune to anything either party can do locally, which is exactly why they, and the single number built from them (the entanglement entropy), are the measure of entanglement for pure states. This lesson turns the qualitative "entangled vs. not" of 1.4.1 into a quantitative dial.

Learning Objectives

After this lesson you will be able to:

  1. State and prove the Schmidt decomposition theorem from the SVD of the coefficient matrix.
  2. Read off the Schmidt coefficients, Schmidt rank, and Schmidt bases of a bipartite pure state.
  3. Show the Schmidt spectrum is a local-unitary invariant, and use Schmidt rank as the separability test.
  4. Define the entanglement entropy E=kλklog2λkE = -\sum_k\lambda_k\log_2\lambda_k and identify maximally entangled states by their flat spectrum.
  5. Compute Schmidt decompositions numerically with numpy.linalg.svd and interpret the spectrum.

Intuition

A bipartite state generally needs dAdBd_A d_B amplitudes — a whole matrix CC of them. The Schmidt decomposition says you can always rotate the local bases (a new basis for AA, a new basis for BB) so that this matrix becomes diagonal: the state collapses to a single sum kσkukvk\sum_k\sigma_k\lvert u_k\rangle\lvert v_k\rangle with at most min(dA,dB)\min(d_A,d_B) terms. The number of terms (the Schmidt rank) and the diagonal weights (the Schmidt coefficients σk\sigma_k) are intrinsic — choosing different starting bases, or applying any gates locally, just relabels uk\lvert u_k\rangle and vk\lvert v_k\rangle but never touches the σk\sigma_k. A product state is the special case of one term (σ=(1,0,)\sigma=(1,0,\dots)); a Bell state is the opposite extreme, a perfectly flat spectrum. So "how entangled is this pure state?" has a clean answer: look at how spread-out the Schmidt spectrum is, and the SVD hands it to you for free.


Theory

Setup: the coefficient matrix

From 1.4.1, any pure state of a bipartite system HAHB\mathcal{H}_A\otimes\mathcal{H}_B (dimensions dA,dBd_A,d_B) expands in product bases {iA}\{\lvert i\rangle_A\}, {jB}\{\lvert j\rangle_B\} as

Ψ=i=1dAj=1dBCijiAjB,CCdA×dB, \lvert\Psi\rangle = \sum_{i=1}^{d_A}\sum_{j=1}^{d_B} C_{ij}\,\lvert i\rangle_A\otimes\lvert j\rangle_B, \qquad C\in\mathbb{C}^{d_A\times d_B},

and normalization is ΨΨ=ijCij2=CF2=1\langle\Psi\lvert\Psi\rangle = \sum_{ij}|C_{ij}|^2 = \lVert C\rVert_F^2 = 1 (the Frobenius norm). The matrix CC holds everything about the state; the Schmidt decomposition is just its SVD, read as a statement about Ψ\lvert\Psi\rangle.

The theorem

Schmidt decomposition. For any pure state ΨHAHB\lvert\Psi\rangle\in\mathcal{H}_A\otimes\mathcal{H}_B there exist orthonormal sets {uk}HA\{\lvert u_k\rangle\}\subset\mathcal{H}_A and {vk}HB\{\lvert v_k\rangle\}\subset\mathcal{H}_B and unique reals σk>0\sigma_k > 0 with kσk2=1\sum_k\sigma_k^2 = 1 such that

 Ψ=k=1rσkukvk  \boxed{\ \lvert\Psi\rangle = \sum_{k=1}^{r}\sigma_k\,\lvert u_k\rangle\otimes\lvert v_k\rangle\ }

The σk\sigma_k are the Schmidt coefficients, rmin(dA,dB)r\le\min(d_A,d_B) is the Schmidt rank, and the {uk},{vk}\{\lvert u_k\rangle\},\{\lvert v_k\rangle\} are the Schmidt bases.

Proof. Apply the SVD (0.1.6) to the coefficient matrix: C=UΣVC = U\Sigma V^\dagger, with UU (dA×dAd_A\times d_A) and VV (dB×dBd_B\times d_B) unitary and Σ\Sigma diagonal with entries σk0\sigma_k\ge0 (the singular values). Componentwise Cij=kUikσk(V)kj=kσkUikVjkC_{ij} = \sum_k U_{ik}\,\sigma_k\,(V^\dagger)_{kj} = \sum_k\sigma_k\,U_{ik}\,\overline{V_{jk}}. Substitute:

Ψ=ijkσkUikVjkij=kσk(iUikiuk)(jVjkjvk). \lvert\Psi\rangle = \sum_{ij}\sum_k \sigma_k\,U_{ik}\,\overline{V_{jk}}\,\lvert i\rangle\lvert j\rangle = \sum_k \sigma_k\Big(\underbrace{\textstyle\sum_i U_{ik}\lvert i\rangle}_{\lvert u_k\rangle}\Big)\otimes \Big(\underbrace{\textstyle\sum_j \overline{V_{jk}}\lvert j\rangle}_{\lvert v_k\rangle}\Big).

Because UU is unitary its columns uk\lvert u_k\rangle are orthonormal; likewise the conjugated columns of VV give orthonormal vk\lvert v_k\rangle. Keeping only the rr strictly positive σk\sigma_k gives the boxed form. Normalization forces kσk2=CF2=1\sum_k\sigma_k^2 = \lVert C\rVert_F^2 = 1. The σk\sigma_k are the singular values of CC, which are unique; the Schmidt bases are unique up to phases (and up to rotation within any degenerate σk\sigma_k subspace). \blacksquare

The decisive feature: it is a single sum over one index kk, not a double sum over i,ji,j. One left vector is matched to exactly one right vector.

Schmidt rank and the separability test

The Schmidt rank r=rank(C)r = \operatorname{rank}(C) (number of nonzero σk\sigma_k) is the sharp measure of whether a pure state is entangled — exactly the criterion promised in 1.4.1 and 1.1.4:

  • r=1r = 1: Ψ=σ1u1v1\lvert\Psi\rangle = \sigma_1\lvert u_1\rangle\lvert v_1\rangle is a product state (separable). With σ1=1\sigma_1=1 this is just u1v1\lvert u_1\rangle\otimes\lvert v_1\rangle.
  • r2r \ge 2: entangled — no single product of local vectors can reproduce it.

The Schmidt spectrum is a local-unitary invariant

Suppose Alice applies UAU_A and Bob applies UBU_B. The coefficient matrix transforms as CUACUBC \to U_A\,C\,U_B^{\top} (Exercise E3; the transpose comes from UBU_B acting on the second factor). Left and right multiplication by unitaries does not change singular values (0.1.6). Hence:

 Local unitaries UAUB leave every Schmidt coefficient σk unchanged.  \boxed{\ \text{Local unitaries }U_A\otimes U_B\text{ leave every Schmidt coefficient }\sigma_k\text{ unchanged.}\ }

They only rotate the Schmidt vectors ukUAuk\lvert u_k\rangle\to U_A\lvert u_k\rangle, vkUBvk\lvert v_k\rangle\to U_B^*\lvert v_k\rangle. This is why the spectrum measures entanglement: it is precisely the part of the state that survives quotienting out each party's choice of local basis. Anything that genuinely changes entanglement must be a joint (entangling) operation.

Reduced states and entanglement entropy

The Schmidt coefficients are the bridge to the density-matrix formalism of Course 1.5. Tracing out one side of ΨΨ\lvert\Psi\rangle\langle\Psi\lvert (the partial trace, 1.5.2) gives diagonal reduced states in the Schmidt bases:

ρA=kσk2ukuk,ρB=kσk2vkvk. \rho_A = \sum_k \sigma_k^2\,\lvert u_k\rangle\langle u_k\lvert, \qquad \rho_B = \sum_k \sigma_k^2\,\lvert v_k\rangle\langle v_k\lvert .

So ρA\rho_A and ρB\rho_B share the same nonzero eigenvalues λk:=σk2\lambda_k := \sigma_k^2 — a striking fact: two subsystems of very different sizes have identically-shaped spectra. Since {λk}\{\lambda_k\} is a probability distribution (λk0\lambda_k\ge0, kλk=1\sum_k\lambda_k=1), we measure entanglement by its Shannon entropy (0.2.3):

 E(Ψ)=kλklog2λk=kσk2log2σk2 (the entanglement entropy, in ebits). \boxed{\ E(\Psi) = -\sum_k \lambda_k\log_2\lambda_k = -\sum_k \sigma_k^2\log_2\sigma_k^2\ }\quad\text{(the \textbf{entanglement entropy}, in ebits).}

It is symmetric (EA=EBE_A = E_B, since both sides share {λk}\{\lambda_k\}), zero iff the state is a product (r=1r=1), and — being a function of the LU-invariant spectrum — itself a local-unitary invariant.

Maximal entanglement = flat spectrum

EE is maximized when the distribution {λk}\{\lambda_k\} is uniform. For Schmidt rank rr, the maximum is E=log2rE = \log_2 r, attained when all σk=1/r\sigma_k = 1/\sqrt r. A state of two dd-dimensional systems is maximally entangled when σk=1/d\sigma_k = 1/\sqrt d for all kk, giving E=log2dE = \log_2 d and maximally mixed reduced states ρA=ρB=I/d\rho_A=\rho_B=I/d. For two qubits (d=2d=2) that is E=1E = 1 ebit — the Bell states (1.4.2), whose flat spectrum (12,12)(\tfrac1{\sqrt2},\tfrac1{\sqrt2}) is exactly what "maximally entangled" means. The entanglement entropy thus interpolates continuously from 00 (product) to log2d\log_2 d (maximal): a genuine dial, not a yes/no flag.


Worked Examples

Example 1 — The Bell state is already in Schmidt form

Φ+=12(00+11)\lvert\Phi^+\rangle = \tfrac1{\sqrt2}(\lvert00\rangle+\lvert11\rangle) has coefficient matrix C = \tfrac1{\sqrt2}\begin{psmallmatrix}1&0\\0&1\end{psmallmatrix} = \tfrac1{\sqrt2}I. Its singular values are both 12\tfrac1{\sqrt2}, so σ=(12,12)\sigma = (\tfrac1{\sqrt2},\tfrac1{\sqrt2}), Schmidt rank r=2r=2, with Schmidt bases {0,1}\{\lvert0\rangle,\lvert1\rangle\} on each side. The spectrum is flat, so λ=(12,12)\lambda = (\tfrac12,\tfrac12) and E=212log212=1E = -2\cdot\tfrac12\log_2\tfrac12 = 1 ebit — maximally entangled, with ρA=ρB=I/2\rho_A = \rho_B = I/2.

Example 2 — Entanglement as a continuous dial

Ψθ=cosθ00+sinθ11\lvert\Psi_\theta\rangle = \cos\theta\,\lvert00\rangle + \sin\theta\,\lvert11\rangle is already a Schmidt decomposition: C=diag(cosθ,sinθ)C = \operatorname{diag}(\cos\theta,\sin\theta), so σ=(cosθ,sinθ)\sigma = (\cos\theta,\sin\theta) (for θ[0,π4]\theta\in[0,\tfrac\pi4]) and λ=(cos2θ,sin2θ)\lambda = (\cos^2\theta,\sin^2\theta). The entanglement entropy is the binary entropy E(θ)=H2(cos2θ)E(\theta) = H_2(\cos^2\theta). At θ=0\theta=0 the state is 00\lvert00\rangle, a product (r=1r=1, E=0E=0); at θ=π4\theta=\tfrac\pi4 it is Φ+\lvert\Phi^+\rangle, maximal (E=1E=1); in between it is partially entangled. One parameter sweeps the whole range from separable to maximal.

Example 3 — One sign flip: product vs. maximal

Compare two states that look almost identical:

P=12(00+01+10+11),M=12(00+01+1011). \lvert P\rangle = \tfrac12(\lvert00\rangle+\lvert01\rangle+\lvert10\rangle+\lvert11\rangle), \qquad \lvert M\rangle = \tfrac12(\lvert00\rangle+\lvert01\rangle+\lvert10\rangle-\lvert11\rangle).

Their coefficient matrices are C_P = \tfrac12\begin{psmallmatrix}1&1\\1&1\end{psmallmatrix} and C_M = \tfrac12\begin{psmallmatrix}1&1\\1&-1\end{psmallmatrix} = \tfrac1{\sqrt2}H. The rows of CPC_P are identical, so rank(CP)=1\operatorname{rank}(C_P)=1: σ=(1,0)\sigma=(1,0), and indeed P=++\lvert P\rangle = \lvert+\rangle\lvert+\rangle is a product state, E=0E=0. But HH is unitary, so CM=12HC_M = \tfrac1{\sqrt2}H has both singular values equal to 12\tfrac1{\sqrt2}: σ=(12,12)\sigma=(\tfrac1{\sqrt2},\tfrac1{\sqrt2}), r=2r=2, E=1E=1M\lvert M\rangle is maximally entangled (it is Φ+\lvert\Phi^+\rangle dressed by a local HH). A single sign separates a product state from a Bell state, and only the Schmidt spectrum sees it at a glance.


Hands-on (Python)

import numpy as np

def schmidt(state, dA, dB, tol=1e-12):
    """Schmidt decomposition of a bipartite pure state (big-endian, A⊗B).
    Returns (sigma, U_cols, Vh_rows) keeping only sigma_k > tol."""
    C = state.reshape(dA, dB)                 # coefficient matrix C_{ij}
    U, s, Vh = np.linalg.svd(C)               # C = U diag(s) Vh
    keep = s > tol
    return s[keep], U[:, keep], Vh[keep, :]   # |u_k> = U[:,k], |v_k> = Vh[k,:]

def entanglement_entropy(sigma):
    """E = -sum lambda log2 lambda,  lambda = sigma^2 (in ebits)."""
    lam = sigma**2
    lam = lam[lam > 0]
    return float(max(0.0, -np.sum(lam * np.log2(lam))))   # entropy is nonnegative

# Build a few 2-qubit states (big-endian: index 2i+j ↔ |i>|j>):
def two_qubit(c00, c01, c10, c11):
    v = np.array([c00, c01, c10, c11], dtype=complex)
    return v / np.linalg.norm(v)

bell    = two_qubit(1, 0, 0, 1)               # |Φ+>
prod    = two_qubit(1, 1, 1, 1)               # |+>|+>  (Example 3, |P>)
maximal = two_qubit(1, 1, 1, -1)              # one sign flip (Example 3, |M>)

for name, st in [("Bell", bell), ("|+>|+>", prod), ("sign-flip", maximal)]:
    s, _, _ = schmidt(st, 2, 2)
    print(f"{name:>10}: sigma={np.round(s,3)}  rank={len(s)}  E={entanglement_entropy(s):.3f} ebits")
#       Bell: sigma=[0.707 0.707]  rank=2  E=1.000   (flat -> maximal)
#     |+>|+>: sigma=[1.]           rank=1  E=0.000   (product; the second σ≈0 is dropped)
#  sign-flip: sigma=[0.707 0.707]  rank=2  E=1.000   (Bell up to a local H)
# The dial of Example 2: E(θ) = H2(cos^2 θ), peaking at θ = π/4.
for theta in (0, np.pi/8, np.pi/4):
    st = two_qubit(np.cos(theta), 0, 0, np.sin(theta))
    s, _, _ = schmidt(st, 2, 2)
    print(f"θ={theta:.3f}: sigma={np.round(s,3)}  E={entanglement_entropy(s):.4f}")
# θ=0.000: sigma=[1.]           E=0.0000   (product)
# θ=0.393: sigma=[0.924 0.383]  E=0.6009   (partial)
# θ=0.785: sigma=[0.707 0.707]  E=1.0000   (maximal)

# Reconstruction check: Σ_k σ_k |u_k>⊗|v_k> rebuilds the state exactly.
s, U, Vh = schmidt(maximal, 2, 2)
rebuilt = sum(sk * np.kron(U[:, k], Vh[k, :]) for k, sk in enumerate(s))
print("reconstruct OK:", np.allclose(rebuilt, maximal))      # True

# Local-unitary invariance: H ⊗ I leaves the Schmidt spectrum unchanged.
H = np.array([[1, 1], [1, -1]], dtype=complex) / np.sqrt(2)
I2 = np.eye(2)
st2 = np.kron(H, I2) @ bell
print("σ after H⊗I:", np.round(schmidt(st2, 2, 2)[0], 3))    # [0.707 0.707] — unchanged

Numerical Schmidt rank. The rank is the count of singular values above a tolerance, never an exact equality test — finite precision turns a "zero" coefficient into something like 101610^{-16}. This is the careful version of the schmidt_rank helper from 1.4.1: pick tol comfortably above machine noise (here 101210^{-12}). The same SVD also drives the matrix-product-state truncation used in tensor-network simulators (Term 5.3).


Exercises

E1 (easy). Give the Schmidt coefficients, rank, and entanglement entropy of Ψθ=cosθ00+sinθ11\lvert\Psi_\theta\rangle = \cos\theta\lvert00\rangle+\sin\theta\lvert11\rangle for θ=0\theta=0, π6\tfrac\pi6, π4\tfrac\pi4.

Solution

It is already in Schmidt form: σ=(cosθ,sinθ)\sigma=(\cos\theta,\sin\theta). At θ=0\theta=0: σ=(1,0)\sigma=(1,0), rank 11, E=0E=0 (product). At θ=π6\theta=\tfrac\pi6: σ=(32,12)\sigma=(\tfrac{\sqrt3}2,\tfrac12), rank 22, E=H2(34)=34log23414log2140.811E = H_2(\tfrac34) = -\tfrac34\log_2\tfrac34-\tfrac14\log_2\tfrac14\approx0.811. At θ=π4\theta=\tfrac\pi4: σ=(12,12)\sigma=(\tfrac1{\sqrt2},\tfrac1{\sqrt2}), rank 22, E=1E=1 (maximal). ∎

E2 (easy). Why must kσk2=1\sum_k\sigma_k^2 = 1 for any normalized state?

Solution

Normalization gives 1=ΨΨ=ijCij2=CF21 = \langle\Psi\lvert\Psi\rangle = \sum_{ij}|C_{ij}|^2 = \lVert C\rVert_F^2, and the squared Frobenius norm equals the sum of squared singular values, CF2=kσk2\lVert C\rVert_F^2 = \sum_k\sigma_k^2. So kσk2=1\sum_k\sigma_k^2 = 1, which is also why λk=σk2\lambda_k=\sigma_k^2 is a valid probability distribution. ∎

E3 (medium). Show that under local unitaries the coefficient matrix transforms as CUACUBC \to U_A\,C\,U_B^{\top}, and conclude the Schmidt coefficients are unchanged.

Solution

$(U_A\otimes U_B)\lvert\Psi\rangle = \sum_{ij}C_{ij}(U_A\lvert i\rangle)\otimes(U_B\lvert j\rangle) = \sum_{ij}C_{ij}\sum_{i'}(U_A){i'i}\lvert i'\rangle\sum{j'}(U_B){j'j}\lvert j'\rangle$. The new coefficient of ij\lvert i'\rangle\lvert j'\rangle is $\sum{ij}(U_A){i'i}C{ij}(U_B){j'j} = (U_A C,U_B^{\top}){i'j'}$. Singular values are invariant under left/right multiplication by unitaries (UBU_B^{\top} is unitary since UBU_B is), so every σk\sigma_k — hence EE — is unchanged; only the Schmidt vectors rotate. ∎

E4 (medium). Without numerics, find the Schmidt rank and entanglement entropy of M=12(00+01+1011)\lvert M\rangle = \tfrac12(\lvert00\rangle+\lvert01\rangle+\lvert10\rangle-\lvert11\rangle).

Solution

C_M = \tfrac12\begin{psmallmatrix}1&1\\1&-1\end{psmallmatrix} = \tfrac1{\sqrt2}H with HH the (unitary) Hadamard. A unitary has all singular values 11, so CMC_M has both singular values 12\tfrac1{\sqrt2}: σ=(12,12)\sigma=(\tfrac1{\sqrt2},\tfrac1{\sqrt2}), rank 22, flat spectrum, E=1E=1 ebit. It is maximally entangled — a Bell state up to the local unitary HH on one qubit. ∎

E5 (medium). Prove that ρA=TrBΨΨ=kσk2ukuk\rho_A = \operatorname{Tr}_B\lvert\Psi\rangle\langle\Psi\lvert = \sum_k\sigma_k^2\lvert u_k\rangle\langle u_k\lvert, and deduce that ρA\rho_A is pure iff Ψ\lvert\Psi\rangle is a product state.

Solution

Write Ψ=kσkukvk\lvert\Psi\rangle=\sum_k\sigma_k\lvert u_k\rangle\lvert v_k\rangle. Then $\lvert\Psi\rangle\langle\Psi\lvert =\sum_{k,l}\sigma_k\sigma_l\lvert u_k\rangle\langle u_l\lvert\otimes\lvert v_k\rangle\langle v_l\lvert$. The partial trace over BB replaces vkvl\lvert v_k\rangle\langle v_l\lvert by vlvk=δkl\langle v_l\lvert v_k\rangle=\delta_{kl} (orthonormality), leaving ρA=kσk2ukuk\rho_A=\sum_k\sigma_k^2\lvert u_k\rangle\langle u_k\lvert — already diagonal, with eigenvalues λk=σk2\lambda_k=\sigma_k^2. ρA\rho_A is pure iff one eigenvalue is 11 and the rest 00, i.e. a single nonzero σk\sigma_k, i.e. Schmidt rank 11, i.e. Ψ\lvert\Psi\rangle is a product. ∎ (Partial trace: 1.5.2.)

E6 (hard). Show rmin(dA,dB)r\le\min(d_A,d_B), and that for two dd-level systems the maximum entanglement entropy is log2d\log_2 d, attained exactly when σk=1/d\sigma_k=1/\sqrt d for all kk.

Solution

r=rank(C)r=\operatorname{rank}(C) and CC is dA×dBd_A\times d_B, so rmin(dA,dB)r\le\min(d_A,d_B); for two dd-level systems rdr\le d. Entanglement entropy is the Shannon entropy H({λk})H(\{\lambda_k\}) of a distribution on rdr\le d outcomes, which is maximized by the uniform distribution and equals log2rlog2d\log_2 r\le\log_2 d (0.2.3). The bound log2d\log_2 d is reached only when r=dr=d and all λk=1/d\lambda_k=1/d, i.e. σk=1/d\sigma_k=1/\sqrt d — the flat spectrum, giving ρA=ρB=I/d\rho_A=\rho_B=I/d. ∎


Checkpoint

  1. State the Schmidt decomposition and the key structural fact that distinguishes it from a generic double sum.
  2. How do you compute the Schmidt coefficients of a state in practice?
  3. What does Schmidt rank tell you, and why is the Schmidt spectrum unchanged by local unitaries?
  4. Define the entanglement entropy and give its value for a product state and for a two-qubit Bell state.
  5. What is the Schmidt spectrum of a maximally entangled state of two dd-level systems, and what are its reduced states?
Answers
  1. Ψ=kσkukvk\lvert\Psi\rangle = \sum_k\sigma_k\lvert u_k\rangle\lvert v_k\rangle with orthonormal {uk}\{\lvert u_k\rangle\}, {vk}\{\lvert v_k\rangle\} and σk>0\sigma_k>0, kσk2=1\sum_k\sigma_k^2=1. It is a single sum pairing one AA-vector with one BB-vector.
  2. Form the coefficient matrix CC and take its singular values via the SVD; the σk\sigma_k are those singular values.
  3. Rank 11 ⟺ product, rank 2\ge2 ⟺ entangled. Local unitaries send CUACUBC\to U_A C U_B^{\top}, which preserves singular values.
  4. E=kσk2log2σk2E = -\sum_k\sigma_k^2\log_2\sigma_k^2; E=0E=0 for a product state, E=1E=1 ebit for a Bell state.
  5. Flat: σk=1/d\sigma_k=1/\sqrt d for all kk, E=log2dE=\log_2 d; reduced states are maximally mixed, ρA=ρB=I/d\rho_A=\rho_B=I/d.

Further Reading

  • [NC] Nielsen & Chuang, §2.5 — the Schmidt decomposition and its consequences for entanglement.
  • [Pre] Preskill, Ph219, Ch. 2 — Schmidt decomposition, purification, and the reduced density operator.
  • [Wat] Watrous, The Theory of Quantum Information, Ch. 2 — operator-Schmidt and SVD viewpoint.
  • [NC] §12.5.1 — entanglement entropy as the entanglement measure for pure bipartite states.

← Prev: Nonlocality & the CHSH Inequality · Up: Term 1 · Next: The Density Operator

Ready to measure your state?

6 exercises · 10 checkpoint questions

Start the quiz