I am not so familiar with Mathematica programming. Here is my problem. I have defined the parameters in the first step:

$G = 0.6, \Gamma = 0.5, r_1 = 1, r_2 = 1, \theta_1 = \pi/4, \theta_2 = \pi/4$, and $t=0$

Then, I have defined some functions:

Δ = G - Γ; 
ω = Sqrt[-4 + G^2 + 2 G Γ + Γ^2];

r11 = (E^(t Δ) (ω Cosh[t ω] + (G + Γ) Sinh[t ω]))/ω;
r12 = (2   E^(t Δ) Sinh[t ω])/ω;
s11 = ((G + Γ + ω) E^( (Δ + ω) (t - u )))/(2 ω) + ((-G - Γ + ω) E^( (Δ - ω) (t - u )))/(2 ω);
s12 = (E^( (Δ + ω) (t - u )))/ ω - (E^( (Δ - ω) (t - u )))/ ω;

Ia = Cosh[t Δ]^2 Cosh[t ω]^2 Sinh[r1]^2 + 2 Cosh[t Δ] Cosh[t ω]^2 Sinh[r1]^2 Sinh[t Δ] + Cosh[t ω]^2 Sinh[r1]^2 Sinh[t Δ]^2 + (2 G Cosh[t Δ]^2 Cosh[t ω] Sinh[r1]^2 Sinh[t ω])/ω + (2 Γ Cosh[t Δ]^2 Cosh[t ω] Sinh[r1]^2 Sinh[t ω])/ω // Chop;

var = r11^2 Cosh[r1]^2 + r12^2 Cosh[r2]^2 - 
    2 r11^2 Cos[θ1] Cosh[r1] Sinh[r1] + r11^2 Sinh[r1]^2 + 
    r12^2 Sinh[r2]^2 +
    r12^2 Cos[θ2] Sinh[2 r2] + 
    Integrate[2 G s11^2 + 2 s12^2 Γ // Expand, {u, 0, t}] // Chop;

At this step, I should change the definition of G as $G = 0.6/(1 + I_a/2)$ and the new time is $t = t + 0.001$. Now we should turn back to the beginning of the codes and repeat this loop until $t=3$. Finally, I should plot $Ia$ and $-Log[var]$ from $t= 0$ to $3$. If $G$ remains constant, it is easy to plot, but I need to calculate the new $G$ at each step and replace it. I will appreciate it if you help me.


Use a Table to collect your points and then extract and plot.

G=0.6; Γ=0.5; r1=1; r2=1; θ1=π/4; θ2=π/4;
points = Table[
  Δ=G-Γ; ω=Sqrt[-4+G^2+2 G Γ+Γ^2]; 
  r11=(E^(t Δ)(ω Cosh[t ω]+(G+Γ)Sinh[t ω]))/ω; 
  r12=(2 E^(t Δ)Sinh[t ω])/ω; 
  s11=((G+Γ+ω)E^((Δ+ω)(t-u)))/(2 ω)+((-G-Γ+ω)E^((Δ-ω)(t-u)))/(2 ω); 
  Ia=Cosh[t Δ^2] Cosh[t ω]^2 Sinh[r1]^2+2 Cosh[t Δ]Cosh[t ω]^2 Sinh[r1]^2 Sinh[t Δ]+
    Cosh[t ω]^2 Sinh[r1]^2 Sinh[t Δ]^2+(2 G Cosh[t Δ]^2 Cosh[t ω]*
    Sinh[r1]^2 Sinh[t ω])/ω+(2 Γ Cosh[t Δ]^2 Cosh[t ω] Sinh[r1]^2*Sinh[t ω])/ω//Chop; 
  var=r11^2 Cosh[r1]^2+r12^2 Cosh[r2]^2-2 r11^2 Cos[θ1] Cosh[r1] Sinh[r1]+
    r11^2 Sinh[r1]^2+r12^2 Sinh[r2]^2+r12^2 Cos[θ2] Sinh[2 r2]+ 
    Integrate[2 G s11^2+2 s12^2 Γ // Expand, {u, 0, t}] //Chop;
  {{t, Ia}, {t, -Log[var]}}, {t,0,3,.001}];
Iapoints = Map[First, points];
varpoints = Map[Last, points];

enter image description here

enter image description here

Please check all this very carefully to make sure there are no errors

| improve this answer | |

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.