Solve maximization problem of quadratic equation in MATLAB - matlab

How do I solve a quadratic Maximization problem in MATLAB? It seems MATLAB only supports minimization problems, so is there a mathematical concept I can use?

simply multiply by (-1) before and after using the minimization function

Using quadprog function in MATLAB.
This function solves Quadratic Programming problems in MATLAB.
Of course if you want the maxima instead of the minima, you can multiply the cost function by -1.
Good Luck.

The above answer #Drazick seems not right.
quadprog() in matlab requires H to be positive definite. If we simply multiply (-1), -H is a negative definite matrix, which violates the requirement.
Another optimization function called fmincon( ) may help.

Related

Boolean least squares

For a spectrum estimation algorithm I need to find the best fitting linear combination of vectors to fit a target spectral distribution. So far, this works relatively well using the lsqlin optimizer in MATLAB.
However, for the final application I would like to approximate/solve this problem for exclusively zeros and ones, meaning Ax=b solved for Boolean x.
Is there any way to parametrize lsqlin or another optimizer function for this purpose?
If the problem is just:
Solve Ax=b for x in {0,1}
then you can use a MIP solver (e.g. Matlab intlinprog). If the problem is over-constrained and you want a least squares solution:
Min w'w
S.t. Ax - b = w
x in {0,1} (binary variable)
w free variable
then you have a MIQP (Mixed Integer Quadratic Programming) problem. There are good solvers for this such as Cplex and Gurobi (callable from Matlab). Also Matlab has a discussion about an approximation scheme using intlinprog. Another idea is to replace the quadratic objective by a sum of absolute values. This can be formulated as linear MIP model.

MATLAB: How to solve linear system modulo m

Does anyone know what functions are available for solving linear systems when the equations are actually congruences mod m? The desire is to solve a linear system (Ax = b) for values x in which "Ax is congruent to b"
A discussion of how to perform gaussian elimination in this situation can be found here, but I was hoping to use MATLAB rather than attempting to do it by hand.
Have a look at the lincon() method found here:
http://www.mathworks.com/matlabcentral/fileexchange/32856-system-of-linear-congruences/content/lincon.m

Fminunc returns indefinite Hessian matrix for a convex objective

In minimizing a convex objective function, does it mean that the Hessian matrix at minimizer should be PSD? If fminunc in Matlab returns a hessian which is not psd what does it mean? am I using a wrong objective?
I do that in environments other than matlab.
Non-PSD means you can't take the Cholesky transform of it (i.e. the matrix square-root), so you can't use it to get standard errors, for example.
To get a good hessian, your objective function has to be really smooth, because you're taking a second derivative, which doubly amplifies any noise. If possible, it is best to use analytic derivatives rather than finite-difference. That is, if you really need the hessian.

Solve equation Matlab

Hy can anyone can tell me how i can solve this equation
2xJ1(x) − J0(x) = 0
where J1 and J0 are the Bessel function
in Matlab without using the fsolve command
You can use fzero to find the zeros if and only if the curve crosses the x-axis. So
fzero(#(x)(2*x*besselj(1,x)-besselj(0,x)),x0)
will give you the zero close to x0.
See this answer of mine for an explanation of when and why fzero fails (although it won't for a Bessel function, it's good to be aware) and the tradeoffs with fsolve.

Newton's method for multivariate optimization in matlab

How to compute the gradient and hessian matrix when the equation cannot be solved numerically?
My minimization equation is:
c=c[(x/y/(1-x)^2)^0.6 + (1-(x/y)/(1-y)^2)^0.6 + 6/y^0
I tried the MATLAB function "diff" to compute the gradient and hessian. But derivations are much longer than one can handle. How to write the code for computing the hessian or gradient?
Why do you say the equation cannot be solved numerically? Do you mean it cannot be solved analytically? There appears to be a typo in your statement of the function c that you wish to optimize. When you refer to your use of Matlab's diff() function, do you mean that you evaluated your function on a grid and then differenced it? Or are you talking about passing a function handle to Matlab's symbolic library?