Group Abstract Group Abstract

Message Boards Message Boards

0
|
2.6K Views
|
4 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Empty Plot of Max of symbolic expression?

Posted 3 years ago
nl=   Max[0, -(1/Log[2]) Log[
           Sqrt[2] \[Sqrt](0.5 - 6.12563 E^(-6. t) Cos[2.034 t]^4 + 
               0.25 (E^(-3. t))[4.05 - 4.05 Cos[4.068 t]] + 
               0.0625 (E^(-3. t))[4.05 - 4.05 Cos[4.068 t]]^2 + 
               0.25 (E^(-3. t))[4.05 + 4.05 Cos[4.068 t]] + 
               0.0625 (E^(-3. t))[4.05 + 4.05 Cos[4.068 t]]^2 - 
               6.12563 E^(-6. t) Sin[2.034 t]^4 - (4.07531 + 0. I) E^(-6. t)
                 Sin[4.068 t]^2 - \[Sqrt](-4. E^(-12. t) (0.0625 E^(
                      6. t) (2. + (E^(-3. t))[
                         4.05 - 4.05 Cos[4.068 t]])^2 (-6.12563 Cos[
                          2.034 t]^4 + 
                        0.0625 E^(
                         6. t) (2. + (E^(-3. t))[
                            4.05 + 4.05 Cos[4.068 t]])^2) - 
                     6.12563 (-6.12563 Cos[2.034 t]^4 + 
                        0.0625 E^(
                         6. t) (2. + (E^(-3. t))[
                            4.05 + 4.05 Cos[4.068 t]])^2) Sin[
                       2.034 t]^4) + (0.5 - 
                    6.12563 E^(-6. t) Cos[2.034 t]^4 + 
                    0.25 (E^(-3. t))[4.05 - 4.05 Cos[4.068 t]] + 
                    0.0625 (E^(-3. t))[4.05 - 4.05 Cos[4.068 t]]^2 + 
                    0.25 (E^(-3. t))[4.05 + 4.05 Cos[4.068 t]] + 
                    0.0625 (E^(-3. t))[4.05 + 4.05 Cos[4.068 t]]^2 - 
                    6.12563 E^(-6. t)
                      Sin[2.034 t]^4 - (4.07531 + 0. I) E^(-6. t)
                      Sin[4.068 t]^2)^2))]];
    Plot[nl,{t,0,2}]
POSTED BY: Danish Hamza
4 Replies
Posted 3 years ago

I want to use solution of coupled differential equation further in the code can you help me in this regard. Proper code is pasted below, The solution of differential equation named as n1, n2 ms, mc, m1, m2 are the elements of a matrix , so i want these solution directly in the matrix.

Clear["Global`*"]
\[Mu] = 1; \[Tau] = 0.45;
d1 = 1/(4 \[Mu]^2 (1 - 2 \[Tau])) + (1 - 2 \[Tau])/4; 
 d2 = 1/(4 \[Mu]^2 (1 - 2 \[Tau])) - (1 - 2 \[Tau])/4;

 \[Phi] = 0; \[Gamma] = 20; \[CapitalOmega] = 1000;
  \[Theta] = 0;

G = 101.7; 
\[Alpha]11 = 0; \[Alpha]22 = 0; \[Alpha]11b = 0; \[Alpha]22b = 0;
\[Alpha]12 = 2*I*G*\[Gamma]/\[CapitalOmega];
\[Alpha]21 = 2*I*G*\[Gamma]/\[CapitalOmega];
\[Alpha]12b = -2*I*G*\[Gamma]/\[CapitalOmega];
\[Alpha]21b = -2*I*G*\[Gamma]/\[CapitalOmega];

\[Kappa]1 = 1.5;
\[Kappa]2 = 1.5;
solA = DSolve[{n1'[
      t] == (1/2) (\[Alpha]11 + \[Alpha]11b - 4 \[Kappa]1)*
       n1[t] + (1/2) E^(I \[Phi]) \[Alpha]12b*
       ms[t] + (1/2) E^(-I \[Phi]) \[Alpha]12*mss[t] + 
      1/2*(\[Alpha]11 + \[Alpha]11b), 
    n2'[t] == (1/2) (\[Alpha]22 + \[Alpha]22b - 4 \[Kappa]2) n2[
        t] + (1/2) E^(I \[Phi]) \[Alpha]21*
       ms[t] + (1/2) E^(-I \[Phi]) \[Alpha]21b*mss[t] + 
      1/2*(\[Alpha]22 + \[Alpha]22b), 
    ms'[t] == (1/2) E^(-I \[Phi]) \[Alpha]21b*
       n1[t] + (1/2) E^(-I \[Phi]) \[Alpha]12*
       n2[t] + (1/
         2) (\[Alpha]11 + \[Alpha]22b - (2 (\[Kappa]1 + \[Kappa]2)))*
       ms[t] + (1/2) (\[Alpha]12 + \[Alpha]21b) E^(-I \[Phi]), 
    mss'[t] == (1/2) E^(I \[Phi]) \[Alpha]21*n1[t] + (1/2) E^(
       I \[Phi]) \[Alpha]12b*
       n2[t] + (1/
         2) (\[Alpha]11b + \[Alpha]22 - (2 (\[Kappa]1 + \[Kappa]2)))*
       mss[t] + (1/2) (\[Alpha]12b + \[Alpha]21) E^(I \[Phi]), 
    n1[0] == d1 - 0.5 , n2[0] == 0, ms[0] == 0, mss[0] == 0}, {n1, n2,
     ms, mss}, {t}];
