1
$\begingroup$

I have the function $$f(x,\alpha) = x^\alpha - \frac{x^2}{2}$$ where $x>0$ is the main variable of interest and $\alpha \in (0,1)$ is the parameter of curvature:

f[x_,\[Alpha]_]:= x^\[Alpha] - x^2/2

I'm interested in finding $x^*$ that maximizes this function. I can do so numerically for certain values of $\alpha$:

ArgMax[f[x, 0.88], x]

which gives me $x^*=0.89...$


On a side note, to inspect the function, I can use Manipulate[] with Plot[] as follows:

Manipulate[Plot[f[x, \[Alpha]], {x, 0, 2}], {\[Alpha], 0, 1}]

but doing so with ArgMax[]:

Manipulate[
 ArgMax[{f[x, \[Alpha]], 0 < \[Alpha] < 1}, x], {\[Alpha], 0, 1}]

gives me an error ("NMaximize::ubnd: The problem is unbounded"): manipulate_argmax_error

Why is that?


Ultimately, I want to find the $x$ that maximizes this function symbolically (i.e., in terms of $\alpha$). I try the following:

ArgMax[{f[x, \[Alpha]], 0 < \[Alpha] < 1}, x]

It just prints back the input. Thus, I try to find the solution to its derivative instead:

Solve[D[f[x, \[Alpha]] == 0, x], x]

I get an error message ("Solve::ifun: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information") but I do get a solution: $\left\{\left\{x\to \alpha ^{\frac{1}{2-\alpha }}\right\}\right\}$.

Why am I getting an error message with Solve[] and why am I not getting this solution with Maximize[] or ArgMax[]?

$\endgroup$
5
  • 2
    $\begingroup$ The option SynchronousUpdating->False can solve this. The clue is that when you move the slider, the result is Indeterminate instead of numerical value. $\endgroup$
    – Lacia
    Commented Aug 1, 2023 at 10:36
  • 2
    $\begingroup$ For the warning of inverse functions. In principle, MMA tries to find all solutions symbolically, and in complicated cases this cannot be done, then it will warn the reason and leave to human whether trusting the result. You can turn off this message by looking at ref/InverseFunctions. $\endgroup$
    – Lacia
    Commented Aug 1, 2023 at 10:42
  • 2
    $\begingroup$ Solve[D[f[x, a], x] == 0, x] results in: x -> a^(1/(2 - a)) $\endgroup$ Commented Aug 1, 2023 at 12:19
  • $\begingroup$ @Daniel The OP mentioned that from the very first post. $\endgroup$
    – Michael E2
    Commented Aug 2, 2023 at 22:59
  • $\begingroup$ Yes, as I mentioned in my post I'm able to find the root of the first derivative. My question is why do I not get the same solution a^(1/(2 - a)) with maximization of the main function f[x, a] via ArgMax[] or Maximize[]? $\endgroup$ Commented Aug 3, 2023 at 10:14

1 Answer 1

1
$\begingroup$

I don't get the OP error message in V13.3.0. I get a bunch of these when $0<a<1$:

NMaximize::nrnum: The function value -0.450753-0.547213 I is not a real number at {x} = {-0.829053}.

And one of these if $a=0$ or $a=1$:

ArgMax::infeas: There are no values of {x} for which the constraints False are satisfied and the objective function 1-x^2/2 is real-valued.

Issues

  1. The constraint is 0 < \[Alpha] < 1 but the slider ranges over 0 <= \[Alpha] <= 1. You can just ignore the problems when a == 0 or a == 1, or you can fix the slider range. In fact the constraint is superfluous since alpha is numeric.

  2. ArgMax[] is an exact solver but α is an inexact (floating-point) Real. Consequently, it calls NMaximize[] to handle the inexact input. NArgMax[] is the numerical alternative. Over the years, Mathematica has developed pretty good fall-backs when the user gives the wrong input to the wrong solver. Again, one may ignore it or fix it.

  3. Another reason to ditch the constraint: Mathematica compares inexact reals with tolerance. To get far enough away from 1 so that a < 1 is false, use {\[Alpha], $MinMachineNumber, 1 - $MachineEpsilon/2} for the slider in Manipulate[].

  4. However, the problem with the numerical solver is that it has to search for candidate values of x to start whatever algorithm it selects. So why not pick some random positive and negative values to start with? Hence the slew of error messages above.

Some solutions

(* most accurate *)
Manipulate[
 (*N@*)ArgMax[
  {f[x, SetPrecision[\[Alpha], Infinity]], x > 0}, x], 
 {\[Alpha], $MinMachineNumber, 1 - $MachineEpsilon/2}]

(* not sure why 1 is excluded *)
Manipulate[
 NArgMax[{f[x, \[Alpha]], 0 < x}, x],
 {\[Alpha], $MinMachineNumber, 1}]

(* simplest adjustment *)
Manipulate[
 ArgMax[{f[x, \[Alpha]], 0 < x}, x],
 {\[Alpha], $MinMachineNumber, 1}]
$\endgroup$
1
  • $\begingroup$ Thanks. I was able to make that slider error-free with your first suggestion. However, I wonder why you use $MinMachineNumber for lower bound while $MachineEpsilon/2 for the upper bound. Don't I get the same result with for example ($MachineEpsilon, 1 - $MachineEpsilon)? $\endgroup$ Commented Aug 3, 2023 at 10:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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