I am new with Octave.Now I am trying to implement steepest descent algorithm in Octave.
For example minimization of f(x1,x2) = x1^3 + x2^3 - 2*x1*x2
Estimate starting design point
x0
, iteration counterk0
, convergence parameter tolerence = 0.1. Say this staring point is (1,0)Compute gradient of
f(x1,x2)
at the current pointx(k)
asgrad(f)
. I will use numerical differentiation here.d/dx1 (f) = lim (h->0) (f(x1+h,x2) - f(x1,x2) )/h
This is
grad(f)=(3*x1^2 - 2*x2, 3*x2^2 - 2*x1)
grad(f)
at (0,1) isc0
= (3,-2)since L2 norm of
c0
> tolerence, we proceed for next stepdirection
d0
=-c0
= (-3,2)Calculate step size
a
.Minimize f(a) = f(x0 + a*d0) = (1-3a,2a) = (1-3a)^3 + (2a)^3 - 2*(1-3a)*(2a)
. I am not keeping constant step size.update:
new[x1,x2] = old[x1,x2]x + a*d0
.
Everything is fine until step 5. I don't know how to implement an equation , or directly get a minimum value of an equation in Octave . How to do it ?
Edit
How can we use steepest descent with this convex function : f(x, y) = 4x^2 − 4xy + 2y^2