TransWikia.com

help in plotting Minimize function

Mathematica Asked on April 27, 2021

Please help in plotting the following function versus $c2 in [-1,1]$
$$S = mathop {min }limits_{theta 1,theta 2,phi 1,phi 2} F(c2,theta 1,theta 2,phi 1,phi 2)$$

where ${theta _i},{phi _i}$ belong to the interval $[0,2pi ]$.

Here my function:

S = 1/(32 Log[2]) E^(-I (ϕ1 + ϕ2)) (8 (-2 E^(I (ϕ1 + ϕ2)) + 
        1/2 √(E^(2 I (ϕ1 + ϕ2)) + 
            c2^2 (E^(2 I ϕ1) + E^(4 I ϕ1) + E^(
               2 I ϕ2) + E^(4 I ϕ2) + 
               3 E^(2 I (ϕ1 + ϕ2)) + E^(
               2 I (2 ϕ1 + ϕ2)) + E^(
               2 I (ϕ1 + 2 ϕ2))) + 
            c2 (1 + E^(2 I ϕ1) + E^(2 I ϕ2) + E^(
               4 I (ϕ1 + ϕ2)) + E^(
               2 I (2 ϕ1 + ϕ2)) + E^(
               2 I (ϕ1 + 2 ϕ2)))) Abs[Sin[2 θ1]] Abs[
          Sin[2 θ2]]) Log[
       1/8 E^(-I (ϕ1 + ϕ2)) (4 E^(
           I (ϕ1 + ϕ2)) - √(E^(
              2 I (ϕ1 + ϕ2)) + 
              c2^2 (E^(2 I ϕ1) + E^(4 I ϕ1) + E^(
                 2 I ϕ2) + E^(4 I ϕ2) + 
                 3 E^(2 I (ϕ1 + ϕ2)) + E^(
                 2 I (2 ϕ1 + ϕ2)) + E^(
                 2 I (ϕ1 + 2 ϕ2))) + 
              c2 (1 + E^(2 I ϕ1) + E^(2 I ϕ2) + E^(
                 4 I (ϕ1 + ϕ2)) + E^(
                 2 I (2 ϕ1 + ϕ2)) + E^(
                 2 I (ϕ1 + 2 ϕ2)))) Abs[
            Sin[2 θ1]] Abs[Sin[2 θ2]])] - 
     4 (4 E^(
         I (ϕ1 + ϕ2)) + √(E^(
            2 I (ϕ1 + ϕ2)) + 
            c2^2 (E^(2 I ϕ1) + E^(4 I ϕ1) + E^(
               2 I ϕ2) + E^(4 I ϕ2) + 
               3 E^(2 I (ϕ1 + ϕ2)) + E^(
               2 I (2 ϕ1 + ϕ2)) + E^(
               2 I (ϕ1 + 2 ϕ2))) + 
            c2 (1 + E^(2 I ϕ1) + E^(2 I ϕ2) + E^(
               4 I (ϕ1 + ϕ2)) + E^(
               2 I (2 ϕ1 + ϕ2)) + E^(
               2 I (ϕ1 + 2 ϕ2)))) Abs[Sin[2 θ1]] Abs[
          Sin[2 θ2]]) Log[
       1/8 E^(-I (ϕ1 + ϕ2)) (4 E^(
           I (ϕ1 + ϕ2)) + √(E^(
              2 I (ϕ1 + ϕ2)) + 
              c2^2 (E^(2 I ϕ1) + E^(4 I ϕ1) + E^(
                 2 I ϕ2) + E^(4 I ϕ2) + 
                 3 E^(2 I (ϕ1 + ϕ2)) + E^(
                 2 I (2 ϕ1 + ϕ2)) + E^(
                 2 I (ϕ1 + 2 ϕ2))) + 
              c2 (1 + E^(2 I ϕ1) + E^(2 I ϕ2) + E^(
                 4 I (ϕ1 + ϕ2)) + E^(
                 2 I (2 ϕ1 + ϕ2)) + E^(
                 2 I (ϕ1 + 2 ϕ2)))) Abs[
            Sin[2 θ1]] Abs[Sin[2 θ2]])]);

One Answer

First make S into a proper function like this (clear kernel first):

S[ϕ1_?NumericQ, ϕ2_?NumericQ, θ1_?NumericQ, θ2_?NumericQ, c2_?NumericQ] := ...

Then write:

cx[a_] := 0 <= a <= 2 π
f[c2_] := NMinimize[{Re@S[ϕ1, ϕ2, θ1, θ2, c2], 
     cx[ϕ1], cx[ϕ2], cx[θ1], 
     cx[θ2]}, {ϕ1, ϕ2, θ1, θ2}][[1]] //Re

It only considers the real part as there's a very small imaginary part (floating point error?) which needs to be discarded.

Plot[f[c2], {c2, -1, 1}]

plot

Correct answer by flinty on April 27, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP