0
$\begingroup$

I try to evaluate the Integer Maximum of a given function under constraints.

b = 31/10;l = 91/10;m = 91/10;d = 1/10;p = 2;

  B[n_, b_, l_, m_, d_, p_] := (b l (-1 + n))/(2 (1 + n)) - d n - 
  l (l/(m n p))^(1/(-1 + p)) ((1/p) - 1) 

If I compare,

N[B[15, b, l, m, d, p]]
NMaxValue[{B[n, b, l, m, d, p], n >= 1&& n \[Element] Integers}, n]

I see that NMaxValue does not return the maximum. Using MaxValue does not return a result at all.

So what is the right comman line for the maximization here?

$\endgroup$
0
$\begingroup$

Solution to the current question

Plot function B and check the the return value range of function B, narrow the question and give MaxValue decent inputs, MaxValue will have a better chance to give what you want.

In:

b = 31/10; l = 91/10; m = 91/10; d = 1/10; p = 2;
B[n_, b_, l_, m_, d_, p_] := (b l (-1 + n))/(2 (1 + n)) - d n - 
  l (l/(m n p))^(1/(-1 + p)) ((1/p) - 1)
B[15, b, l, m, d, p] // N;
Plot[B[n, b, l, m, d, p], {n, 1, 10000}]
Plot[B[n, b, l, m, d, p], {n, 1, 1000}](* n between 1 and 150 *)
MaxValue[{B[n, b, l, m, d, p], 
  150 >= n >= 1 && n \[Element] Integers}, n]

Out: enter image description here

Solution to the previous question

The question is updated. The code below has nothing to do with the latest question. I haven't deleted it because I thought the other people might has the similar issues.

In:

Clear[R, F, HR, n]
b = 48/10;
l = 19/10;
m = 99/10;
d = 5/10;
p = 12/10;

R[n_, b_, l_, m_, d_, p_] := 
  1/2 l (b - (4 b)/(1 + n) + 2 (l/(m n p))^(1/(-1 + p)));
F[l_, m_, n_, b_, d_, p_] := -d + (b l)/(n + n^2) - 
   m ((l/(m n p))^(p/(-1 + p)));
HR[n_, b_, l_, m_, d_, p_] := 
  l/(m p (p - 1)) (n m p/l)^((p - 2)/(p - 1));

Maximize[{ R[n, b, l, m, d, p], b > HR[n, b, l, m, d, p] , 
  F[l, m, n, b, d, p] > 0  , n >= 1 }, n \[Element] Integers]
Maximize[{R[n, b, l, m, d, p], b > HR[n, b, l, m, d, p], 
  F[l, m, n, b, d, p] > 0, n > 1}, n \[Element] Integers]

Out:

{29403675625/35939207332188864, {n -> 3}}
{29403675625/35939207332188864, {n -> 3}}
| improve this answer | |
$\endgroup$
  • $\begingroup$ This was a huge tip, thank you. Do you see why that follow problem is not solved? $\endgroup$ – user34047 May 2 '17 at 8:20

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.