Exercises

ch16-ex01

Easy

(Phase Swap Experiment) (a) Load two 128Γ—128128 \times 128 images (e.g., a circle and a star). Compute their 2D DFTs.

(b) Create hybrid images by swapping amplitude and phase spectra: h1=Fβˆ’1{∣f~βˆ£β€‰ej∠g~}h_1 = \mathcal{F}^{-1}\{|\tilde{f}|\,e^{j\angle\tilde{g}}\} and h2=Fβˆ’1{∣g~βˆ£β€‰ej∠f~}h_2 = \mathcal{F}^{-1}\{|\tilde{g}|\,e^{j\angle\tilde{f}}\}.

(c) Display all four images. Which original does each hybrid resemble?

(d) Compute the SSIM between each hybrid and each original. Verify that the hybrid with image kk's phase has higher SSIM to image kk.

ch16-ex02

Easy

(Spectral Initialization Quality) (a) Generate x0∈C64\mathbf{x}_0 \in \mathbb{C}^{64} with i.i.d. CN(0,1)\mathcal{CN}(0, 1) entries. Create M=384M = 384 Gaussian measurements yi=∣⟨ai,x0⟩∣2y_i = |\langle \mathbf{a}_i, \mathbf{x}_0\rangle|^2.

(b) Form Y=1Mβˆ‘iyiaiaiH\mathbf{Y} = \frac{1}{M}\sum_i y_i \mathbf{a}_i\mathbf{a}_i^H and compute its leading eigenvector.

(c) Align the global phase: Ο•^=∠(z(0)Hx0)\hat{\phi} = \angle(\mathbf{z}^{(0)H} \mathbf{x}_0). Report the relative initialization error.

(d) Plot the initialization error vs. M/NM/N for M/N=2,3,4,6,8,12M/N = 2, 3, 4, 6, 8, 12.

ch16-ex03

Easy

(Basic Wirtinger Flow) (a) Implement Wirtinger flow for f(z)=14Mβˆ‘i(∣⟨ai,z⟩∣2βˆ’yi)2f(\mathbf{z}) = \frac{1}{4M}\sum_i (|\langle\mathbf{a}_i, \mathbf{z}\rangle|^2 - y_i)^2 with spectral initialization.

(b) Use N=32N = 32, M=192M = 192 Gaussian measurements, noiseless.

(c) Plot dist(z(t),x0)/βˆ₯x0βˆ₯\text{dist}(\mathbf{z}^{(t)}, \mathbf{x}_0)/\|\mathbf{x}_0\| vs. iteration. Verify linear convergence on a semilog plot.

(d) Vary the step size μ∈{0.1,0.5,1.0,2.0,5.0}/βˆ₯z(0)βˆ₯2\mu \in \{0.1, 0.5, 1.0, 2.0, 5.0\}/ \|\mathbf{z}^{(0)}\|^2. What is the optimal range?

ch16-ex04

Easy

(Phase Alignment) (a) Show that the optimal global phase alignment Ο•^=arg⁑min⁑ϕβˆ₯x^βˆ’ejΟ•x0βˆ₯2\hat{\phi} = \arg\min_\phi \|\hat{\mathbf{x}} - e^{j\phi}\mathbf{x}_0\|^2 is given by Ο•^=∠(x^Hx0)\hat{\phi} = \angle(\hat{\mathbf{x}}^H \mathbf{x}_0).

(b) Prove that the phase-aligned distance satisfies dist2(x^,x0)=βˆ₯x^βˆ₯2+βˆ₯x0βˆ₯2βˆ’2∣x^Hx0∣\text{dist}^2(\hat{\mathbf{x}}, \mathbf{x}_0) = \|\hat{\mathbf{x}}\|^2 + \|\mathbf{x}_0\|^2 - 2|\hat{\mathbf{x}}^H\mathbf{x}_0|.

(c) Why is phase alignment necessary when evaluating phase retrieval algorithms?

ch16-ex05

Medium

(PhaseLift via SDP) (a) Implement PhaseLift for N=16N = 16, M=128M = 128 Gaussian measurements using CVXPY.

