# Maximizing a function with assumptions

Using

f[s_] := Log[(s/r)^α ((α - 2) n0 r^α  + 2 π Pmax ρ r^2)
/((α - 2) n0 s^α + 2 π Pmax ρ s^2)]/s


When I run the following line:

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


I get the following output:

Maximize[Log[((s/r)^α (n0 r^α (-2 + α) + 2 π Pmax r^2 ρ))
/(n0 s^α (-2 + α) + 2 π Pmax s^2 ρ)]/s, s]


Actually, Mathematica ignores the assumptions and outputs the function only. That is, nothing is done by Mathematica. I know that Assuming[.] works with Refine, Simplify, and Integrate. But, is there any way to use Maximize with assumptions? What do you think about the given function? Is it analytically solvable at all?

EDIT: Let g[x]=n0 β + 2 π ρ Pmax x^(-β), where β = α - 2. We can rewrite f[s] as:

f[s_] := Log[g[r]/g[s]]/s


for β>0. Therefore, the optimal point is found by maximizing Log[(g[r]/g[s])^(1/s)] or equivalently maximizing (g[r]/g[s])^(1/s). Mathematica cannot solve the latter optimization problem as well. Even with some more simplification, r=1 and n0=1, which results in the following problem, it cannot be solved:

Maximize[{((β + 2 π Pmax ρ)/(β + 2 π Pmax s^-β ρ))^(1/s), β > 0, Pmax > 1, ρ > 1}, s]

-
Solve[f'[s] == 0, s] says it cannot solve the system. –  FJRA Apr 17 '12 at 1:27

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 && \[Rho] > 1 && \[Alpha] > 2, Solve[f'[s] == 0, s]]  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*\[Pi]*\[Rho])]]


Mathematica still cannot solve that:

Assuming[s > r && r > 1 && P > 2 Pi && \[Alpha] > 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:

-