0
$\begingroup$

I have been messing around with the function $f(x_1,x_2)=(x_1-2)^4+(x_1-2x_2)^2$ for a while now in MatLab, and I'm starting to suspect I'm making some pretty basic error when it comes to differentiation, though I cannot figure out what I'm doing wrong.

Calculating the gradient of $f$ is fairly straightforward: $\nabla f(x_1,x_2)=\begin{pmatrix} 4(x_1-2)^3+2(x_1-2x_2)\\ -4(x_1-2x_2)\\ \end{pmatrix}$

Now I'm tasked with calculating the steepest descent direction from the initial point $x^0=(0,3)^t$. I'm thinking that the steepest descent direction is $$d=-\nabla f(0,3)=\begin{pmatrix} 44\\ -24\\ \end{pmatrix}$$

Let $\phi(t)=f(x^0+td)$. Then, according to my line of thinking, $\phi(t)$ should be smaller than $f(x^0)$ for small positive values of $t$, since $d=-\nabla f(x^0)$ is a descent direction. However, when testing in MatLab, I get the exact opposite result: $\phi(t)>f(x^0)$ for small $t>0$.

Am I confusing $\nabla f$ with $-\nabla f$ or something? At this point I have no idea what I'm doing wrong.

Edit: I'm still not entirely sure what was wrong, but after looking at the answer my guess is that I accidentally managed to put $d=\nabla f(x^0)$ somehow. But the matter is resolved now.

  • 0
    What's your matlab code?2017-01-13
  • 0
    simply using anonymous functions: f=@(x) (x(1)-2)^4+(x(1)-2*x(2))^2; and so on. Then I take fline=@(t) f(x0+t*d);2017-01-13

1 Answers 1

1

I do not see the problem. With your code I obtain:

>> f=@(x) (x(1)-2)^4+(x(1)-2*x(2))^2;
>> x0 = [0; 3]; d = [44; -24];
>> fline=@(t) f(x0+t*d);
>> fline(0)
ans =
    52
>> fline(0.001)
ans =
   49.5423
  • 0
    Hmmm, maybe there's something wrong with my matlab code or something, let me check.2017-01-13