Suppose I have $n$-dimensional real vectors $\mathbf u$, $\mathbf v$, $\mathbf w$, with $\mathbf v>0$. I'd like to maximize the following function $f$:
$$ f(\mathbf x)=\sum_{i}(u_ix_i-v_ix_i^2)\quad\text{subject to}\quad g(\mathbf x)=\mathbf w^\top\mathbf x=0. $$
Normally I think this can be done with the method of Lagrange multipliers, that is, if $\mathbf z$ is the solution then there is $\lambda$ for which
$$ \nabla f(\mathbf z)=\lambda\nabla g(\mathbf z), $$
which gives the following system of $n+1$ variables in $n+1$ equations:
$$ \begin{align} u_1-2v_1z_1&=\lambda w_1\\ &\vdots\\ u_n-2v_nz_n&=\lambda w_n\\ w_1z_1+\dots+w_nz_n&=0. \end{align} $$
How do we solve this system if $n\gg0$? Say the vectors $\mathbf u,\mathbf v,\mathbf w$ can only be loaded in memory in chunks of length $N\ll n$.
Is it possible to "iteratively" compute and output the components of $\mathbf z$ without reading in the full contents of $\mathbf u,\mathbf v,\mathbf w$?
1 Answer 1
This is resolved - the solution was right in front of my eyes.
From the first $n$ equations we can express each $z_i$ in terms of the other variables. Then, applying the constraint $\mathbf w^\top\mathbf z=0$ and simplifying gives
$$ \sum\frac{w_iu_i}{2v_i}=\lambda\sum\frac{w_i^2}{2v_i}. $$
The denominators are fine since $\mathbf v>0$. Clearly both sums can be computed iteratively, which gives $\lambda$.
Then, for each $i$ we can simply compute
$$ z_i=\frac{u_i-\lambda w_i}{2v_i}. $$
Explore related questions
See similar questions with these tags.