I need this code to list me and say the total solutions found
Reduce[3 x + 2 y == 8800 && 1800 <= x <= 3200 &&
1000 <= y <= 1500 , {x, y}, Integers] /. Or -> List /. And -> List
this is an example, there are many more Thank you
I need this code to list me and say the total solutions found
Reduce[3 x + 2 y == 8800 && 1800 <= x <= 3200 &&
1000 <= y <= 1500 , {x, y}, Integers] /. Or -> List /. And -> List
this is an example, there are many more Thank you
Using Solve produces the desired results directly:
Solve[
3 x + 2 y == 8800 && 1800<=x<=3200 && 1000<=y<=1500,
{x,y},
Integers
] //Length
167
However, the OP would prefer to use Reduce. To have Reduce produce similar output, one needs to change SystemOptions. Here is some code to do so:
Internal`WithLocalSettings[
old = OptionValue[SystemOptions[], "ReduceOptions"->"DiscreteSolutionBound"];
SetSystemOptions["ReduceOptions" -> "DiscreteSolutionBound" -> 1000],
Reduce[
3 x + 2 y == 8800 && 1800<=x<=3200 && 1000<=y<=1500,
{x,y},
Integers
] //Length,
SetSystemOptions["ReduceOptions" -> "DiscreteSolutionBound" -> old]
]
167
x = 516, 518, 520. Define sol = Solve[...] (from answer), then the solution with the lowest x-value is MinimalBy[sol, #[[1, 2]] &], which is {x -> 1934, y -> 1499}.
– aardvark2012
Oct 07 '17 at 10:18
Solveinstead ofReduce? – Carl Woll Oct 07 '17 at 01:30SolveoptionMethod->Reduce– Bob Hanlon Oct 07 '17 at 02:16