(b) Solve the SDP. Plot the eigenvalues of X^\hat{\mathbf{X}}. Verify the solution is approximately rank 1.

(c) Extract x^=Ξ»1v1\hat{\mathbf{x}} = \sqrt{\lambda_1}\mathbf{v}_1. Compute the relative error after phase alignment.

(d) Increase NN to 32, 64. Plot computation time vs. NN and verify the approximately O(N6)O(N^6) scaling.

ch16-ex06

Medium

(Truncated Wirtinger Flow) (a) Implement truncated Wirtinger flow: at each iteration, discard measurements with ∣⟨ai,z⟩∣>αhyi|\langle\mathbf{a}_i, \mathbf{z}\rangle| > \alpha_h\sqrt{y_i} from the gradient, with αh=3\alpha_h = 3.

(b) Setup: N=128N = 128, M=512M = 512, Gaussian, SNR = 25 dB.

(c) Compare convergence of standard WF and truncated WF.

(d) Reduce MM to 256256 (2N2N). Does standard WF converge? Does truncated WF?

(e) Plot success rate (50 trials) vs. M/NM/N for both methods.

ch16-ex07

Medium

(Coded Diffraction Patterns) (a) Generate a 32Γ—3232 \times 32 complex image. Simulate Fourier magnitude measurements: yk=∣x~k∣2y_k = |\tilde{x}_k|^2.

(b) Attempt phase retrieval with a single Fourier magnitude pattern using alternating projections (500 iterations, 10 random restarts). Report the best relative error.

(c) Add coded diffraction patterns with L=1,2,3,5L = 1, 2, 3, 5 random phase masks. Run Wirtinger flow for each LL.

(d) Plot relative error vs. LL. At what LL does the error plateau?

ch16-ex08

Medium

(Wirtinger Gradient Derivation) Derive the Wirtinger gradient of the amplitude loss:

g(z)=12Mβˆ‘i=1M(∣⟨ai,zβŸ©βˆ£βˆ’yi)2.g(\mathbf{z}) = \frac{1}{2M}\sum_{i=1}^{M} \left(|\langle \mathbf{a}_i, \mathbf{z}\rangle| - \sqrt{y_i}\right)^2.

Show that βˆ‡zΛ‰g=12Mβˆ‘i(1βˆ’yi∣⟨ai,z⟩∣)⟨ai,zβŸ©β€‰ai\nabla_{\bar{\mathbf{z}}} g = \frac{1}{2M}\sum_i \left(1 - \frac{\sqrt{y_i}}{|\langle\mathbf{a}_i, \mathbf{z}\rangle|}\right)\langle\mathbf{a}_i, \mathbf{z}\rangle\,\mathbf{a}_i.

Where is this gradient undefined? How does truncation help?

ch16-ex09

Medium

(Lifting Trick Verification) (a) For x=[1,j]T\mathbf{x} = [1, j]^T and a=[1,1]T/2\mathbf{a} = [1, 1]^T / \sqrt{2}, verify that ∣⟨a,x⟩∣2=tr(aaHxxH)|\langle\mathbf{a}, \mathbf{x}\rangle|^2 = \text{tr}(\mathbf{a}\mathbf{a}^H \mathbf{x}\mathbf{x}^H).

(b) Compute X=xxH\mathbf{X} = \mathbf{x}\mathbf{x}^H explicitly. What are its eigenvalues? Verify it is rank-1 PSD.

(c) Show that the set of rank-1 PSD matrices is non-convex by finding two rank-1 PSD matrices whose average is rank 2.

ch16-ex10

Medium

(Noise Robustness) Setup: N=128N = 128, M=768M = 768, Gaussian measurements.

(a) Vary SNR from 5 to 40 dB in 5 dB steps. For each SNR, run Wirtinger flow, truncated WF, and amplitude flow.

(b) Plot relative error vs. SNR for all three methods.

(c) Compute the "phase retrieval SNR tax": for each method, what additional SNR is needed compared to linear recovery (if phase were available)?

ch16-ex11

Hard

