# Solve diophantine equation with constraints by counting and listing results [duplicate]

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

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

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:

InternalWithLocalSettings[
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

• 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 7 '17 at 2: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 7 '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 7 '17 at 12:38
{"ft_lang_label":"__label__en","ft_lang_prob":0.7191034,"math_prob":0.9713397,"size":1591,"snap":"2020-24-2020-29","text_gpt3_token_len":515,"char_repetition_ratio":0.105860114,"word_repetition_ratio":0.41843972,"special_character_ratio":0.39912006,"punctuation_ratio":0.15436241,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.97877955,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-07-03T17:43:43Z\",\"WARC-Record-ID\":\"<urn:uuid:87f5e758-503f-4e97-8dcb-b5fff12153b4>\",\"Content-Length\":\"133542\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:8a2e5714-1a7d-411d-b61f-80ce0f070d02>\",\"WARC-Concurrent-To\":\"<urn:uuid:1353ebdf-f38c-4f0e-8a36-7ba2be5b8e38>\",\"WARC-IP-Address\":\"151.101.193.69\",\"WARC-Target-URI\":\"https://mathematica.stackexchange.com/questions/157262/solve-diophantine-equation-with-constraints-by-counting-and-listing-results?noredirect=1\",\"WARC-Payload-Digest\":\"sha1:2UAWTEMIB5YPSYV273XZ2LFJ2V2LRRJX\",\"WARC-Block-Digest\":\"sha1:EXRTJFUKRE7OCDKMC3OK43PZXLOSW7U5\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-29/CC-MAIN-2020-29_segments_1593655882634.5_warc_CC-MAIN-20200703153451-20200703183451-00369.warc.gz\"}"}