Maximizing a function with assumptions

Maximize does not take $Assumptions into account by default, but wants the assumptions to be given explicitly:

Assuming[Abs[x]>=3,Maximize[-x^2,x]]
(*
==> {0, {x -> 0}}
*)

Maximize[{-x^2,Abs[x]>=3},x]
(*
==> {-9, {x -> -3}}
*)

However you can inject $Assumptions explicitly:

Assuming[Abs[x]>=3,Maximize[{-x^2,$Assumptions},x]]
(*
==> {-9, {x -> -3}}
*)

However for your particular example, Maximize doesn't seem to be able to find the maximum anyway.


First thing first: I don't think Minimize takes advantage of the enclosing Assuming. The only example of the two together given in the documentation involves an addition Refine step, performed on minimization results that already give some satisfaction without assumptions.

However, you can restate your problem by finding the roots of the derivative of your function, and looking at the sign of further derivatives. If a point $x$ is such that $f'(x)=0$ and $f''(x)<0$, then it is a maximum of $f$.

In your case, that doesn't help much and Mathematica cannot solve the issue either:

Assuming[s > r && r > 1 && Pmax > n0 && n0 > 0 && ρ > 1 && α > 2, Solve[f'[s] == 0, s]]

     enter image description here

You can work around that by trying to reduce the number of variables, making your function easier for both you and Mathematica to study. I chose $P=2\pi\rho P_{\text{max}} / n_0$:

g[s_] := Evaluate[Simplify[f[s] /. Pmax -> n0*P/(2*π*ρ)]]

     enter image description here

Mathematica still cannot solve that:

Assuming[s > r && r > 1 && P > 2 Pi && α > 2, Solve[g'[s] == 0, s]]
Solve::nsmet: This system cannot be solved with the methods available to Solve. >>

probably because there are two many cases involved, but with this simplified expression you can probably study a few cases (i.e. some sets of parameters) by hand to get an idea of what's happening: