0
$\begingroup$

This question already has an answer here:

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

$\endgroup$

marked as duplicate by Carl Woll, Nasser, Michael E2, m_goldberg, Alexey Popkov Oct 8 '17 at 0:42

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ Why not use Solve instead of Reduce? $\endgroup$ – Carl Woll Oct 7 '17 at 1:30
  • $\begingroup$ I find Reduce more versatile $\endgroup$ – juan muñoz Oct 7 '17 at 1:32
  • 1
    $\begingroup$ You can use the Solve option Method->Reduce $\endgroup$ – Bob Hanlon Oct 7 '17 at 2:16
4
$\begingroup$

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

$\endgroup$
  • $\begingroup$ 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 $\endgroup$ – juan muñoz Oct 7 '17 at 2:10
  • $\begingroup$ @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}. $\endgroup$ – aardvark2012 Oct 7 '17 at 10:18
  • $\begingroup$ 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 $\endgroup$ – juan muñoz Oct 7 '17 at 12:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.