1
$\begingroup$

I want to use NMinimize in the following way:

Uni[phi_, psi_,theta_] := {{E^(I*phi)*Cos[theta], E^(I*psi)*Sin[theta]}, {-E^(-I*psi)*Sin[theta], E^(-I*phi)*Cos[theta]}}
LocalUni[a1_, a2_, a3_, b1_, b2_, b3_, c1_, c2_, c3_] := KroneckerProduct[Uni[a1, b1, c1], KroneckerProduct[Uni[a2, b2, c2], Uni[a3, b3, c3]]]
StateDifference[a1_, a2_, a3_, b1_, b2_, b3_, c1_, c2_, c3_] := RhoKnown - LocalUni[a1, a2, a3, b1, b2, b3, c1, c2,  c3].RhoFound.ConjugateTranspose[LocalUni[a1, a2, a3, b1, b2, b3, c1, c2, c3]]

so I have the function StateDifference, and I want to minimize its absolute value, in terms of the a1,a2... parameters. Thus I apply:

NMinimize[{Abs[N[StateDifference[m1, m2, m3, m4, m5, m6, m7, m8, m9]]]}, {m1, m2, m3, m4, m5, m6, m7, m8, m9}]

where I just replaced a1,a2, with m1,m2 etc (this should not matter).

The problem is when I run this:

The objective function {{Abs[<<1>>],Abs[(-0.0526+0.0765 I)+<<1>>+<<11>>],Abs[(0.1122 -0.0484 I)+<<12>>],Abs[<<12>>+2.71828^(Times[<<2>>]+Times[<<2>>]+Times[<<2>>]) <<1>> ((-0.113-0.0444 I) Power[<<2>>] Cos[<<1>>] Cos[<<1>>] Cos[<<1>>]-(0.0196 -0.1235 I) Power[<<2>>] Cos[<<1>>] Cos[<<1>>] Sin[<<1>>]+(0.0062 +0.1358 I) Power[<<2>>] Cos[<<1>>] Cos[<<1>>] Sin[<<1>>]-(0.1134 -0.0651 I) <<3>> Sin[<<1>>]+(<<1>>) <<4>>-(0.1036 -0.0864 I) Power[<<2>>] Cos[<<1>>] Sin[<<1>>] Sin[<<1>>]+(0.0596 +0.1086 I) Power[<<2>>] Cos[<<1>>] Sin[<<1>>] Sin[<<1>>]+(0.1218 +0.014 I) Power[<<2>>] Sin[<<1>>] Sin[<<1>>] Sin[<<1>>])],Abs[(<<7>> +<<1>>)+<<12>>],Abs[<<1>>],Abs[<<1>>],Abs[(0.0314 +0.0286 I)+2.71828^(Times[<<2>>]+Times[<<2>>]+Times[<<2>>]) Conjugate[Sin[<<1>>] Sin[<<1>>] Sin[<<1>>]] (<<1>>)+<<11>>]},<<7>>} should be scalar-valued. >>

The matrices RhoKnown and RhoFound are just 2 numerical 8x8 matrices. (Hermitian and of trace 1).

$\endgroup$
2
$\begingroup$

The problem resides in the fact that I was minimizing over a matrix not a number. This can be done, however, over the sum of the total matrix elements, by using the line:

FinalFunct[a1_, a2_, a3_, b1_, b2_, b3_, c1_, c2_, c3_] := Sum[StateDifference[a1, a2, a3, b1, b2, b3, c1, c2,c3][[k]][[k]], {k, 1,   Length[StateDifference[a1, a2, a3, b1, b2, b3, c1, c2, c3]]}]

and using NMinimize on this function. My apologies for not seeing this before posting the question.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.