I have the following optimization problem.
$$\operatorname*{argmax}_{w} \|(1-w)\boldsymbol{X} -w\boldsymbol{Y}\|^2 \\ s.t. \quad 0<w<1 $$
How can I find the solution of this problem? May be can I apply gradient descent?
$J = \|(1-w)X -wY\|^2 + \mu (w-1)+\lambda w\\\frac{\partial J}{\partial w} = 0$
Is it correct? should I use $\lambda \quad \text{and} \quad \mu$ ?
$X$ and $Y$ are known, one dimensional vectors, their values are bounded in a known range.
Since $X,Y \in \mathbb{R}$, we can restate your problem as $$w^* :=\arg \max_{0\leq w\leq 1} (a+bw)^2$$ where $a = X$ and $b = -(X+Y)$. Now, with $f(w) = (a+bw)^2$, we now that this convex parabola has a zero at $-\frac{a}{b}$ (where the minimum is reached). So we want to go the further as possible from the minimum. Therefore we have $$ w^* = 1 \quad \text{ if } -\frac{b}{a}\leq\frac{1}{2},\quad \text{ and } \quad w^* = 0 \quad \text{ if } -\frac{b}{a}>\frac{1}{2}.$$ See the figure below to get a better intuition.
In blue $-\frac{b}{a} \leq \frac{1}{2}$ and in red $-\frac{b}{a} \geq \frac{1}{2}$.