2
$\begingroup$

Trying to maximize a two-variable expression and to get variables' values at maximum points:

ArgMax[{-2 b + 1 + 2 a (2 b - 1), 0 <= a <= 1, 0 <= b <= 1}, a]

Еxpecting the following result: $$ \begin{cases} a=0 & \mbox{if } b < \frac{1}{2} \\ a=1 & \mbox{if } b > \frac{1}{2} \\ 0 \leq a \leq 1 & \mbox{if } b = \frac{1}{2} \end{cases} $$

but get: $$ \begin{cases} \frac{1}{2} & b == \frac{1}{2} \\ 1 & \frac{1}{2} < b \leq 1 \\ Indeterminate & !(0 \leq b < \frac{1}{2} || b == \frac{1}{2} || \frac{1}{2} < b \leq 1) \\ 0 & \mbox{True} \end{cases} $$

OK, by adding Assuming and FullSimplify (or by removing 0 <= b <= 1), it's possible to convert it into more readable:

$$ \begin{cases} \frac{1}{2} & b == \frac{1}{2} \\ 1 & b > \frac{1}{2} \\ 0 & \mbox{True} \end{cases} $$

but there are still many questions:

  1. Is there any way to force Mathematica to explicitly show the last case condition instead of "True"? Even such simple result has to be examined from the very beginning to the end to understand meaning of the "True", and for more complex results it should be very error-prone.
  2. How to force Mathematica to show the correct solution for the $b==\frac{1}{2}$ case? It is "a is ANY" or $0 \leq a \leq 1$, but not just $a==\frac{1}{2}$.
  3. Why specifying additional conditions obscures result instead of simplifying it?
| improve this question | | | | |
$\endgroup$
  • $\begingroup$ It shows exactly my last result, with "True" condition, and $\frac{1}{2}$ instead of $0 \leq a \leq 1$. Am I missing something? $\endgroup$ – user4510038 Mar 10 '15 at 21:51
  • $\begingroup$ user45... sorry -- misread the question:) $\endgroup$ – kglr Mar 10 '15 at 21:57
2
$\begingroup$

You can extract the condition on $b$ in the True case as follows:

basicPiecewise = PiecewiseExpand[ArgMax[{-2 b + 1 + 2 a (2 b - 1), 0 <= a <= 1, 0 <= b <= 1}, a], Assumptions -> 0 <= b <= 1]

Then extract the explicit ("non-True") conditions:

basicPiecewise[[1, 1, All]][[All, 2]]

(* {b == 1/2, b > 1/2} *)

Then find the logical NOT of either of those conditions where $b \in \Re$ (the Reals):

Simplify@LogicalExpand@ Resolve[! Or @@ basicPiecewise[[1, 1, All]][[All, 2]], Reals]

(* 2 b < 1 *)

With some work, you can place this in the last row of your basic piecewise result, so that the value of $a$ is $0$ under the condition $2 b < 1$ (i.e., $b < 1/2$).

| improve this answer | | | | |
$\endgroup$

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.