0
$\begingroup$

Please help me to plot the solution of a differential equation as a parameter of Delta. Here is what I've tried.

(**Constants**)

tin := -50;
tfin := 50;
t := 0.05;
v := 1;

(**Solve differential equation**)

sol = NDSolve[Delta == Module[{x0},
  Table[x0, {x0, 0, 10}]],
  {I y1'[t] == v t y1[t] +
    Delta y2[t], I y2'[t] == -v t y2[t] + Delta y1[t], y1[tin] == 1, y2[tin] == 0}, {y1, y2}, {t, tin, tfin}];

(**Probability**)

Prob1[t_] := 
      Re[Evaluate[y1[t] /. sol]]^2 + Im[Evaluate[y1[t] /. sol]]^2;

(**we need to plot this result as a function of delta**)

a = Plot[{Prob1[t]}, {Delta, -10, 10}]
$\endgroup$
2
  • $\begingroup$ The way you use Evaluate here doesn't do anything. It only has any effect if it appears directly as an argument of a function with a hold attribute, such as in Plot[Evaluate[...], ...]. $\endgroup$ Commented Jul 6, 2021 at 13:09
  • $\begingroup$ – Sjoerd Smit 1 please help me to correct this one by proposing a code that is correct, I presented the curve that I expected. $\endgroup$ Commented Jul 6, 2021 at 13:15

1 Answer 1

2
$\begingroup$

Is this the plot you want?

(**Constants**)
tin := -50;
tfin := 50;
t1 := 0.05;
v := 1;

(**Solve differential equation**)
sol = ParametricNDSolve[{I y1'[t] == v t y1[t] + Delta y2[t], 
    I y2'[t] == -v t y2[t] + Delta y1[t], y1[tin] == 1, 
    y2[tin] == 0}, {y1, y2}, {t, tin, tfin}, Delta];

(**Probability**)
Prob1[Delta_, t_] := Abs[y1[Delta][t]]^2;

(**we need to plot this result as a function of delta**)
a = ListPlot[Table[{Delta, Prob1[Delta, t1]} /. sol, {Delta, -10, 10}]]

Plot

$\endgroup$
1
  • $\begingroup$ Please i Do not satisfy, i want that t and Delta varies. How Can we do? $\endgroup$ Commented Jul 7, 2021 at 10:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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