# Check if an inequality holds among the solutions returned by Solve [duplicate]

Let's say I solve a system:

Solve[{a == 3* c, b == 2 *a}, {a, b}]


and then want to see if the values found for a and b satisfy an inequality:

Reduce[a < 7 b]


What I would usually do is copy and paste by hand the result of the Solve[] to make it available to Reduce:

Solve[{a == 3* c, b == 2 *a}, {a, b}]
(output) {{a -> 3 c, b -> 6 c}}

a = 3 c;
b = 6 c;
Reduce[a < 7 b]


but there must be a better way to do this? I would also like all those variables (a,b and c) to stay local because I will have to solve a lot of similar equations with the same variable names on the same notebook and I wouldn't want the values to mix.

-

## marked as duplicate by halirutan, m_goldberg, Yves Klett, Artes, Sjoerd C. de VriesJul 9 '13 at 13:49

{a, b} = {a, b} /. First@Solve[...] ? – Öskå Jul 8 '13 at 16:00
Try First@Solve[{a == 3*c, b == 2*a}, {a, b}]; Reduce[(a < 7 b) /. %] – PlatoManiac Jul 8 '13 at 16:05
@Öskå this would work but a and b are not local in this case. – Sulli Jul 8 '13 at 16:12

There is a reason why Solve returns a list of rules ;-)

sol = Solve[{a == 3*c, b == 2*a}, {a, b}]
Reduce[a < 7 b /. First[sol]]


To be a bit more verbose in my answer: a thing like a->b is called a Rule and it can be used to replace a with b in expressions. Hopefully, now it makes more sense to you why most solving or minimization routines return rules.

-
but if I try that I get as output {c \[Element] Reals && 3 c < 42 c} which is not the same as the "normal" output c > 0 – Sulli Jul 8 '13 at 16:08
@su1 I think you want Reduce[a < 7 b /. sol] – Mr.Wizard Jul 8 '13 at 16:11
@su1 I was to fast, but updated my answer. Of course you first want to replace the solution and then you want to reduce it. – halirutan Jul 8 '13 at 16:14
@su1 Additionally, note that in this case it doesn't matter whether you leave out the First as MrWizard did in his comment. In general solve returns a list of solutions, thats why you get a double nested list. – halirutan Jul 8 '13 at 16:16
@su1 you are missing a ; in that line. Try: Module[{sol}, sol = Solve[{a == 3*c, b == 2*a}, {a, b}]; Reduce[a < 7 b /. sol]] or simply: Reduce[a < 7 b /. Solve[{a == 3*c, b == 2*a}, {a, b}]] – Mr.Wizard Jul 8 '13 at 16:38