Minimization Problem in Matlab regarding vector equation

64 Views Asked by At

How can I minimize for b in the equation

    f(b) = norm((b*a+c),2)

when b is a scalar and c, a are vectors (Nx1)?

I tried:

    objective_fct = @(beta_min)(norm((b*a+c),2))

    [beta_min,fval] = fminsearch(objective_fct,[-ones(6,1), ones(6,1)])

but that doesn't work...

2

There are 2 best solutions below

0
On

Assuming ${\bf a}\neq 0$, the minimum of $f(b)$ is $||{\bf c}||^2 - {({\bf a}\cdot {\bf c})^2\over ||{\bf a}||^2}$. This is attained at $b = -({\bf a}\cdot{\bf c})/||{\bf a}||^2$.

Here are the steps: $$||b{\bf a} + {\bf c}||^2 = (b{\bf a}+{\bf c})\cdot (b{\bf a}+{\bf c}) = ||{\bf a}||^2 b^2 + 2({\bf a}\cdot{\bf c})b + ||{\bf c}||^2.$$ The right-hand side is quadratic in $b$ and (assuming ${\bf a}\neq 0$) concave up. Find the minimum by taking the derivative with respect to $b$ and setting it equal to zero: $$2||{\bf a}||^2b + 2{\bf a}\cdot{c} = 0 \quad \Rightarrow \quad b = -{({\bf a}\cdot{\bf c})\over ||{\bf a}||^2}\,.$$

Evaluating the quadratic at this value of $b$ gives the answer $||{\bf c}||^2 - {({\bf a}\cdot{\bf c})^2\over ||{\bf a}||^2}$ as above.

In other words, it would seem that you can just enter the formula for the minimum explicitly, without needing to call any optimization routine.

3
On

Since $f(x)=||xa+c||_2=\sqrt{\sum_i (xa_i+c_i)^2}\geq 0$, you've got, calling $g(x)=f^2(x)$: $$ \frac{d}{dx}g(x)=0\Rightarrow \sum_i2(xa_i+c_i)a_i=0, $$ then: $$ \sum_i(xa_i^2+a_ic_i)=x\sum a^2_i+\sum a_ic_i=0, $$ finally: $$ x=-\frac{\sum a_ic_i}{\sum a^2_i}=-\frac{a\cdot c}{||a||_2^2}. $$