# Combining solutions while solving

Here is a simple representation of my problem.

I want to solve

Solve[(w^2*c^2 /. #) - 1 == 0, w]& /@ {{c -> 1}, {c -> 2}}

{{{w -> -1}, {w -> 1}}, {{w -> -(1/2)}, {w -> 1/2}}}


The thing is, I want to combine this with value of c like this

{{c->1, w->-1}, {c->1,w->1}, {c->2,w->-1/2}, {c->2,w->1/2}}


I used

Outer[Union, #, Solve[(w^2*c^2 /. #) - 1 == 0, w]] & /@ {{c -> 1}, {c -> 2}}


for this but it gives

Rule::argrx: Rule called with 4 arguments; 2 arguments are expected. >>.

What am I doing wrong? Is there a better way to do this ?

Note:The example which I gave is simple but my problem is generic. So instead of w^2*c^2 == 0 there can be any equation which can give any number of solutions.

I like this short one:

Solve[w^2 c^2 - 1 == 0 && (c == 1 || c == 2), {w, c}]
(*{{w -> -1, c -> 1}, {w -> 1, c -> 1}, {w -> -(1/2), c -> 2}, {w -> 1/2, c -> 2}}*)


It can be generalized as:

cvalues = {1, 2, 5, 6};
Solve[w^2 c^2 - 1 == 0 && Or @@ Thread[c == cvalues], {w, c}]

ArrayReshape[Tuples /@ ({#, Solve[(w^2*c^2 /. #)-1 == 0, w]} & /@ {{c -> 1}, {c -> 2}}), {4, 2}]


or

Partition[Flatten[Tuples /@ ({#,Solve[(w^2*c^2 /. #)-1 == 0, w]} & /@ {{c -> 1}, {c -> 2}})], 2]


both give

(* {{c -> 1, w -> -1}, {c -> 1, w -> 1}, {c -> 2, w -> -(1/2)}, {c -> 2, w -> 1/2}} *)

cc = {c -> 1, c -> 2};

sol = Solve[(w^2*c^2 /. #) - 1 == 0, w] & /@ cc;

Partition[Riffle[Riffle[cc, cc], Flatten @ sol], 2] cc = {c -> 1, c -> 2, c -> 3};

sol = Solve[(w^2*c^2 /. #) - 1 == 0, w] & /@ cc;

Partition[Riffle[Riffle[cc, cc], Flatten @ sol], 2] • riffle = {c -> 1, c -> 2}; ....; Partition[ Riffle[Riffle[riffle, riffle], Flatten@sol], 2] – Dr. belisarius Sep 22 '14 at 16:23
• @belisarius lol – eldo Sep 22 '14 at 16:24
sol = Flatten[Solve[{w^2*c^2 - 1 == 0, c == #}, {c, w}] & /@ {1, 2}, 1]


{{c -> 1, w -> -1}, {c -> 1, w -> 1}, {c -> 2, w -> -(1/2)}, {c -> 2, w -> 1/2}}

sol == Flatten[
Solve[{w^2*c^2 - 1 == 0, c == #}, {c,
w}] & /@ (c /. {{c -> 1}, {c -> 2}}), 1]


True