0

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

juan muñoz
  • 309
  • 1
  • 8

1 Answers1

5

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

Carl Woll
  • 130,679
  • 6
  • 243
  • 355
  • ok thank you, that simple, I did not see it before, but I just need solutions how do I do this
    1. x = 516, and = 2226
    2. x == 518, y = 2223
    3. x = 520, y = 2220
    – juan muñoz Oct 07 '17 at 02:10
  • @juanmuñoz There are no solutions for 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
  • an error in writing, I do not understand how to do what you say, then you put the code please, my knowledge is limited and I need it for something punctual – juan muñoz Oct 07 '17 at 12:38