# Check sign of second order condition for different values of parameters

I am facing a maximisation problem, and I need to check the concavity of my objective function. (Actually, quasi-concavity would be sufficient, but I have no idea how to check it). In poor words, I have to maximise f(x) wrt x. This is what I have so far:

function = (k*f)*f + 3 f + (1 - f) k (1 + f) t
first = D[function, f]
second = Simplify[ D[first, f]]


Thus, the second order condition is -2 k (-1 + t), where k and t are parameters which can vary in the range [0,1]. I want to determine under which conditions on the parameters the objective function is concave (or quasi-concave). How can I do it?

function = (k*f)*f + 3 f + (1 - f) k (1 + f) t //
Simplify;


To find the function's maximum use Maximize

Maximize[function, f]


For the function to be bounded requires that (t > 1 && k > 0) || (t < 1 && k < 0)

{max, arg} = Assuming[(t > 1 && k > 0) || (t < 1 && k < 0),
Maximize[function, f] // Simplify]

(* {9/(4 k (-1 + t)) + k t, {f -> 3/(2 k (-1 + t))}} *)

max == function /. arg // Simplify

(* True *)


EDIT Graphically,

Manipulate[
Module[{
cond = (tt > 1 && kk > 0) || (tt < 1 && kk < 0),
maxPt = If[tt == 1 || kk == 0, {},
{3/(2*kk*(-1 + tt)), 9/(4*kk*(-1 + tt)) + kk*tt}]},
Plot[function /. {k -> kk, t -> tt}, {f, -5, 5},
PlotStyle -> If[cond,
Blue, Directive[Red, Dashed]],
Epilog -> {If[cond,
{Text[Style["max", Red, Bold], maxPt, {0, 2}],
Red, AbsolutePointSize[4], Point[maxPt]},
Nothing]}]],
{{kk, -2, k}, -3, 5, .1, Appearance -> "Labeled"},
{{tt, 0, t}, -5, 5, .1, Appearance -> "Labeled"}]


• Thank for the answer. So, following your code, a maximum is attained when (t > 1 && k > 0) || (t < 1 && k < 0), right? Does it imply that my function is concave only if those conditions are true? Apr 27, 2020 at 20:39
• Play with Manipulate. Apr 27, 2020 at 21:29
• Sorry, I tried to understand your code, but I did not get it. The fact is that the function I ma working with is different from the one I posted (that is just an example), so now I cannot understand the code relative to the plot. Apr 28, 2020 at 14:30
• Maximize calculates max value of function and value of f at which the max is obtained, each as function of k and t. These values are used to draw & label max on plot of function for selected values of k and t. The control variables kk and tt correspond to k and t. k and t cannot be used directly in the Manipulate since scoping localizes the control variables and they would not be the same as the global variables. Alternatively, define function with explicit arguments: function[k_, t_, f_] = ... so that the control variables can be passed to function. Apr 28, 2020 at 14:57

want to determine under which conditions on the parameters the objective function is concave (or quasi-concave)

If I understand you right, you could try

function = (k*f)*f + 3 f + (1 - f) k (1 + f) t;

• @BobHanlon I just read that OP wanted to check concavity. I thought they meant concave up (convex). overlooked later they said down. So you are right, it needs to be <0 instead. Will fix now. Thanks. Apr 27, 2020 at 20:35
• @PlasticMan hi. When you say concave do you mean down or up? concave down means it is max. concave up mean is it min. second derivative is positive means it is min. second derivative is negative means it is max. So conditions for max is as shown above, yes. second derivative is 2 k (1 - t). For this to be negative, we see the answer is correct as given by Mathematica. so if your t,k meet any ONE of these two conditions, then it is max. Apr 27, 2020 at 20:47