# Extract a List of Co-ordinates from a List of Complex Solutions

Let's say I have this list of solutions from a previous computation:

{
{x -> -9.640491283722653 - 5.790987589334252 I},
{x -> -9.640491283722653 + 5.790987589334252 I},
{x ->  0.- 14.792128645445802 I},
{x ->  0.+ 14.792128645445802 I},
{x ->  9.640491283722653- 5.790987589334252 I},
{x ->  9.640491283722653+ 5.790987589334252 I}
}


Now, how do I extract a list of coordinates from them?

Like

{
{-9.640491283722653, - 5.790987589334252},
{-9.640491283722653, + 5.790987589334252},
{0.,- 14.792128645445802},
{0.,+ 14.792128645445802},
{9.640491283722653,- 5.790987589334252},
{9.640491283722653,+ 5.790987589334252 }
}

-

Works nicely:

rules = {{x -> -9.640491283722653 - 5.790987589334252 I},
{x -> -9.640491283722653 + 5.790987589334252 I},
{x -> 0. - 14.792128645445802 I}, {x -> 0. + 14.792128645445802 I},
{x -> 9.640491283722653 - 5.790987589334252 I},
{x -> 9.640491283722653 + 5.790987589334252 I}};

Through[{Re, Im}[x]] /. rules
{{-9.64049, -5.79099}, {-9.64049, 5.79099}, {0., -14.7921}, {0., 14.7921},
{9.64049, -5.79099}, {9.64049, 5.79099}}

-
/. is a shortcut for which function ? – The-Ever-Kid Nov 24 '12 at 4:55
@The-Ever-Kid, in the interest of teaching you how to fish: highlight the /. in your Mathematica notebook and press F1. – J. M. Nov 24 '12 at 4:56
Thanks.....BTW you learned all you know from the Docs Right ? – The-Ever-Kid Nov 24 '12 at 4:58
...and reading other resources, and a lot of practice and trial and error. – J. M. Nov 24 '12 at 4:59

J. M. recommended: Through[{Re, Im}[x]] /. rules

I believe it is cleaner to use: {Re@x, Im@x} /. rules

These prove to be equivalent.

First an explanation of the replacement being done (with /.). As shown in the documentation when the right-hand side of /. is a list of lists of rules you get replacements for each:

x /. {{x -> 1}, {x -> 3}, {x -> 7}}

{1, 3, 7}


ReplaceAll (the long form of /.) does not have a Hold attribute so Through[{Re, Im}[x]] actually evaluates to {Re[x], Im[x]} before the replacements are made. (I use @` simply because I like to save keystrokes and reduce stacking of brackets.)

-