Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Consider the following Mathematica expression:

Reduce[2^j/(j + 1) <= 10, j, Integers]

which outputs:

j == 0 || j == 1 || j == 2 || j == 3 || j == 4 || 
j == 5 || j == 6 || (j \[Element] Integers && j <= -2)

Therefore, the maximum integer $j$ satisfying $\frac{2^j}{j + 1}$ is 6.

I tried to using the FindMaximum, as follows:

FindMaximum[{j, 2^j/(j + 1) <= 10 && j \[Element] Integers}, j]

but it gives the following error:

FindMaximum::eqineq: "Constraints in {j\[Element]Integers,2^j/(1+j)<=10} are 
not all equality or inequality constraints. 
With the exception of integer domain constraints for linear programming, 
domain constraints or constraints with Unequal (!=) are not supported."

My general question is:

How to solve inequalities like $\frac{2^j}{j + 1} \le c$ (for some constant $c$) in Mathematica, over Integers?

share|improve this question
add comment

2 Answers 2

up vote 8 down vote accepted

Your approach to solve for general j using Reduce is correct. However, you can also use Maximize or NMaximize as:

Maximize[{j, 2^j/(j + 1) <= 10}, j, Integers]
(* {6, {j -> 6}} *)

Or even more compactly, as JM notes:

ArgMax[{j, 2^j/(j + 1) <= 10}, j, Integers]
(* 6 *)
share|improve this answer
    
Thanks for the answer. Is there a way to put this maximum value into another variable, say $k$? –  Sadeq Dousti Aug 25 '12 at 21:20
1  
@SadeqDousti You can do k = j /. Last@Maximize[...] (fill in the rest from above) –  rm -rf Aug 25 '12 at 21:21
1  
Or alternately, k = First@Maximize[...], since the function being maximized is just j. –  rm -rf Aug 25 '12 at 21:27
3  
More compactly: ArgMax[{j, 2^j/(j + 1) <= 10}, j, Integers]. –  J. M. Aug 26 '12 at 0:47
    
@J.M.: That's really compact. Thanks! –  Sadeq Dousti Aug 26 '12 at 12:01
add comment

If you want to use the results from Reduce, you could do:

Max[j /. Solve@ Reduce[2^j/(j + 1) <= 10, j, Integers]]
share|improve this answer
    
except that it doesn't generalize to situations where the actual answer is in the j ∈ Integers && j ... case :) For example, find the minimum $j$ such that $2^j/(j+1)\geq 4$. Reduce[2^j/(j + 1) >= 4, j, Integers] will give j ∈ Integers && j >= 5 which will lead to errors with Solve. But something in the spirit of what you're doing would be: Maximize[{j, Reduce[2^j/(j + 1) <= 10, j, Integers]}, j] –  rm -rf Aug 25 '12 at 21:31
    
@R.M Well, your answer does not return Infinity for Maximize[j, 2^j/(j + 1) >= 4, j, Integers] either :) –  belisarius Aug 25 '12 at 21:38
    
Yes, but that seems more like a bug in Maximize when given a constraint. Compare: Maximize[{x, x > 2}, x, Integers] with Maximize[{x}, x, Integers]. This is a bug worth being aware though... I can think of a few instances where this would've misled me. –  rm -rf Aug 25 '12 at 21:52
1  
@R.M Let's continue this in a proper duel –  belisarius Aug 26 '12 at 7:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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