2
$\begingroup$

I am trying to plot the solutions of this equation.

eq[x_, k_, T_] := -Sin[3*k + x]/Sin[4*k + x] + P + 
    Cos[k] + T^2 + (A*T^2*Sin[k]^2)/(Sin[4*k + x]^2 + 
    B*T^2*Sin[k]^2) == 0 /. {A -> 1/2, B -> 0.0001, 
      P -> -2.38}

sol[T_?NumericQ, k_ /; 0 <= k <= Pi] := 
   x /. NSolve[{eq[x, k, T], 0 <= x <= Pi}, x, Reals]

ListLinePlot[Table[sol[T, 0.2], {T, 0.1, 1.2, 0.1}]]

It has three solutions for each T and k, I want to plot for a specific k which I defined in the above case to be $k=0.2$ inside sol[T, 0.2]. It gives me a list of multi-solutions for various T values {T, 0.1, 1.2, 0.1}. I want T to be one of the axis of the plot with these three solution curves, but it shows several curves, more than three. Should I use some other type of plot?

$\endgroup$
2
$\begingroup$
ListLinePlot[Transpose@Table[sol[t, 0.2], {t, 0.1, 1.2, 0.1}], 
 DataRange -> {0, 1.2}, Frame -> True, 
 FrameLabel -> {t, Subscript[x, i][t, .2]}, 
 PlotLegends -> {Subscript[x, 1][t, .2], Subscript[x, 2][t, .2], Subscript[x, 3][t, .2]}]

enter image description here

$\endgroup$
  • $\begingroup$ Thanks a lot. This t corresponds to T^2 in the equation then? $\endgroup$ – AtoZ Mar 12 at 14:59
  • $\begingroup$ Could't we just write 'T' or there was a reason to write 't' instead of 'T'? Thanks $\endgroup$ – AtoZ Mar 12 at 15:56
  • 2
    $\begingroup$ @AtoZ, yes t corresponds to T. You can use T in place of t. I used lower case to avoid possible conflict with a built-in function (e.g. N or C); in this case there is no built-in function T; so it is ok. $\endgroup$ – kglr Mar 12 at 16:11
  • $\begingroup$ Thank you very much, now I will play with it for other variants :) $\endgroup$ – AtoZ Mar 12 at 16:15

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.