# Which method to use for finding maximum without actually computing optimization function explicitly?

I am new to Mathematica and I am currently working on an optimization problem. The optimization function that I have easy to calculate for some assignment of variable but it is very difficult to calculate it explicitly. So, is there any function in Mathematica to optimize a function with some given constraint so that it does not need to calculate the function to be optimized explicitly.

Basically my function first takes the partial of a 4*4 matrix and then takes the log of that matrix, so I think it is getting very complicated to calculate the function explicitly. Main section of the code is:

    comp[x_, y_] := x + I y;
mkvec2[x01_, x02_, x03_, x04_, y01_, y02_, y03_,
y04_] := {comp[x01, y01], comp[x02, y02], comp[x03, y03],
comp[x04, y04]};
densmat[v_] := ConjugateTranspose[{v}].{v};
densmat1[v_] := Simplify[Expand[ConjugateTranspose[v].v]];
pdensmat1[M_] := PartialTrace[M, {2, 2, 2, 2}, {2, 4}];
pdensmat2[M_] := PartialTrace[M, {2, 2}, {1}];
NEntropy[M_] := Expand[ Tr[-MatrixLog[M].M]/Log[2]];
veckraus[a_, b_] := KroneckerProduct[{a}, {b}];
Optm[ar_, br_, cr_, dr_, ai_, bi_, ci_, di_] :=
Re[NEntropy[pdensmat1[densmat1[Finvec[ar, br, cr, dr, ai, bi, ci, di]]]] - NEntropy[pdensmat2[densmat[mkvec2[Re[cr], 0, 0, Re[dr], Re[ci], 0, 0, Re[di]]]]]];
Optm[1/Sqrt[2], 1/Sqrt[2], 0.636944, 0, 0, 0, 0.770919, 0];
Optm[1/Sqrt[2], 1/Sqrt[2], 0.5, 0.7, 0.5, 0.6, 0.2, 0.6];
FindMaximum[{Optm[1/Sqrt[2], 1/Sqrt[2], cr, dr, 0, 0, ci, di], cr^2 + dr^2 + ci^2 + di^2 == 1}, {{cr, 0}, {dr, 0}, {ci, 0}, {di, 0}}]


Here the function "Optm" is the function to be optimized. It is very fast to calculate it for an assignment of variables as I have tried in 2nd and 3rd last line of the code but it is not working out when dealing with the "FindMaximum" problem.

I hope the question is clear, if not, let me know I will try to edit it.

• Welcome to Mathematica.SE! I suggest that: 1) You take the introductory Tour now! 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. – bbgodfrey May 20 '15 at 18:38
• What isn't working? Runs forever, gives an error...? It may be that you need to define your function to only be evaluated when the arguments are numerical using NumericQ: see this User-defined functions, numerical approximation, and NumericQ – MarcoB May 20 '15 at 19:04
• I second the comment by @MarcoB. That's certainly the first thing to try. I cannot test it though because the code above is incomplete (missing definitions of PartialTrace and Finvec). – Daniel Lichtblau May 20 '15 at 19:08
• First thing is to try what @Marco suggested (to repeat myself..): Clear[Optm]; Optm[ar_?NumericQ, br_NumericQ, cr_NumericQ, dr_NumericQ, ai_NumericQ, bi_NumericQ, ci_NumericQ, di_NumericQ] := ...  – Daniel Lichtblau May 20 '15 at 19:15
• Strictly speaking, it probably was going to run alright but slowly. The issue is that symbolic processing might be attempted and Optm might not be evaluating "nicely" for symbolic input (input that is in terms of the variables and not numeric values). Forcing it to be undefined except for explicitly numeric input is a way to circumvent this. – Daniel Lichtblau May 20 '15 at 22:37