Message Boards Message Boards


Finding the maximum value on a restricted interval

Posted 2 years ago
4 Replies
1 Total Likes


I have the following function that I'm trying to maximize with respect to tau, but tau should be in a certain interval. And I know that I'm missing something, but can not find what as when I run my code I do not obtain anything. Maybe I'm using the wrong function, but even with Maxvalue I had the same issue. Any advice would be welcome,


Xavier Koch

POSTED BY: Xavier Koch
4 Replies

Beware that if you write

$Assumptions = a > 0
$Assumptions = \[Beta] > 0

the second line overrides the first one. It seems that your assumptions are not compatible with the constraint you impose on the variable \[Tau].

POSTED BY: Gianluca Gorni

Thanks for your reply, how should I write the assumptions then if this method is not efficient? Also, I don't see how the constraints could not match as they are just limiting the maximum value [Tau] can take.

POSTED BY: Xavier Koch

I've noticed that the original file is from an advanced version and not everyone can open it so here's a better version.

POSTED BY: Xavier Koch

To make more than one assumption I would use And:

$Assumptions = And[a > 0, \[Beta] > 0, d > 0, 1 > b > 0,
  c > 0, a > \[Tau]*\[Theta]A, \[Tau] > 
   0, \[Theta]A > \[Theta]B > \[Theta]C, a > \[Tau]*\[Theta]B,
  a > \[Tau]*\[Theta]C, Fb > 0, Fc > 0, 1 > \[Alpha] > 0]

Your constraint is then

myConstraint = Simplify[\[Tau] < 1/(2 (-\[Theta]A^2 + \[Theta]B^2))*
    (-2 a \[Theta]A + 2 a \[Theta]B - 
      Sqrt[((2 a \[Theta]A - 2 a \[Theta]B)^2 - 
         4 (-\[Theta]A^2 + \[Theta]B^2)*
           (-((a^2 \[Theta]A)/(\[Theta]A + \[Theta]B)) - (
            a^2 \[Beta] \[Theta]A)/(\[Theta]A + \[Theta]B) + (
            a^2 p \[Beta] \[Theta]A)/(\[Theta]A + \[Theta]B) - (
            a^2 p \[Alpha] \[Beta] \[Theta]A)/(\[Theta]A + \[Theta]B) \
+ (a^2 \[Theta]B)/(\[Theta]A + \[Theta]B) +
            (a^2 \[Beta] \[Theta]B)/(\[Theta]A + \[Theta]B) - (
            a^2 p \[Beta] \[Theta]B)/(\[Theta]A + \[Theta]B) + (
            a^2 p \[Alpha] \[Beta] \[Theta]B)/(\[Theta]A + \

I retract what I said about incompatibility: I had miswritten a symbol. Your constraint is indeed an interval, but its endpoints have different expressions, depending on the parameters:

intrvl =Reduce[myConstraint && $Assumptions, \[Tau], Reals]

To maximize a parametric expression, FindMaxValue is not suitable, because it uses numerical methods. MaxValue can handle symbolic expressions:

fnct = -((d (a - \[Theta]A \[Tau])^2)/(2 (b + c)^2)) + (
   b (1 + \[Beta]) (a - \[Theta]A \[Tau])^2)/(8 (b + c)^2) +
   ((1 + \[Beta]) (a - \[Theta]A \[Tau])^2)/(4 (b + c));
MaxValue[{fnct, intrvl}, \[Tau]]// Simplify

The interpretation of the symbolic result is tricky.

POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract