I need to find the minimum of a function. However, the condition is that the final state should be normalized i.e. sum of the squares must be one. One way to deal with it is just add the constraint into the Mathematica function NMinimize and solve it. In that case the function is a quartic polynomial. However I can also divide all the parameters to the sum of their squares and then the problem will be without a constraint but this means that the problem will not be a nice, simple quartic polynomial. I am using "DifferentialEvolution" and "RandomSearch" methods and I am wondering based on how they work should I solve the problem with constraint or embed it into the function? This is my question. I have tried and haven't seen any difference but on the other hand my code takes ages to evaluate so I wanted to ask if anyone has any experience upon.


1 Answer 1


I don't get why you use a quartic polynomial as constraint. The sum of squares minus 1 is quadratic. Squaring that once more is a very bad move as that will lead to a constraint mapping that does not satisfy any of the standard constraint qualifications: its differential vanishes whenever the constraint is satisfied (which also means that NMinimize might run into problems.)

The second method has the problem that you might end up dividing by zero. Actually, your objective function will have a nasty singularity at 0. Moreover, you will have 1-parameter family of minimizers and your Hessian of the energy will have a nontrivial nullspace (wherever the objective function is twice differentiable). Newton-like optimization methods might have problems with that. Though BFGS, Mathematica's standard method for local unconstrained optimization, might be sufficiently robust and still quick enough for that.

All in all, I would suggest to use the constrained optimization approach with the quadratic constraint.

  • $\begingroup$ Constraint is not a quartic polynomial it is quadratic as you wrote. The function to be solved is quartic with the quadratic constraint. Sorry if the question is not clear. But you answered the question anyway. I think this is not a trivial question at all. $\endgroup$
    – user59583
    Sep 19, 2018 at 14:29
  • $\begingroup$ But wait, if the denominator goes to zero than the numerator should also goes to zero and since the numerator is quartic it should approach to zero faster (is this correct?), so numerically there should be no problem, right? $\endgroup$
    – user59583
    Sep 20, 2018 at 13:19
  • $\begingroup$ Well, computers are usually not aware of such limiting processes; it lies in the programmer's responsibility to cope with that. But I said, you might end up dividing by zero, not that you will do it. $\endgroup$ Sep 20, 2018 at 15:19
  • 1
    $\begingroup$ After many trials I have found that solving with the normalization embedded gave me more optimum results. I felt this has to be noted. $\endgroup$
    – user59583
    Oct 2, 2018 at 9:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.