Suppose $a \in \mathbb R^{n_1n_2n_3}$. Show how to compute $f \in \mathbb R^{n_1}$ and $g \in \mathbb R^{n_2}$ so that $$\| a - h \otimes g \otimes f \|_2$$ is minimized where $h \in \mathbb R^{n_3}$ is given.
Is there a way to solve this question using the SVD?
Using SVD (after vectorizing slices), we can decompose $a$ into a sum of the form $$ a = \sum_{i=1}^k h_i \otimes m_i $$ where $h_i \in \Bbb R^{n_3}, m_i \in \Bbb R^{n_1n_2}$, $h_1 = h$, $\|m_i\| = 1$, and $\langle h_i,h_j \rangle = \langle m_i,m_j \rangle = 0$ whenever $i \neq j$.
It follows that $$ a - h\otimes g \otimes f = h \otimes (M_1 - g \otimes f) + \sum_{i=2}^k h_i \otimes m_i. $$ Now, because all terms in the sum are mutually orthogonal, we have $$ \begin{align} \|a - h\otimes g \otimes f\|^2 &= \|h \otimes (m_1 - g \otimes f)\|_2^2 + \sum_{i=2}^k \|h_i \otimes m_i\|_2^2 \\ & = \|h\| \cdot \|m_1 - g \otimes f\|_2^2 + \sum_{i=2}^k \|h_i\|_2^2. \end{align} $$ Thus, it suffices to find $f,g$ so that $\|m_1 - g \otimes f\|_2^2$ is minimized.
This also can be solved using SVD: By unvectorizing, we reframe this as finding $f,g$ such that $\|M_1 - gf^T\|$ is minimized (where $M_1 = \operatorname{vec}^{-1}(m_1)$). By the E-Y-M theorem, we can minimize this quantity by taking $g$ and $f$ to be multiples of the left and right singular vectors (respectively) associated with $\sigma_1$ (the largest singular value of $M_1$) such that $\|f\| \cdot \|g\| = \sigma_1$.
Regarding the first step: define the vectorization operator $\operatorname{vec}:\Bbb R^{n_3 \times n_1n_2} \to \Bbb R^{n_1n_2n_3}$ to be the unique map satisfying $$ \operatorname{vec}(hv^T) = h \otimes v $$ for any $h \in \Bbb R^{n_3}$ and $v \in \Bbb R^{n_1n_2}$. Now, let $A = \operatorname{vec}^{-1}(a)$. The singular value decomposition expresses $A$ as a sum $$ A = \sum_{i=1}^r \sigma_i \hat h_i m_i^T $$ where $\hat h_i$ is a unit vector in $\Bbb R^{n_3}$ and $m_i$ is a unit vector in $\Bbb R^{n_1n_2}$. If we define $h_i = \sigma_i h_i$, then we can rewrite this as $$ A = \sum_{i=1}^r h_i m_i^T. $$ If we vectorize both sides, then we get $$ a = \operatorname{vec}(A) = \sum_{i=1}^r \operatorname{vec}(h_i m_i^T) = \sum_{i=1}^r h_i \otimes m_i. $$ In order to get the matrix $M_i$ from $m_i$, vectorize with respect to $n_2$ and $n_3$.