solB = DSolve[{m1'[t] ==  (\[Alpha]11 - 2 \[Kappa]1)*m1[t] + 
      E^(-I \[Phi]) \[Alpha]12*mc[t], 
    m2'[t] == (\[Alpha]22 - 2 \[Kappa]2) m2[t] + 
      E^(I \[Phi]) \[Alpha]21*mc[t], 
    mc'[t] == 
     1/2 E^(I \[Phi]) \[Alpha]21*m1[t] + 
      1/2 E^(-I \[Phi]) \[Alpha]12*m2[t] + 
      1/2 (\[Alpha]11 + \[Alpha]22 - 2 (\[Kappa]1 + \[Kappa]2))*mc[t],
     m1[0] == -d2 , m2[0] == 0, mc[0] == 0}, {m1, m2, mc}, {t}];
Vt = ( {
    {n1 + 0.5, -m1, ms, -mc},
    {-Conjugate[m1], n1 + 0.5, -Conjugate[mc], Conjugate[ms]},
    {Conjugate[ms], -mc, n2 + 0.5, -m2},
    {-Conjugate[mc], ms, -Conjugate[m2], n2 + 0.5}
   } ); 
Vtq = Chop[(Vt + Vt\[Transpose])/2];
Aq = ( {
    {n1 + 0.5, -m1},
    {-Conjugate[m1], n1 + 0.5}
   } );
Bq = ( {
    {n2 + 0.5, -m2},
    {-Conjugate[m2], n2 + 0.5}
   } );
Cq = ( {
    {ms, -mc},
    {-Conjugate[mc], mss}
   } );
sigma = Det[Aq] + Det[Bq] - 2 Det[Cq];
\[Xi] = Abs[Evaluate[Sqrt[(sigma - Sqrt[sigma^2 - 4*Det[Vtq]])/2]]];
Eme = Max[0, -Log2[2 \[Xi]]];

lg = LineLegend[{Directive[Black, AbsoluteThickness[3]], 
    Directive[Blue, Dashed, AbsoluteThickness[3]], 
    Directive[Red, AbsoluteThickness[3]]}, {"\[CapitalOmega]=1000"}];
Plot[Eme, {t, 0, 2}, 
 FrameTicks -> {{{0, 0.03, 0.2, 0.4, 0.6, 0.8, 1, 1.2, 1.4, 1.6, 1.8, 
     2}, None}, {{{0, 0}, {0.5, 50}, {1, 100}, {1.5, 150}, {2, 200}}, 
    None}}, PlotStyle -> {{Black, Thickness -> .007}, {Blue, 
    Thickness -> 0.007, Dashed}, {Red, Thickness -> 0.007}}, 
 Frame -> True, FrameTicksStyle -> 14, Axes -> False, 
 GridLines -> Automatic, GridLinesStyle -> Directive[Orange, Dashed], 
 PlotRange -> All, 
 PlotLegends -> Placed[lg, {Scaled[{0.67, 0.8}], {0, 0.2}}], 
 FrameLabel -> {Style["G t", FontSize -> 18, Bold], 
   Style["\!\(\*SubscriptBox[\(E\), \(N\)]\)", FontSize -> 18, Bold]}]
POSTED BY: Danish Hamza
Posted 3 years ago

Thanks mate.

POSTED BY: Danish Hamza

With correct syntax:

nl = Max[0, -(1/Log[2]) Log[
     Sqrt[2] \[Sqrt](0.5 - 6.12563 E^(-6. t) Cos[2.034 t]^4 + 
         0.25 (E^(-3. t)) (4.05 - 4.05 Cos[4.068 t]) + 
         0.0625 (E^(-3. t)) (4.05 - 4.05 Cos[4.068 t])^2 + 
         0.25 (E^(-3. t)) (4.05 + 4.05 Cos[4.068 t]) + 
         0.0625 (E^(-3. t)) (4.05 + 4.05 Cos[4.068 t])^2 - 
         6.12563 E^(-6. t) Sin[2.034 t]^4 - (4.07531 + 
            0. I) E^(-6. t) Sin[
            4.068 t]^2 - \[Sqrt](-4. E^(-12. t) (0.0625 E^(6. t) (2. \
+ (E^(-3. t)) (4.05 - 4.05 Cos[4.068 t]))^2 (-6.12563 Cos[
                    2.034 t]^4 + 
                  0.0625 E^(6. t) (2. + (E^(-3. t)) (4.05 + 
                    4.05 Cos[4.068 t]))^2) - 
               6.12563 (-6.12563 Cos[2.034 t]^4 + 
                  0.0625 E^(6. t) (2. + (E^(-3. t)) (4.05 + 
                    4.05 Cos[4.068 t]))^2) Sin[2.034 t]^4) + (0.5 - 
               6.12563 E^(-6. t) Cos[2.034 t]^4 + 
               0.25 (E^(-3. t)) (4.05 - 4.05 Cos[4.068 t]) + 
               0.0625 (E^(-3. t)) (4.05 - 4.05 Cos[4.068 t])^2 + 
               0.25 (E^(-3. t)) (4.05 + 4.05 Cos[4.068 t]) + 
               0.0625 (E^(-3. t)) (4.05 + 4.05 Cos[4.068 t])^2 - 
               6.12563 E^(-6. t) Sin[2.034 t]^4 - (4.07531 + 
                  0. I) E^(-6. t) Sin[4.068 t]^2)^2))]];
Plot[nl, {t, 0, 2}]

Works fine.

POSTED BY: Mariusz Iwaniuk

It is syntax: the square brackets are used only for the arguments of functions. Instead of

(E^(-3. t))[4.05 - 4.05 Cos[4.068 t]]

write

(E^(-3. t))*(4.05 - 4.05 Cos[4.068 t])
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard