Mathematica 9 is now available
Student Support Forum
Student Support Forum: 'Minimize not working when expr value 10 or more' topicStudent Support Forum > General > "Minimize not working when expr value 10 or more"

Help | Reply To Topic
Author Comment/Response
Simon Biber
09/07/05 3:28pm

I have a specific problem I'm trying to solve. Given a particular area, find the integer side lengths of the most square-like rectangle with that area. Here, "most square" means that the difference between the two side lengths is minimised.

So, if given the area 48, the best answer is a 6 by 8 rectangle. If given the area 17, the only possible answer is a 1 by 17 rectangle.

The following function _sometimes_ works:

MSR := Function[{n},
Minimize[Abs[a - b],
a b == n
&& 0 < a <= n
&& a <= b <= n
&& Element[a, Integers]
&& Element[b, Integers], {a, b}]]

It works for cases where the difference between a and b is small (less than 10), but does not work where the difference is 10 or more.

It appears the Minimize function can't cope with situations where the closest solution that fits the constraints results in the expression to be minimized being 10 or more. That includes all prime numbers from 11 onwards, plus many other numbers including 39 (3 * 13 would be OK, but 13-3 >= 10 so it doesn't find it.), 51 (3 * 17), 57 (3 * 19), 69 (3 * 23), etc. It works fine with prime numbers less than 10.

Is this a known bug, or is it by design? Is there a workaround?

URL: ,
Help | Reply To Topic