# How to Minimize a Log/Linear function symbolically?

I have my objective function as :

$\hspace{25mm} \text{Minimize} \sum_k- \alpha_k \log_2 W_k$

$\hspace{25mm} \text{subject to}: 0\leq W_k \leq q', 0 \leq \alpha_k \leq 1$

$\hspace{25mm} k =0,1,\cdots, N$

How should I solve this to get an exact/analytical solution for $W$?

I wrote the below code:

MaxValue[{-a2*Log2[w2] - a1*Log2[w1]}, {0 <= w1 <= q, 0 <= w2 <= q,
0 <= a1 <= 1, 0 <= a2 <= 1,  0 <= q <= 1 }, {w1, w2} ]


But got the prompt:

>> MaxValue::vdom: Variable domain {w1,w2} should be either Reals or Integers. "


Then I wrote as:

MaxValue[{-a2*Log2[w2] - a1*Log2[w1] }, { Element[w1, Reals],
Element[w2, Reals],   0 <= a1 <= 1, 0 <= a2 <= 1 }, {w1, w2} ]


But got the same prompt. I cant understand where the mistake is. Any hint/help is highly appreciated. thanks.

• Did you read how to specify a domain? Aug 15, 2015 at 4:54
• yap, actually I have tried that too by specifying the domain but I am not sure why I am not getting the answer. I have updated that command too. Aug 15, 2015 at 5:02
• By inspection and a moment of thought, since each term of your sum is independent and is monotonically decreasing as Wk goes to q then isn't the minimum equal to the sum of -ak Log2[q] over all k? Yes I did try to get MMA to realize this. Perhaps it is the unknown value of q that is keeping MMA from being able to see this.
– Bill
Aug 15, 2015 at 6:26
• thanks @Bill. but on the second command I actually removed 'q' just to see whether it can find a solution for the equation but that did not work either. Aug 15, 2015 at 6:29
• This instantly succeeds Maximize[{-3*Log2[w2] - 2*Log2[w1], 1/99 <= w1 <= 1 && 1/76 <= w2 <= 1}, {w1, w2}]. Replace the lower bounds on wk by zero or replace the coefficients by ak and it fails. Note: In my previous comment I had my signs backwards, the maximum will be where the wk approach the lower bounds, not the upper. Sorry.
– Bill
Aug 15, 2015 at 6:50

The calculation, as presented in the question, is ill-posed in that the maximum value is infinity for w1 or w2 equal to zero and the corresponding a not equal to zero. Bounding the ws away from zero and making a few other changes, as shown here, produces an answer.

MaxValue[{-a2*Log2[w2] - a1*Log2[w1], 0.01 <= w1 <= q, 0.01 <= w2 <= q,
0 <= a1 <= 1, 0 <= a2 <= 1, .01 <= q <= 1}, {w1, w2, a1, a2, q}]
(* 13.2877 *)


The corresponding values of the five variables are

Maximize[{-a2*Log2[w2] - a1*Log2[w1], 0.01 <= w1 <= q, 0.01 <= w2 <= q,
0 <= a1 <= 1, 0 <= a2 <= 1, .01 <= q <= 1}, {w1, w2, a1, a2, q}]
(* {13.2877, {w1 -> 0.01, w2 -> 0.01, a1 -> 1., a2 -> 1., q -> 0.308563}} *)


Note, however, that any value of q within the range .01 <= q <= 1` gives the maximum value.