2
$\begingroup$

Does Mathematica provide any way to compare two symbolic expressions and find which is the greatest? For example, I want to find which is the greatest of (n - 1) + 2(n - 1) Log[2, n] or n(n - 1)/2, where n is a variable.

$\endgroup$
1
  • $\begingroup$ You mean Log2 (with a capital L), right? $\endgroup$ Nov 24, 2012 at 18:11

1 Answer 1

7
$\begingroup$
Reduce[(n - 1) + 2 (n - 1) Log2[n] > n (n - 1)/2, n, Reals]

Returns that the statement is true for $$0 < n < \frac{-4}{\ln 2} \text{ProductLog}(\frac{-\ln 2}{4 \sqrt{2}})\lor 1 < n < \frac{-4}{\ln 2}\text{ProductLog}(\frac{-\ln 2}{4 \sqrt{2}})^*$$ Where $\text{ProductLog}$ is the solution to the Lambert W equation. As @Rojo notes in the comments, use N to find a numerical approximation.

General note: try using the free-form input in MMA to get a primary understanding for individual functions themselves and to learn of knew ones, such as Reduce.

$\endgroup$
2
  • 2
    $\begingroup$ Wrap it in N to get 0. < n < 0.814262 || 1. < n < 18.9881 $\endgroup$
    – Rojo
    Nov 24, 2012 at 18:25
  • $\begingroup$ A couple of pics: Plot[{(n - 1) + 2 (n - 1) Log2[n], n (n - 1)/2}, {n, -.2, 1.5}, GridLines -> {{0.814262, 1}, {}}]; Plot[{(n - 1) + 2 (n - 1) Log2[n], n (n - 1)/2}, {n, -.2, 20}, GridLines -> {{0.814262, 1, 18.9981}, {}}] $\endgroup$
    – DavidC
    Nov 25, 2012 at 1:22

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.