# Plotting values from the rules obtained from solving multiple iterations of an equation

After running this equation in a loop and obtaining the solutions for α and β I want to plot the corresponding sin(β) vs sin(α) graph. But with the solutions carrying (α and β) as labels I have to remove the variable name one by one and then proceed. Is there a way to obtain the solutions, manipulate them by applying Sin function on them and directly plot them? I also need to filter out the imaginary solutions.

Below is the code:

Do[LCKM = {{c12 c13, s12 s13,
s13 Exp[-I \[Delta]]}, {-s12 c23 - c12 s23 s13 Exp[I \[Delta]],
c12 c23 - s12 s23 s13 Exp[I \[Delta]],
s23 c13}, {s12 s23 - c12 c23 s13 Exp[I \[Delta]], -c12 s23 -
s12 c23 s13 Exp[I \[Delta]], c23 c13}};
Dv = {{1, 0, 0}, {0, Exp[I \[Alpha]], 0}, {0, 0,
Exp[I (\[Beta] + \[Delta])]}};
LPMNS = LCKM.Dv;
MmM = {{ m1, 0, 0}, {0, Sqrt[m1^2  + dm12^2], 0}, {0, 0,
Sqrt[m1^2 + dm13^2]}};
RPMNS = Transpose[LPMNS];
dm12 = RandomReal[{Sqrt[7.03*10^-5], Sqrt[8.09*10^-5]}];
dm13 = RandomReal[{Sqrt[2.407*10^-3], Sqrt[2.643*10^-3]}];
s12 = RandomReal[{Sqrt[0.271], Sqrt[0.345]}];
s23 = RandomReal[{Sqrt[0.385], Sqrt[0.635]}];
s13 = RandomReal[{Sqrt[0.01934], Sqrt[0.02392]}];
\[Delta] = RandomReal[{0, 2 \[Pi]}];
m1 = RandomReal[{10^-6, 10^-1}];
c12 = Sqrt[1 - s12^2];
c13 = Sqrt[1 - s13^2];
c23 = Sqrt[1 - s23^2];
UP = LPMNS.MmM.RPMNS;
Assuming[{\[Alpha] \[Element] Reals, \[Beta] \[Element] Reals},
data[i] = FindRoot[{FullSimplify[ComplexExpand[Re[UP[[1, 2]]]]] == 0,
FullSimplify[ComplexExpand[Im[UP[[1, 2]]]]] == 0},
{\[Alpha], 0}, {\[Beta],0}]], {i, 0, 1000, 1}]
Do[Print[data[i]], {i, 1, 1000}]

• It might be easier to help if we had your UP function (or something similar), but it seems like you want to be using Table. Commented Oct 20, 2017 at 11:04
• The imaginary parts are very small and probably artifacts of using machine precision. They can be removed with Chop. After you take the Sin the points are tightly clustered around a few points. This will make labeling difficult. Commented Oct 20, 2017 at 17:48

Is there a way to obtain the solutions, manipulate them by applying sin function on them and directly plot them? I also need to filter out the imaginary solutions.

Let results = {{α -> 73.7436, β -> 1.48695}, ... {α -> -7.70912, β -> 4.85723}}.

You can get the list of {α, β} value pairs using

alphabetavalues = results[[All, All, -1]]
(* or alphabetavalues = results /. Rule -> List *)


and remove the complex roots from alphabetavalues using Select:

realresults = Select[alphabetavalues, FreeQ[#, _Complex] &];
realresults // Column // TeXForm


$\begin{array}{l} \{73.7436,1.48695\} \\ \{2.97605,1.40524\} \\ \{-23.6117,10.9458\} \\ \{23.5821,-1.55061\} \\ \{17.1438,4.57741\} \\ \{89.4655,-4.78226\} \\ \{-33.014,4.68514\} \\ \{64.2895,-4.82556\} \\ \{-89.4613,26.7777\} \\ \{-1.48688,1.65472\} \\ \{17.1707,4.6043\} \\ \{-7.70912,4.85723\} \\ \end{array}$

Applying Sin to this gives

sinalphasinbeta = Sin @ realresults;
sinalphasinbeta // Column // TeXForm


$\begin{array}{l} \{-0.996489,0.996487\} \\ \{0.164788,0.986327\} \\ \{0.998762,-0.998762\} \\ \{-0.999797,-0.999796\} \\ \{-0.990907,-0.990904\} \\ \{0.997559,0.99756\} \\ \{-0.999628,-0.999629\} \\ \{0.993605,0.993603\} \\ \{-0.997257,0.997251\} \\ \{-0.996481,0.99648\} \\ \{-0.994167,-0.994164\} \\ \{-0.989526,-0.989529\} \\ \end{array}$

ListPlot[(Tooltip /@ List /@ sinalphasinbeta),
Frame -> True, PlotRangePadding -> .2,
PlotLegends -> PointLegend[Pane /@ sinalphasinbeta]]


• Hey thanks a million! This easily solved my problem. Although I still got to add commas after each {alpha, beta} value in the 'result'. Or else there's no output. I know this is menial stuff but is there a way to add a comma after value bracket and then store them right away? Rest all works just fine. Commented Oct 21, 2017 at 8:21
• @Eshan, my pleasure. Thank you for the accept. Re commas: instead of Do[Print[data[i]], {i, 1, 1000}] you can use results = data/@Range[1000]
– kglr
Commented Oct 21, 2017 at 14:12