I'll tackle your questions from your Example.nb one at a time in separate replies:
As you can see in the matrix from the previous command, there are pairs.08 {x,y} and x assumes low and high values for each y value. For instance, the first two elements have x=3.58297 and x=0.316068 for y=0.01
Question: How to separate this list into two lists where one has the highest values of x while the one list has the lowest values of x?
So, early on you created a table using some ranges. You threw away the range info. Then later on you tried to re-incorporate the range info. This is a very complicated workflow. So, I'd simplify the whole thing as follows.
Let's start here:
\[Delta]tRoots = Table[SolveValues[fjf\[Delta]t[jf, \[Delta]t] == 0, \[Delta]t, Reals], {jf, 0.001, 1, 0.1}];
\[Delta]tRootsF = Flatten[\[Delta]tRoots]
(* {0.0169133,0.211189,0.788811,0.983087,0.0978286,0.194265,0.805735,0.902171} *)
For clarity, I changed the range step so that we have shorter lists to look at. Next you define a range.
jfRange = Range[0.01, 1, 0.2]
(* {0.01, 0.21, 0.41, 0.61, 0.81} *)
I did a similar simplification. And now you get your main result.
jgRoots =
Table[
SolveValues[fjfjg\[Delta]t[jf, jg, \[Delta]t] == 0, jg, Reals], {\[Delta]t, \[Delta]tRootsF},
{jf, jfRange}]
(* {{{3.58297},{17.5798},{25.4253},{31.6752},{37.0623}},{{0.316068},{0.332205},{0.347738},{0.362734},{0.37725}},{{},{},{},{},{}},{{},{},{},{},{}},{{0.858419},{1.11999},{1.33969},{1.53368},{1.70974}},{{0.374548},{0.397487},{0.419413},{0.440458},{0.460727}},{{},{},{},{},{}},{{},{},{},{},{}}} *)
The next bunch of code in your notebook is trying to get the jfRange
values assocated back in to these results. But you could have just done that to start. Here are a few ways.
jgRootsAlt1 =
Table[
{jf, SolveValues[fjfjg\[Delta]t[jf, jg, \[Delta]t] == 0, jg, Reals]},
{\[Delta]t, \[Delta]tRootsF},
{jf, jfRange}]
(*
{{{0.01,{3.58297}},{0.21,{17.5798}},{0.41,{25.4253}},{0.61,{31.6752}},{0.81,{37.0623}}},
{{0.01,{0.316068}},{0.21,{0.332205}},{0.41,{0.347738}},{0.61,{0.362734}},{0.81,{0.37725}}},
{{0.01,{}},{0.21,{}},{0.41,{}},{0.61,{}},{0.81,{}}},
{{0.01,{}},{0.21,{}},{0.41,{}},{0.61,{}},{0.81,{}}},
{{0.01,{0.858419}},{0.21,{1.11999}},{0.41,{1.33969}},{0.61,{1.53368}},{0.81,{1.70974}}},
{{0.01,{0.374548}},{0.21,{0.397487}},{0.41,{0.419413}},{0.61,{0.440458}},{0.81,{0.460727}}},
{{0.01,{}},{0.21,{}},{0.41,{}},{0.61,{}},{0.81,{}}},
{{0.01,{}},{0.21,{}},{0.41,{}},{0.61,{}},{0.81,{}}}}
*)
But with this, we'll need to use Transpose
to get all the solutions for the same jfRange
value together. We can avoid that by just changing the order of our iterators.
jgRootsAlt2 =
Table[
{jf, SolveValues[fjfjg\[Delta]t[jf, jg, \[Delta]t] == 0, jg, Reals]},
{jf, jfRange},
{\[Delta]t, \[Delta]tRootsF}]
(*
{{{0.01,{3.58297}},{0.01,{0.316068}},{0.01,{}},{0.01,{}},{0.01,{0.858419}},{0.01,{0.374548}},{0.01,{}},{0.01,{}}},
{{0.21,{17.5798}},{0.21,{0.332205}},{0.21,{}},{0.21,{}},{0.21,{1.11999}},{0.21,{0.397487}},{0.21,{}},{0.21,{}}},
{{0.41,{25.4253}},{0.41,{0.347738}},{0.41,{}},{0.41,{}},{0.41,{1.33969}},{0.41,{0.419413}},{0.41,{}},{0.41,{}}},
{{0.61,{31.6752}},{0.61,{0.362734}},{0.61,{}},{0.61,{}},{0.61,{1.53368}},{0.61,{0.440458}},{0.61,{}},{0.61,{}}},
{{0.81,{37.0623}},{0.81,{0.37725}},{0.81,{}},{0.81,{}},{0.81,{1.70974}},{0.81,{0.460727}},{0.81,{}},{0.81,{}}}}
*)
Now you want to collect these groups together and find minimums and maximums. You could do this with this structure, but there is built in functionality, Merge
that will do all of that for us. To use Merge
we need Rule
s. So, let's try yet again...
jgRootsAlt3 =
Table[
jf -> SolveValues[fjfjg\[Delta]t[jf, jg, \[Delta]t] == 0, jg, Reals],
{jf, jfRange},
{\[Delta]t, \[Delta]tRootsF}]
(*
{{0.01->{3.58297},0.01->{0.316068},0.01->{},0.01->{},0.01->{0.858419},0.01->{0.374548},0.01->{},0.01->{}},
{0.21->{17.5798},0.21->{0.332205},0.21->{},0.21->{},0.21->{1.11999},0.21->{0.397487},0.21->{},0.21->{}},
{0.41->{25.4253},0.41->{0.347738},0.41->{},0.41->{},0.41->{1.33969},0.41->{0.419413},0.41->{},0.41->{}},
{0.61->{31.6752},0.61->{0.362734},0.61->{},0.61->{},0.61->{1.53368},0.61->{0.440458},0.61->{},0.61->{}},
{0.81->{37.0623},0.81->{0.37725},0.81->{},0.81->{},0.81->{1.70974},0.81->{0.460727},0.81->{},0.81->{}}}
*)
And now...
Merge[jgRootsAlt3, MinMax@*Flatten]
(* <|0.01->{0.316068,3.58297},0.21->{0.332205,17.5798},0.41->{0.347738,25.4253},0.61->{0.362734,31.6752},0.81->{0.37725,37.0623}|> *)
Okay, I probably need to explain MinMax@*Flatten
. Merge
let's you supply a function to apply to the list of elements that share a common key. Try a dummy function just to see how it works:
Merge[jgRootsAlt3, someFunction]
(*
<|0.01->someFunction[{{3.58297},{0.316068},{},{},{0.858419},{0.374548},{},{}}],
...etc...
0.81->someFunction[{{37.0623},{0.37725},{},{},{1.70974},{0.460727},{},{}}]|>
*)
Well, we know we want to flatten things:
Merge[jgRootsAlt3, Flatten]
(*
<|0.01->{3.58297,0.316068,0.858419,0.374548},
....etc....
0.81->{37.0623,0.37725,1.70974,0.460727}|>
*)
And now, we'd like to find minimums and maximums. You can apply functions over Associations
directly, and fortunately, there is a built in function to do both Min
and Max
:
MinMax /@ Merge[jgRootsAlt3, Flatten]
(* <|0.01->{0.316068,3.58297},0.21->{0.332205,17.5798},0.41->{0.347738,25.4253},0.61->{0.362734,31.6752},0.81->{0.37725,37.0623}|> *)
And you could just use that. But I got fancy and just did the whole thing with Merge
by using Composition
. You can compose two functions into a single function that applies both in sequence. That's how I got to MinMax@*Flatten
.
So, at this point, we have some data that's organized into what you want. It's not how you originally envisioned it, but it's semantically equivalent. With that data, we can move on to plotting:
minMaxData = Merge[jgRootsAlt3, MinMax@*Flatten]
(It may take me awhile to post the next answer about plotting...)