I am trying to do symbolic maximization of a function, and would like to specify the range of a parameter of that function.

I am able to set constraints of the variable I am maximizing over, but am not sure how to set constraints/range for a variable I am not maximizing over.

Here I would like to specify that a is always positive. How can I do that? And can this be done globally?

Maximize[{x^0.5 - a*x, x > 0}, x]



A slightly more complicated example, where I am stuck: if I want to specify the exponent symbolically, and want to put a constraint on it (say $0<b<1$?)

Maximize[{x^b - a*x, x > 0}, x]

1 Answer 1


By putting x^0.5 in your code, Mathematica assumes that you want to use machine arithmetic, and so will not return a result (since a doesn't have a definite numerical value.) If you use x^(1/2) or Sqrt[x] instead, Mathematica will try to solve the problem symbolically instead of numerically, and actually return a symbolic result. This result can then be simplified using Simplify and the appropriate Assumptions:

Maximize[{x^(1/2) - a*x, {x > 0}}, x];
Simplify[%, Assumptions -> a > 0]

(* {1/(4 a), {x -> 1/(4 a^2)}} *)
  • $\begingroup$ Simplify[%, a > 0] also works. $\endgroup$ Commented Apr 4, 2016 at 16:39
  • $\begingroup$ great, thanks @MichaelSeifert!! I tried to use your method for a slightly more complicated case, but was quickly stuck. I edited the question, hope you would kindly accept tp extend your answer to that case? Or should I start a new question? Thanks so much! $\endgroup$
    – Matifou
    Commented Apr 5, 2016 at 5:21

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.