Having looked at
- Maximize Documentation
- SO: Mathematica: Commands return no output, but itself. Bug?
- Problem with Maximize
- Why won't Mathematica Solve a set of two equations for one variable?
- Inequalities with assumptions and constraints
- Application of Maximize: The cuboid constrained to the ellipsoid in $\mathbb{R}^3$
I understand that the Maximize function often needs some "help" with domain and implicit assumptions. What's really confusing me here is: In general, what is the right way to give the function the "help" it needs?
As a simple example, I'm stumped about how to explain the behavior below:
In[1]:= Maximize[{Log[x*y], x + y == 10}, {x, y}, Reals]
Out[1]= {Log[25], {x -> 5, y -> 5}}
In[2]:= Maximize[{Log[x] + Log[y], x + y == 10}, {x, y}, Reals]
Out[2]= Maximize[{Log[x] + Log[y], x + y == 10}, {x, y}, Reals]
(*OK, maybe M doesn't like the risk that x or y is nonpositive and can't simplify.*)
In[3]:= Maximize[{Log[x] + Log[y], x + y == 10 && x > 0 && y > 0}, {x, y}, Reals]
Out[3]= Maximize[{Log[x] + Log[y], x + y == 10 && x > 0 && y > 0}, {x, y}, Reals]
(*Maybe this still isn't enough information? Let me try to be doubly redundant*)
In[4]:= Assuming[{x, y} \[Element] Reals && x > 1 && y > 1,
Refine[Maximize[{Log[x] + Log[y], $Assumptions &&
{x, y} \[Element] Reals && x + y == 10 &&
x > 1 && y > 1}, {x, y}, Reals]]]
Out[4]= Maximize[{Log[x] + Log[y], x + y == 10}, {x, y}, Reals]
(*Maybe this is just too hard?*)
In[5]:= Assuming[a \[Element] Reals && a > 0,
Maximize[{Log[x] + a, x <= 10}, {x}, Reals]]
Out[5]= Maximize[{a + Log[x], x <= 10}, {x}, Reals]
In[6]:= Assuming[a \[Element] Reals && a > 0,
Maximize[{Log[x] + a, $Assumptions && x <= 10}, {x}, Reals]]
Out[6]= Maximize[{a + Log[x], a \[Element] Reals && a > 0 && x <= 10}, {x}, Reals]
(*And yet without that little a,*)
In[7]:= Maximize[{Log[x], x <= 10}, {x}, Reals]
Out[7]= {Log[10], {x -> 10}}
(*In fact according to the documentation Mathematica can
maximize algebraically in terms of parameters:*)
In[8]:= Maximize[{a*x^2 + b*x + c, x <= 10}, {x}, Reals]
Out[8]= [too long to print, a little strange,
but a reasonable characterization of the solution space]
So my observations are:
- Mathematica is capable of symbolically maximizing a function
- including transcendental functions
- including when introducing a boundary
(from other examples) and can even optimize over multiple variables in a multi-dimensional bounded space
Yet in certain circumstances where the solution should be "obvious," simply introducing a parameter breaks Mathematica's ability to solve the problem, even when handling that parameter seems to be within its ability in other contexts (namely the
Log[x]+a
example versusa*x^2+b*x+c
example)
So, I'm missing something, but I'm not sure what. My question is the general one I put in bold above; if that question is not specific enough, then a specific piece of my question is "how do I explain the behavior observed above and in particular avoid breaking Maximize
's ability to maximize when giving it expressions that seem within its ability to handle based on similar examples yet break it for reasons that I cannot understand," or even more narrowly but still relatedly, "what is the reason [that I have been unable to discern] for why Maximize
breaks under certain inputs and not others?"
My hope is that if I figure out why this doesn't work, I can generalize to figure out why the actual maximization I want to do isn't working. In particular, I have many more free parameters, and I want Mathematica to maximize a sum of functions in terms of those parameters, and I know that a solution exists provided that those parameters satisfy certain inequalities, and I want Mathematica to categorize the solutions-in-terms-of-parameters-under-what-inequality-conditions automatically. The reason I need it to do this for me even though I've done it by hand is that I want to generalize to a high-dimension case that I don't want to solve by hand, and wanted to see Mathematica reproduce my results on the low-dimension case first, but so far I've failed even to make it do that. I can explain more of the general problem if necessary, but I believe the first step is for me to understand how to use Maximize
correctly.