I am struggling with using a While loop inside a Do loop and using the break to break the loop. In this code, I would like to use the While loop for the value of i and the Do loop for the value of h, I am defining what f is, and I am trying to change the value for i start with h=5 with the While loop, if the value of i gives out false for f, then I would like the loop to move on to evaluate f for the next values of h.
First I tried to define my inequality with specific h value (h=5);
f = Reduce[FunctionExpand[Binomial[n - 1, 5 - 1] + 2 - 2*\!\( \*UnderoverscriptBox[\(\[Sum]\), \(l = 0\), \(5 - 2\)]\(Binomial[ n - m, l]*Binomial[m - 1, 5 - l - 1]\)\)] <= 0 && m >= 5 + 1 && n >= (i/10)*5*m, {m, n}, Reals]
Then, I used Do loop to determine which value of i does not have solution. This is good, however, I would like to use the While loop instead of Do loop, I tried but it did not work. I am very new with loop in mathematica.
Do[Print[f], {i, 12, 14}]
With this, the output tells me that there is a solution when i=12, and false for 13 and 14. What I want is the first i value that gives me false. Now, Instead of me giving the range, I would like to make the loop start with certain value of i and stop when it first become false. After this, I would like to make the f more general by defining it as ;
f = Reduce[FunctionExpand[Binomial[n - 1, h- 1] + 2 - 2*\!\( \*UnderoverscriptBox[\(\[Sum]\), \(l = 0\), \(h - 2\)]\(Binomial[ n - m, l]*Binomial[m - 1, h - l - 1]\)\)] <= 0 && m >= h + 1 && n >= (i/10)*h*m, {m, n}, Reals]
And, use first loop to find the value for i, and then after it first gives false, then break and move to the next loop to evaluate the value of i for the next value of h.
This is what I tried;
Do[i = 12; While[f == true; If[false, Break[]]]; i++,{h,5,7}]
But the mathematica do not evaluate it.
I am sorry for the long explanation. However, I would really appreciate it if someone could give me any direction with the while loop and the break. Thank you so much.
Edit: I found the loop that I needed.Thank you.
true
andfalse
? And exactly what is the value off
when you try that last line of code? $\endgroup$Reduce::nsmet: This system cannot be solved with the methods available to Reduce.
$\endgroup$Reduce::fexp: Warning: Reduce used FunctionExpand to transform the system. Since FunctionExpand transformation rules are only generically correct, the solution set might have been altered.
andGeneral::stop: Further output of Reduce::fexp will be suppressed during this calculation.
$\endgroup$Do[i=12; Print["i is ",i]; i++,{h,5,7}]
andi=12;Do[Print["i is ",i]; i++,{h,5,7}]
$\endgroup$