0
$\begingroup$

I want to find the minimum m which satisfies conditions as below:

Minimize[{m, m > 0 && Mod[m 3.1, 0.5] == 0}, m, Integers]
(* {1., {m -> 1}} *)

Obviously, the answer is m=5, however, Mathematica11.1 does not find the answer. How can I instruct MM to find the correct answer?

$\endgroup$
1
  • $\begingroup$ Mathematica v12.2. gives an error message NMinimize::nosat: Obtained solution does not satisfy the following constraints within Tolerance -> 0.001: {-Mod[3.1 m,0.5]==0}.` $\endgroup$ – Ulrich Neumann Jun 10 at 6:20
3
$\begingroup$
Minimize[{m, m > 0 && 31/10 m == 1/2 k && k ∈ Integers}, {m, k}, Integers]

{5, {m -> 5, k -> 31}}

Thanks @BobHanlon

Minimize[{m, m > 0 && 3.1 m == .5 k // Rationalize} , {m,    k}, Integers]
$\endgroup$
3
  • $\begingroup$ +1 Note that k \[Element] Integers is redundant $\endgroup$ – Bob Hanlon Jun 9 at 2:04
  • $\begingroup$ @BobHanlon Thanks! I forgot that the last ` Integers` restrict {m,k} to Integers $\endgroup$ – cvgmt Jun 9 at 2:09
  • $\begingroup$ I understand the solution. Why does the Mod or the Minimize not work for decimal representations? $\endgroup$ – Taiki Bessho Jun 9 at 2:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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