Solve the following problem:
$\theta^* = \arg\min_{\theta} ||\mathbf{p} - \theta\mathbf{u} - (1 - \theta)\mathbf{v}||^2$.
(7)
where $\mathbf{u}, \mathbf{v}, \mathbf{p} \in \mathbb{R}^n$. For a given $\mathbf{p}$, the optimization problem seeks to find the nearest point
that lies on the line passing through $\mathbf{u}$ and $\mathbf{v}$, where $\mathbf{u} \neq \mathbf{v}$. You may note that the line passing
through two points $\mathbf{u}$ and $\mathbf{v}$ is the set of vectors
$\mathcal{L} = \{\theta\mathbf{u} + (1 - \theta)\mathbf{v} \mid \theta \in \mathbb{R}\}$
(8)
Therefore, the goal is to find $\theta$ for which the distance of the point $\mathbf{p}$ from the point $\theta\mathbf{u} + (1 - \theta)\mathbf{v}$
is as small as possible.