(Sparse Phase Retrieval for RF Imaging) (a) Create a sparse RF imaging scene: N=32Γ—32=1024N = 32 \times 32 = 1024, s=10s = 10 point scatterers.

(b) Construct a MIMO radar forward model with Nt=4N_t = 4, Nr=8N_r = 8, Nf=64N_f = 64. Generate phaseless measurements with L=3L = 3 phase masks and SNR = 25 dB.

(c) Implement sparse Wirtinger flow (gradient + hard thresholding at sparsity ss).

(d) Compare with standard (non-sparse) Wirtinger flow. Plot NMSE vs. iteration for both.

(e) Vary ss from 5 to 50. At what sparsity does sparse WF fail?

ch16-ex12

Hard

(Gerchberg--Saxton with Spectral Initialization) (a) Implement the Gerchberg--Saxton algorithm for Fourier phase retrieval with a support constraint.

(b) Setup: N=64N = 64, Fourier measurements with L=3L = 3 coded masks. Signal has support ∣supp(x)∣=20|\text{supp}(\mathbf{x})| = 20.

(c) Compare convergence with: (i) random initialization, (ii) spectral initialization.

(d) Test a hybrid: spectral init + 50 GS iterations + WF refinement. Compare with pure WF.

ch16-ex13

Hard

(Dual Certificate for PhaseLift) Consider the noiseless PhaseLift SDP with MM Gaussian measurements.

(a) Write the Lagrangian dual of PhaseLift. What is the dual variable?

