# Min and Max of a function

I need to obtain for what $$a_i$$'s the function:

$$a_1 \ln (\sqrt{2\pi e} s_1) + a_2 \ln (\sqrt{2\pi e} s_2),$$

has a maximum and minimum, under the constraint $$a_1 + a_2 = 1$$; also, $$s_1, s_2 > 0$$.

Let's first look at the maximum and minimum of the function:

Minimize[{a1 Log[Sqrt[2 Pi E] s1] + a2 Log[Sqrt[2 Pi E] s2], a1 + a2 == 1}, {a1, a2}, Reals] // FullSimplify

Maximize[{a1 Log[Sqrt[2 Pi E] s1] + a2 Log[Sqrt[2 Pi E] s2], a1 + a2 == 1}, {a1, a2}, Reals] // FullSimplify


I don't understand the results: besides the fact that, I don't know how Mathematica has calculated the conditions, but also, the results show that for the same condition the value of max and min are equal!

My second question is: how can one from the above, now infer the corresponding values of $$a_i$$'s?

• I thought the result of Solve[Thread[D[a1 Log[Sqrt[2 Pi E] s1] + (1 - a1) Log[Sqrt[2 Pi E] s2], {{s1, s2}, 1}] == 0], a1] was pretty informative... (see the fourth bullet under "Details and Options" of Solve[]'s doc page) Dec 22, 2021 at 20:04

Since a1 + a2 == 1 you will get cleaner results by using (1 - a1) in place of a2. You should also include the constraints that s1 > 0 and s2 > 0

({min, max} = (#[{a1 Log[Sqrt[2 Pi E] s1] + (1 - a1) Log[Sqrt[2 Pi E] s2],
s1 > 0, s2 > 0}, a1] // FullSimplify) & /@ {Minimize,


• For some reason, I had interpreted the $a_k$ to be parameters, while the $s_k$ were the independent variables. @Sam, can you confirm if I had interpreted wrongly? Dec 22, 2021 at 20:24

You can solve this analytically.

We may replace a2 by (1-a1) and Log[Sqrt[2 Pi E] si]] by Log[Sqrt[2 Pi E]+ Log[si]. Further we may call Log[Sqrt[2 Pi E] == c:

ex= c + a1 Log[s1] + Log[s2] - a1 Log[s2]


For an extremum the derivative relative to a1 must be zero:

Log[s1] -  Log[s2] == 0


As the Log is monotonic:

s1 == s2


Let us call this value: s. Then we have:

ex= c + Log[s]


Therefore, if s->infinity, then Max is + Infinity and the Min is -Infinity. And a1 and a2 drop out.

• Yes, if I did it right, they drop out. Dec 22, 2021 at 20:57