# Extracting list from a list of lists obtained using Solve function

After solving a set of equations I got a solution like the following using Solve[] function.

{{X0 -> 0,X1 -> 0, Xn1 -> 0, X2 -> 0,
Xn2 -> 0}, {X0 -> -0.046557 + 0.0660528 I,
X1 -> -0.00129788 - 0.104325 I, Xn1 -> -0.0370385 - 0.0938482 I,
X2 -> -0.00857655 + 0.0700392 I,
Xn2 -> 0.0466159 + 0.0600041 I}, {X0 -> 0.046557 - 0.0660528 I,
X1 -> -0.00129788 - 0.104325 I, Xn1 -> -0.0370385 - 0.0938482 I,
X2 -> 0.00857655 - 0.0700392 I,
Xn2 -> -0.0466159 - 0.0600041 I}, {X0 -> -0.094816 + 0.182855 I,
X1 -> 0, Xn1 -> 0, X2 -> 0, Xn2 -> 0}, {X0 -> 0.094816 - 0.182855 I,
X1 -> 0, Xn1 -> 0, X2 -> 0, Xn2 -> 0}, {X0 -> 0,
X1 -> 0.109897 - 0.273052 I, Xn1 -> 0.0246269 - 0.3725 I, X2 -> 0,
Xn2 -> 0}, {X0 -> 0, X1 -> 0.109897 - 0.273052 I,
Xn1 -> 0.0246269 - 0.3725 I, X2 -> 0, Xn2 -> 0}}


My intend is to extract only those solutions from the result where the condition Im(X0)!=0&&Im(X1)!=0&&Im(Xn1)!=0&&Im(X2)!=0&&Im(Xn2)!=0 is met, i.e., the second and third solutions in this case.

• I am sorry. It should be != 0. I have corrected it now. – Soumyajit Roy Jul 5 at 5:51
• The expression passed as the first argument to Solve can be a system of equations or inequalities for the variables. Include the inequalities in your Solve and the solution should satisfy the conditions. – Bob Hanlon Jul 5 at 12:59

## 1 Answer

Pick[solution,
And @@ Thread[Im[{X0, X1, Xn1, X2, Xn2}] != 0] /. solution]


{{X0 -> -0.046557 + 0.0660528 I, X1 -> -0.00129788 - 0.104325 I, Xn1 -> -0.0370385 - 0.0938482 I, X2 -> -0.00857655 + 0.0700392 I, Xn2 -> 0.0466159 + 0.0600041 I},
{X0 -> 0.046557 - 0.0660528 I, X1 -> -0.00129788 - 0.104325 I, Xn1 -> -0.0370385 - 0.0938482 I, X2 -> 0.00857655 - 0.0700392 I, Xn2 -> -0.0466159 - 0.0600041 I}}

• Initial version of my question had a mistake. The condition should be Im(X0)!=0&&Im(X1)!=0&&Im(Xn1)!=0&&Im(X2)!=0&&Im(Xn2)!=0. I have corrected it now. Thanks for the answer. – Soumyajit Roy Jul 5 at 5:58
• Thanks a lot. It has worked. – Soumyajit Roy Jul 5 at 6:16