(b) Show that strong duality holds (Slater's condition).

(c) State the KKT conditions for optimality of X^\hat{\mathbf{X}}.

(d) Explain why constructing a dual certificate Ξ»\boldsymbol{\lambda} with βˆ‘iΞ»iAiβͺ―I\sum_i \lambda_i \mathbf{A}_i \preceq \mathbf{I} and (Iβˆ’βˆ‘iΞ»iAi)X0=0(\mathbf{I} - \sum_i \lambda_i \mathbf{A}_i)\mathbf{X}_0 = 0 proves X0\mathbf{X}_0 is optimal.

ch16-ex14

Hard

(Measurement Diversity vs. Number of Masks) Consider an N=64N = 64 signal with Fourier measurements.

(a) Generate L=1,2,3,4,5,7,10L = 1, 2, 3, 4, 5, 7, 10 coded masks. For each, run 50 trials of Wirtinger flow and record the success rate (error <10βˆ’3< 10^{-3}).

(b) Plot the success rate vs. LL. Where is the phase transition?

(c) For L=3L = 3, vary the mask type: (i) random uniform phase, (ii) random Β±1\pm 1, (iii) random phase with limited range Ο•βˆˆ[βˆ’Ο€/4,Ο€/4]\phi \in [-\pi/4, \pi/4]. Which provides the best diversity?

(d) Relate your findings to the measurement diversity requirement in Fourier phase retrieval theory.

ch16-ex15

Hard

(Resolution Limits of Phaseless Imaging) (a) From magnitude-only Fourier data ∣F(k)∣2|F(\mathbf{k})|^2, show that the autocorrelation R(Ο„)=βˆ«Ο‡(r)Ο‡βˆ—(rβˆ’Ο„) drR(\boldsymbol{\tau}) = \int \chi(\mathbf{r})\chi^*(\mathbf{r} - \boldsymbol{\tau})\,d\mathbf{r} is directly accessible via the Wiener--Khinchin theorem.

(b) What is the "resolution" of the autocorrelation in terms of the original signal bandwidth BB?

(c) Argue that successful phase retrieval restores the original resolution Ξ΄r=c/(2B)\delta_r = c/(2B).

(d) Simulate: create a scene with two point targets at separation Ξ”r=1.5Ξ΄r\Delta r = 1.5\delta_r. Compare the autocorrelation image with the phase-retrieved image. Are the targets resolvable in each?

ch16-ex16

Hard

(Convergence Rate Analysis) (a) Implement Wirtinger flow and record et=dist(z(t),x0)e_t = \text{dist}(\mathbf{z}^{(t)}, \mathbf{x}_0) for N=64N = 64, M=384M = 384.

(b) Fit an exponential decay etβ‰ˆe0ρte_t \approx e_0 \rho^t to the convergence curve. Estimate the contraction factor ρ\rho.

(c) Vary M/N∈{4,6,8,12}M/N \in \{4, 6, 8, 12\}. How does ρ\rho depend on M/NM/N?

(d) The theory predicts ρ=1βˆ’c/N\rho = 1 - c/N. Estimate cc from your data. Does it match the theoretical prediction?

ch16-ex17

Hard

(Hybrid Phase Retrieval: Partial Phase Information) In practice, some receivers may provide partial phase information (e.g., quantized phase or relative phases).

(a) Formulate the hybrid problem: M1M_1 full complex measurements zi=⟨ai,x⟩z_i = \langle\mathbf{a}_i, \mathbf{x}\rangle and M2M_2 magnitude-only measurements yj=∣⟨aj,x⟩∣2y_j = |\langle\mathbf{a}_j, \mathbf{x}\rangle|^2.

(b) Modify Wirtinger flow to incorporate both measurement types.

(c) For N=64N = 64, vary the fraction M1/(M1+M2)M_1/(M_1 + M_2) from 0 to 1. Plot recovery error vs. fraction of complex measurements.

(d) At what fraction does the hybrid method match pure complex (linear) recovery?

ch16-ex18

Challenge

(Information-Theoretic Lower Bound) (a) For the noiseless phase retrieval model yi=∣⟨ai,x⟩∣2y_i = |\langle\mathbf{a}_i, \mathbf{x}\rangle|^2 with Gaussian ai\mathbf{a}_i, compute the Fisher information matrix for x\mathbf{x} from the measurements {yi}\{y_i\}.

(b) Show that the Fisher information per measurement scales as O(βˆ₯xβˆ₯2)O(\|\mathbf{x}\|^2) rather than O(1)O(1) as in linear measurements.

(c) Use the Cramer--Rao bound to derive a lower bound on the MSE of any unbiased estimator.

(d) Compare this lower bound with the empirical error of Wirtinger flow. How close is WF to the information-theoretic limit?

ch16-ex19

Challenge

(Burer--Monteiro for Low-Rank Phase Retrieval) (a) Formulate the PhaseLift SDP with Burer--Monteiro factorization: X=VVH\mathbf{X} = \mathbf{V}\mathbf{V}^H with V∈CNΓ—r\mathbf{V} \in \mathbb{C}^{N \times r}.

(b) Derive the gradient of the resulting non-convex problem with respect to V\mathbf{V}.

(c) Implement gradient descent on V\mathbf{V} for N=64N = 64, r=2r = 2. Compare convergence with Wirtinger flow.

(d) For what values of rr does the Burer--Monteiro approach recover the correct rank-1 solution? Is r=1r = 1 sufficient?

(e) Discuss: when might Burer--Monteiro be preferred over direct Wirtinger flow?

ch16-ex20

Challenge

(Complete Phaseless RF Imaging Pipeline) Build an end-to-end phaseless RF imaging system:

(a) Scene: 32Γ—3232 \times 32 grid with 10 point scatterers and 2 extended targets (rectangles).

(b) System: MIMO radar, Nt=8N_t = 8, Nr=16N_r = 16, Nf=64N_f = 64, center frequency 10 GHz, bandwidth 4 GHz. L=4L = 4 phase masks.

(c) Forward model: Near-field Born approximation. Power detection: yiβ„“=∣[Dβ„“Ac]i∣2y_i^\ell = |[\mathbf{D}_\ell\mathbf{A}\mathbf{c}]_i|^2. SNR = 20 dB.

(d) Reconstruction pipeline: (i) Spectral initialization. (ii) Wirtinger flow (200 iterations). (iii) Sparse refinement: threshold to s^\hat{s} components, then sparse WF (100 iterations). (iv) Final ADMM + TV for edge preservation.

(e) Evaluation: NMSE, SSIM, support F1-score at each stage.

(f) Plot quality (NMSE) vs. computation time for each variant.