upF = {{0.375, -0.225754 + 0.0998109 I,
0.125, -0.0752515 - 0.0998109 I}, {-0.225754 - 0.0998109 I,
0.375, -0.0752515 + 0.0998109 I,
0.125}, {0.125, -0.0752515 - 0.0998109 I,
0.125, -0.0752515 - 0.0998109 I}, {-0.0752515 + 0.0998109 I,
0.125, -0.0752515 + 0.0998109 I, 0.125}}
p1 = KroneckerProduct[{Cos[\[Theta]], Exp[I \[Phi]]*Sin[\[Theta]]},
Conjugate[{Cos[\[Theta]], Exp[I \[Phi]]*Sin[\[Theta]]}]];
p2 = KroneckerProduct[{Exp[-I \[Phi]]*Sin[\[Theta]], -Cos[\[Theta]]},
Conjugate[{Exp[-I \[Phi]]*Sin[\[Theta]], -Cos[\[Theta]]}]];
dTraceSystem[upF, {2}, 2]
upF1 = dTraceSystem[
Flatten[Map[KroneckerProduct @@ # &, {{IdentityMatrix[2], p1}}],
1].upF.Flatten[
Map[KroneckerProduct @@ # &, {{IdentityMatrix[2], p1}}], 1], {2},
2];
upF2 = dTraceSystem[
Flatten[Map[KroneckerProduct @@ # &, {{IdentityMatrix[2], p2}}],
1].upF.Flatten[
Map[KroneckerProduct @@ # &, {{IdentityMatrix[2], p2}}], 1], {2},
2];
probM1 = Simplify[
ComplexExpand[
Tr[Flatten[
Map[KroneckerProduct @@ # &, {{IdentityMatrix[2], p1}}],
1].upF.Flatten[
Map[KroneckerProduct @@ # &, {{IdentityMatrix[2], p1}}],
1]]]];
probM2 = Simplify[
ComplexExpand[
Tr[Flatten[
Map[KroneckerProduct @@ # &, {{IdentityMatrix[2], p2}}],
1].upF.Flatten[
Map[KroneckerProduct @@ # &, {{IdentityMatrix[2], p2}}],
1]]]];
test1 = upF1/probM1
test2 = upF2/probM2
oop = Eigenvalues[test1 + 10^-15 IdentityMatrix[Length[test1]]];
entropyOop =
ComplexExpand[-Sum[
oop[[j]] Log[2, oop[[j]]], {j, 1, Length[oop]}]];
ComplexExpand[entropyOop[[1]]]
oop1 = Eigenvalues[test2 + 10^-15 IdentityMatrix[Length[test2]]];
entropyOop1 =
ComplexExpand[-Sum[
oop1[[j]] Log[2, oop1[[j]]], {j, 1, Length[oop1]}]];
NMinimize[{probM1*entropyOop +
probM2*entropyOop1, {\[Theta] \[Element] Reals, \[Theta] <=
2*\[Pi], \[Phi] \[Element] Reals,
0 <= \[Phi] <= 2*\[Pi]}}, {\[Theta], \[Phi]}]
So after this post, I thought I had a handle on how to utilize the min and max functions. However, I am still running into the problem of non real numbers, despite having complex expanded the eigenvalue calculations.
Using numericQ shouldn't help as, from my understanding, that is only employed to halt the evaluation of a function containing nMinimize until parameters have been passed to it. I tried it anyway, no change. I attempted to set up the eigenvalue calculations and matrix calculations of test1 and test2 as functions as well. However, this also hasn't solved the problem. Honestly, at this point I clearly don't understand how nMinimize actually works and I am just randomly trying things to get it to work.
Edit: To clarify, probM1 and probM2 minimize just fine. The issue seemsto come from the introduction of entropyOop and entropOop1.
Edit2 :Edit: So after having updated the code to the above, and attempting both Re and Chop to handle the imaginary parts, I am still getting either not a number or not a scalar value
Edit3:
Here is test1:
test1 = {{1/(0.5 -
0.602012 Cos[θ] Cos[ϕ] Sin[θ]) (Conjugate[
Cos[θ]] Cos[θ] ((0. + 0. I) +
0.375 Conjugate[
Cos[θ]] Cos[θ] - (0.225754 +
0.0998109 I) E^(-I Conjugate[ϕ])
Conjugate[Sin[θ]] Cos[θ]) +
E^(I ϕ)
Conjugate[
Cos[θ]] ((0. +
0. I) - (0.225754 - 0.0998109 I) Conjugate[
Cos[θ]] Cos[θ] +
0.375 E^(-I Conjugate[ϕ])
Conjugate[Sin[θ]] Cos[θ]) Sin[θ] +
E^(-I Conjugate[ϕ])
Conjugate[
Sin[θ]] Cos[θ] ((0. + 0. I) +
0.375 E^(I ϕ)
Conjugate[
Cos[θ]] Sin[θ] - (0.225754 + 0.0998109 I) E^(
I ϕ - I Conjugate[ϕ])
Conjugate[Sin[θ]] Sin[θ]) +
E^(I ϕ - I Conjugate[ϕ])
Conjugate[
Sin[θ]] Sin[θ] ((0. +
0. I) - (0.225754 - 0.0998109 I) E^(I ϕ)
Conjugate[Cos[θ]] Sin[θ] +
0.375 E^(I ϕ - I Conjugate[ϕ])
Conjugate[Sin[θ]] Sin[θ])),
1/(0.5 - 0.602012 Cos[θ] Cos[ϕ] Sin[θ]) \
(Conjugate[
Cos[θ]] Cos[θ] ((0. + 0. I) +
0.125 Conjugate[
Cos[θ]] Cos[θ] - (0.0752515 -
0.0998109 I) E^(-I Conjugate[ϕ])
Conjugate[Sin[θ]] Cos[θ]) +
E^(I ϕ)
Conjugate[
Cos[θ]] ((0. +
0. I) - (0.0752515 + 0.0998109 I) Conjugate[
Cos[θ]] Cos[θ] +
0.125 E^(-I Conjugate[ϕ])
Conjugate[Sin[θ]] Cos[θ]) Sin[θ] +
E^(-I Conjugate[ϕ])
Conjugate[
Sin[θ]] Cos[θ] ((0. + 0. I) +
0.125 E^(I ϕ)
Conjugate[
Cos[θ]] Sin[θ] - (0.0752515 - 0.0998109 I) E^(
I ϕ - I Conjugate[ϕ])
Conjugate[Sin[θ]] Sin[θ]) +
E^(I ϕ - I Conjugate[ϕ])
Conjugate[
Sin[θ]] Sin[θ] ((0. +
0. I) - (0.0752515 + 0.0998109 I) E^(I ϕ)
Conjugate[Cos[θ]] Sin[θ] +
0.125 E^(I ϕ - I Conjugate[ϕ])
Conjugate[Sin[θ]] Sin[θ]))}, {1/(
0.5 - 0.602012 Cos[θ] Cos[ϕ] Sin[θ]) (Conjugate[
Cos[θ]] Cos[θ] ((0. + 0. I) +
0.125 Conjugate[
Cos[θ]] Cos[θ] - (0.0752515 -
0.0998109 I) E^(-I Conjugate[ϕ])
Conjugate[Sin[θ]] Cos[θ]) +
E^(I ϕ)
Conjugate[
Cos[θ]] ((0. +
0. I) - (0.0752515 + 0.0998109 I) Conjugate[
Cos[θ]] Cos[θ] +
0.125 E^(-I Conjugate[ϕ])
Conjugate[Sin[θ]] Cos[θ]) Sin[θ] +
E^(-I Conjugate[ϕ])
Conjugate[
Sin[θ]] Cos[θ] ((0. + 0. I) +
0.125 E^(I ϕ)
Conjugate[
Cos[θ]] Sin[θ] - (0.0752515 - 0.0998109 I) E^(
I ϕ - I Conjugate[ϕ])
Conjugate[Sin[θ]] Sin[θ]) +
E^(I ϕ - I Conjugate[ϕ])
Conjugate[
Sin[θ]] Sin[θ] ((0. +
0. I) - (0.0752515 + 0.0998109 I) E^(I ϕ)
Conjugate[Cos[θ]] Sin[θ] +
0.125 E^(I ϕ - I Conjugate[ϕ])
Conjugate[Sin[θ]] Sin[θ])),
1/(0.5 - 0.602012 Cos[θ] Cos[ϕ] Sin[θ]) \
(Conjugate[
Cos[θ]] Cos[θ] ((0. + 0. I) +
0.125 Conjugate[
Cos[θ]] Cos[θ] - (0.0752515 -
0.0998109 I) E^(-I Conjugate[ϕ])
Conjugate[Sin[θ]] Cos[θ]) +
E^(I ϕ)
Conjugate[
Cos[θ]] ((0. +
0. I) - (0.0752515 + 0.0998109 I) Conjugate[
Cos[θ]] Cos[θ] +
0.125 E^(-I Conjugate[ϕ])
Conjugate[Sin[θ]] Cos[θ]) Sin[θ] +
E^(-I Conjugate[ϕ])
Conjugate[
Sin[θ]] Cos[θ] ((0. + 0. I) +
0.125 E^(I ϕ)
Conjugate[
Cos[θ]] Sin[θ] - (0.0752515 - 0.0998109 I) E^(
I ϕ - I Conjugate[ϕ])
Conjugate[Sin[θ]] Sin[θ]) +
E^(I ϕ - I Conjugate[ϕ])
Conjugate[
Sin[θ]] Sin[θ] ((0. +
0. I) - (0.0752515 + 0.0998109 I) E^(I ϕ)
Conjugate[Cos[θ]] Sin[θ] +
0.125 E^(I ϕ - I Conjugate[ϕ])
Conjugate[Sin[θ]] Sin[θ]))}};
Here is test 2:
test2 = {{1/(0.5 +
0.602012 Cos[θ] Cos[ϕ] Sin[θ]) (Conjugate[
Cos[θ]] Cos[θ] ((0. + 0. I) +
0.375 Conjugate[
Cos[θ]] Cos[θ] + (0.225754 - 0.0998109 I) E^(
I Conjugate[ϕ])
Conjugate[Sin[θ]] Cos[θ]) -
E^(-I ϕ)
Conjugate[
Cos[θ]] ((0. +
0. I) - (0.225754 + 0.0998109 I) Conjugate[
Cos[θ]] Cos[θ] -
0.375 E^(I Conjugate[ϕ])
Conjugate[Sin[θ]] Cos[θ]) Sin[θ] -
E^(I Conjugate[ϕ])
Conjugate[
Sin[θ]] Cos[θ] ((0. + 0. I) -
0.375 E^(-I ϕ)
Conjugate[
Cos[θ]] Sin[θ] - (0.225754 -
0.0998109 I) E^(-I ϕ + I Conjugate[ϕ])
Conjugate[Sin[θ]] Sin[θ]) +
E^(-I ϕ + I Conjugate[ϕ])
Conjugate[
Sin[θ]] Sin[θ] ((0. +
0. I) + (0.225754 + 0.0998109 I) E^(-I ϕ)
Conjugate[Cos[θ]] Sin[θ] +
0.375 E^(-I ϕ + I Conjugate[ϕ])
Conjugate[Sin[θ]] Sin[θ])),
1/(0.5 + 0.602012 Cos[θ] Cos[ϕ] Sin[θ]) \
(Conjugate[
Cos[θ]] Cos[θ] ((0. + 0. I) +
0.125 Conjugate[
Cos[θ]] Cos[θ] + (0.0752515 + 0.0998109 I) E^(
I Conjugate[ϕ])
Conjugate[Sin[θ]] Cos[θ]) -
E^(-I ϕ)
Conjugate[
Cos[θ]] ((0. +
0. I) - (0.0752515 - 0.0998109 I) Conjugate[
Cos[θ]] Cos[θ] -
0.125 E^(I Conjugate[ϕ])
Conjugate[Sin[θ]] Cos[θ]) Sin[θ] -
E^(I Conjugate[ϕ])
Conjugate[
Sin[θ]] Cos[θ] ((0. + 0. I) -
0.125 E^(-I ϕ)
Conjugate[
Cos[θ]] Sin[θ] - (0.0752515 +
0.0998109 I) E^(-I ϕ + I Conjugate[ϕ])
Conjugate[Sin[θ]] Sin[θ]) +
E^(-I ϕ + I Conjugate[ϕ])
Conjugate[
Sin[θ]] Sin[θ] ((0. +
0. I) + (0.0752515 - 0.0998109 I) E^(-I ϕ)
Conjugate[Cos[θ]] Sin[θ] +
0.125 E^(-I ϕ + I Conjugate[ϕ])
Conjugate[Sin[θ]] Sin[θ]))}, {1/(
0.5 + 0.602012 Cos[θ] Cos[ϕ] Sin[θ]) (Conjugate[
Cos[θ]] Cos[θ] ((0. + 0. I) +
0.125 Conjugate[
Cos[θ]] Cos[θ] + (0.0752515 + 0.0998109 I) E^(
I Conjugate[ϕ])
Conjugate[Sin[θ]] Cos[θ]) -
E^(-I ϕ)
Conjugate[
Cos[θ]] ((0. +
0. I) - (0.0752515 - 0.0998109 I) Conjugate[
Cos[θ]] Cos[θ] -
0.125 E^(I Conjugate[ϕ])
Conjugate[Sin[θ]] Cos[θ]) Sin[θ] -
E^(I Conjugate[ϕ])
Conjugate[
Sin[θ]] Cos[θ] ((0. + 0. I) -
0.125 E^(-I ϕ)
Conjugate[
Cos[θ]] Sin[θ] - (0.0752515 +
0.0998109 I) E^(-I ϕ + I Conjugate[ϕ])
Conjugate[Sin[θ]] Sin[θ]) +
E^(-I ϕ + I Conjugate[ϕ])
Conjugate[
Sin[θ]] Sin[θ] ((0. +
0. I) + (0.0752515 - 0.0998109 I) E^(-I ϕ)
Conjugate[Cos[θ]] Sin[θ] +
0.125 E^(-I ϕ + I Conjugate[ϕ])
Conjugate[Sin[θ]] Sin[θ])),
1/(0.5 + 0.602012 Cos[θ] Cos[ϕ] Sin[θ]) \
(Conjugate[
Cos[θ]] Cos[θ] ((0. + 0. I) +
0.125 Conjugate[
Cos[θ]] Cos[θ] + (0.0752515 + 0.0998109 I) E^(
I Conjugate[ϕ])
Conjugate[Sin[θ]] Cos[θ]) -
E^(-I ϕ)
Conjugate[
Cos[θ]] ((0. +
0. I) - (0.0752515 - 0.0998109 I) Conjugate[
Cos[θ]] Cos[θ] -
0.125 E^(I Conjugate[ϕ])
Conjugate[Sin[θ]] Cos[θ]) Sin[θ] -
E^(I Conjugate[ϕ])
Conjugate[
Sin[θ]] Cos[θ] ((0. + 0. I) -
0.125 E^(-I ϕ)
Conjugate[
Cos[θ]] Sin[θ] - (0.0752515 +
0.0998109 I) E^(-I ϕ + I Conjugate[ϕ])
Conjugate[Sin[θ]] Sin[θ]) +
E^(-I ϕ + I Conjugate[ϕ])
Conjugate[
Sin[θ]] Sin[θ] ((0. +
0. I) + (0.0752515 - 0.0998109 I) E^(-I ϕ)
Conjugate[Cos[θ]] Sin[θ] +
0.125 E^(-I ϕ + I Conjugate[ϕ])
Conjugate[Sin[θ]] Sin[θ]))}};
Here is the system for oop2:
{{0.75, 0.25}, {0.25, 0.25}}
Edit 5: Using the suggestion of mszynisz, I have rewrote them as expressions as opposed to functions.
dTraceSystem
is undefined. $\endgroup$entropyOop2
, or perhapsoop2
, or as a last resort, the definition ofdTraceSystem
. $\endgroup$