Message Boards Message Boards


Interpret Maximize with parameters?

Posted 10 months ago
2 Replies
3 Total Likes

I try to test Maximize[f[x],x] with some function f[x] containing parameters. I use a simple parabola f[x_]=-a (x-1)^2+b with parameters a and b. It's maximum value is b at x=1 for a>0.

f[x_] = -a (x - 1)^2 + b;
Print["f[x] = ", f[x]];
Print["1. Maximize f[x]: ", Maximize[f[x], x]];
Print["2. Maximize f[x] with a>0: ", 
  Maximize[{-a (x - 1)^2 + b, a > 0}, x]];

f[x] = b-a (-1+x)^2

1. Maximize f[x]: {\[Piecewise] b   a==0||a>0
\[Infinity] True

,{x->\[Piecewise]   1 a>0
0   a==0
Indeterminate   True


2. Maximize f[x] with a>0: {\[Piecewise]    b  a>0
-\[Infinity]    True

,{x->\[Piecewise]   1 a>0
Indeterminate   True


I can understand those results, but not the last entries which tell +/-[Infinity] for x Indeterminate. What does that mean?

At least in my second case where a is explicitly restricted to a>0 I would expect: "2. Maximize f[x] with a>0: {b, {x->1]}"

Just as in:

In[104]:= Maximize[-4711 (x - 1)^2 + b, x]

Out[104]= {b, {x -> 1}}
2 Replies


First, from the documentation for Maximize ("Details and Options"):

If the constraints cannot be satisfied, Maximize returns {-Infinity, {x->Indeterminate,...}}.

Why would -Infinity be an appropriate choice? A real-valued function cannot have -Infinity as a maximum (or least upper bound), so it would seem ridiculous. Maybe just for that reason, to indicate a problem. But actually, it follows from a certain definition: An upper bound for $f(x)$ over a domain is a number $B$ such that for all $x$ in the domain, $f(x) \le B$. If the domain is empty, then by standard logic the proposition "for all $x$ in the domain, $f(x) \le B$" is true (sometimes said to be vacuously true). If the constraint cannot be satisfied, the domain is empty; therefore any real number $B$ is an upper bound for $f(x)$ and the least upper bound in some sense is -Infinity. (It would be more proper to say the least upper bound does not exist. If we allow some latitude, -Infinity does capture the idea in a way, and it can be dealt with programmatically in an unambiguous way. To me it seems a reasonable choice for the result.)

Second, the constraint a > 0 is not treated the same as an assumption. The answer that is produced consists of two parts, one for when the constraint is satisfied (maximum b, x -> 1), and the other for when the constraint is not satisfied (in which case the answer agrees with the documentation above).

If you wish to consider only the case a > 0, then use Simplify or FullSimplify to apply the assumption:

Simplify[Maximize[{-a (x - 1)^2 + b, a > 0}, x], a > 0]
(*  {b, {x -> 1}}  *)
Posted 10 months ago

Sorry, Michael, for answering so late.

Your explanations were very helpful for me. Actually I had read the docs, but did not really understand them. And I was not really familiar with Piecewise. In particular I did not understand how the constraints in Maximize are handled. Now I got it.

BTW: Instead of your Simplify one can use Refine:

In[970]:= Simplify[Maximize[{-a (x - 1)^2 + b, a > 0}, x], a > 0]

Out[970]= {b, {x -> 1}}

In[971]:= Refine[Maximize[{-a (x - 1)^2 + b, a > 0}, x], a > 0]

Out[971]= {b, {x -> 1}}
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract