# Optimization of difference of two convex function.

Suppose we have to minimize a function $f(X,Y)-g(X,Y)$, where both the functions are convex. How can this be solved in matlab? Is there any tool to solve this in matlab?

-

## 1 Answer

There are a lot of optimization functions in Matlab. Which to choose depends on the functions $f$ and $g$. For example, you can try fminunc, especially if you know first or second derivatives, or fminsearch for a derivative-free method.

However, note that the difference of convex function is not in general a convex function, so you can get stuck in local minimum.

-
Sir when X is a matrix and Y is some column matrix then how it can be fit using fminsearch.. –  user3256924 Feb 26 '14 at 10:23
X and Y can be treat as one big vector of unknowns. However, it will be extremely slow without derivatives. –  felagund Feb 26 '14 at 10:29
use reshape() function to convert matrix to vector and back vector to matrix. –  felagund Feb 26 '14 at 10:46
suppose $f(X,Y)=|l*X*h|^2/(Y(1,:)+0.01)$, then how it can be written using fminsearch . will you help me in writing the code for this? –  user3256924 Feb 26 '14 at 10:50
Sorry sir but unable to understand.. –  user3256924 Feb 26 '14 at 10:53