I know in MATLAB there is a fmincon to solve this kind of problem. But I really don't know how to use it for my problem.
Question 1: Find optimal $u$ to
$u^TDx-\frac{\mu}{2} |u|^2 \rightarrow max$
$|u_{i}| \le 1$
where $x$ - given 1D column vector, $\mu$ - const, |.| - $L_2$ norm, $D$ - gradient operator, $u$ - 1D column vector.
Question 2: Do above problem and below problem have same optimum?
$-(u^TDx-\frac{\mu}{2} |u|^2) \rightarrow min$
$|u_{i}| \le 1$
If without constraint, this is right. However, there is constraint, do they have same optimum? I don't want to formulate the dual problem.
Most optimization solvers require an objective function (by default) in minimization form. Multiplying a maximization by negative one is one way to reliably transform the objective to a minimization statement, even with constraints. I created an fmincon tutorial with source code (see method #2) for a problem with an objective function, equality constraint, and an inequality constraint or you can use MathWorks' fmincon or quadprog documentation.
If you do solve this problem numerically, you should avoid the use of an absolute value operator $\left | u_i \right |<1$ as an inequality constraint but instead use an upper and lower bound on the variable ($u_i\lt 1$ and $u_i\gt -1$). Using an absolute value operator may cause problems for gradient based solvers that require continuous first and second derivatives.