# Loop with Reduce

The following Do-loop

Do[Print[Reduce[x^2 + 4 y*x - 2 y^3 >= 0, x]], {y, 1, 5, 1}]


will give the following output:

x <= -2 - Sqrt[6] || x >= -2 + Sqrt[6]
x < =4(-1 - Sqrt[2]) || x >= 4(-1 + Sqrt[2])
x <= 3(-2 - Sqrt[10]) || x >= 3(-2 + Sqrt[10])
x <= 8(-1 - Sqrt[3]) || x >= 8(-1 + Sqrt[3])
x <= 5(-2 - Sqrt[14]) || x >= 5(-2 + Sqrt[14])


I need to write a loop which will give in output the condition of the reduce and (the logical and &&) all the previous conditions:

x<=-2-Sqrt[6]||x>=-2+Sqrt[6]
(x<=-2-Sqrt[6]||x>=-2+Sqrt[6]) && (x<=4 (-1-Sqrt[2])||x>=4 (-1+Sqrt[2]))
((x<=-2-Sqrt[6]||x>=-2+Sqrt[6]) && (x<=4 (-1-Sqrt[2])||x>=4 (-1+Sqrt[2]))) && (x<=3 (-2-Sqrt[10])||x>=3 (-2+Sqrt[10]))
((x<=-2-Sqrt[6]||x>=-2+Sqrt[6]) && (x<=4 (-1-Sqrt[2])||x>=4 (-1+Sqrt[2]))) && (x<=3 (-2-Sqrt[10])||x>=3 (-2+Sqrt[10])) && (x<=8 (-1-Sqrt[3])||x>=8 (-1+Sqrt[3]))
((x<=-2-Sqrt[6]||x>=-2+Sqrt[6]) && (x<=4 (-1-Sqrt[2])||x>=4 (-1+Sqrt[2]))) && (x<=3 (-2-Sqrt[10])||x>=3 (-2+Sqrt[10])) && (x<=8 (-1-Sqrt[3])||x>=8 (-1+Sqrt[3])) && (x<=5 (-2-Sqrt[14])||x>=5 (-2+Sqrt[14]))


How should I write it? I'm thinking about introducing a "variable" which will memorize all the solves, but I can't implement it.

Make a list of all the terms:

all = Table[Reduce[x^2 + 4 y*x - 2 y^3 >= 0, x], {y, 1, 5, 1}]

{x <= -2 - Sqrt[6] || x >= -2 + Sqrt[6],
x <= -4 - 4 Sqrt[2] || x >= -4 + 4 Sqrt[2],
x <= -6 - 3 Sqrt[10] || x >= -6 + 3 Sqrt[10],
x <= -8 - 8 Sqrt[3] || x >= -8 + 8 Sqrt[3],
x <= -10 - 5 Sqrt[14] || x >= -10 + 5 Sqrt[14]}


If you really need them in order with all the previous ones:

Table[all[[1 ;; i]], {i, 1, 5}]


To change the List into a series of logical Ands:

And @@@ Table[all[[1 ;; i]], {i, 1, 5}]

• If the last line is what is desired, it can be obtained directly with Table[Reduce[x^2 + 4 #*x - 2 #^3 >= 0, x] & /@ Range[y], {y, 5}] – Bob Hanlon Nov 17 '16 at 3:28
• thank you, but when I said I need in output the condition of the reduce and all the previous condition, the and was the logical one && (as it is written in my example).. so I'll obtain the condition which is the logical and of all conditions. How can it be done? – user389604 Nov 17 '16 at 9:44
• this seems like a list of all conditions – user389604 Nov 17 '16 at 10:01
• As in the update, just add And@@@ to change the header of the lists into logical Ands. – bill s Nov 17 '16 at 13:26