2
$\begingroup$

I just started to use Mathematica. Using the following simple command to minimize a function of variables $a,b,c,d$ with parameter $n$, it takes too much time. Do you know if there is a mistake in this command syntax?

Minimize[{((b (b - 1)/2)*(c + d) + 
 b*a*(c + d) + (d (d - 1)/2)*(a + b) + 
 c*d*(a + b))/((a + b)*(a + b - 1)*(c + d)/
   2 + (c + d)*(c + d - 1)*(a + b)/2), a + c == n && b + d == n && n >= 1000 a >= 1 && b >= 0 && c >= 1 && d >= 0}, {a, b, c, d}]
$\endgroup$
3
  • 3
    $\begingroup$ Just a little curious: is there a comma missed? n >= 1000 a >= 1 or n >= 1000, a >= 1? $\endgroup$ Sep 8, 2020 at 15:14
  • 1
    $\begingroup$ If I guess right,Minimize[{((b (b - 1)/2)*(c + d) + b*a*(c + d) + (d (d - 1)/2)*(a + b) + c*d*(a + b))/((a + b)*(a + b - 1)*(c + d)/ 2 + (c + d)*(c + d - 1)*(a + b)/2), a + c == n, b + d == n, n >= 1000 , a >= 1, b >= 0, c >= 1, d >= 0}, {a, b, c, d}] returns what you want. $\endgroup$ Sep 8, 2020 at 15:16
  • $\begingroup$ Thank you a lot @wuyudi! $\endgroup$ Sep 8, 2020 at 15:29

1 Answer 1

2
$\begingroup$
Assuming[n >= 1000, 
 Minimize[{((b (b - 1)/2)*(c + d) + 
       b*a*(c + d) + (d (d - 1)/2)*(a + b) + 
       c*d*(a + b))/((a + b)*(a + b - 1)*(c + d)/
         2 + (c + d)*(c + d - 1)*(a + b)/2), 
    a + c == n && b + d == n && n >= 1000 && a >= 1 && b >= 0 && 
     c >= 1 && d >= 0}, {a, b, c, d}] // Simplify]

(*{n/(2 (-1 + n)), {a -> 1, b -> n, c -> -1 + n, d -> 0}}*)
$\endgroup$
1
  • $\begingroup$ Thank you yarchik! $\endgroup$ Sep 8, 2020 at 17:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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