Maximizing a trigonometric function

This is probably a naive question, but here it goes:

I know that $$r\cos a+s\cos b+t\cos c \leq \frac{rs}{2t}+\frac{rt}{2s}+\frac{ts}{2r},$$

subject to the conditions $a+b+c=\pi$ and $r,s,t$ are positive reals.

My question is whether I can ask Mathematica to find the RHS in the above inequality.

I tried:

Maximize[{r*Cos[a] + s*Cos[b] + t*Cos[c], c = Pi - a - b, r > 0, s > 0, t > 0}, {a, b}]

• Please write down the Mathematica code you tried. Thanks! Oct 14 '14 at 13:51
• Maximize[{rcos[a] + scos[b] + t*cos[c], c = pi - a - b, r > 0, s > 0, t > 0}, {a, b}] Oct 14 '14 at 13:56
• You got syntax issues - take care of upper/lowercase spelling, and = is not equivalent to ==. Oct 14 '14 at 14:31
• Maximize[{rCos[a] + sCos[b] + t*Cos[Pi - a - b], r > 0, s > 0, t > 0}, {a, b}] ? Oct 14 '14 at 14:50
• Yes, that's now capitalized correctly. Oct 14 '14 at 14:55

Here is a way of obtaining the result that you want.

Define the expression to be maximised, using a + b + c == Pi to eliminate c.

expr = r Cos[a] + s Cos[b] + t Cos[Pi - a - b];


Solve for the stationary points w.r.t. a and b.

sol = Solve[D[expr, a] == 0 && D[expr, b] == 0, {a, b}]

(* Lots of ConditionalExpression due to the periodicity of the expression being maximised *)


Substitute the solutions back into the expression. Then post-process the result in several stages: (1) FullSimplify using that {r, s, t} > 0, (2) Refine to remove the degeneracy due to periodicity, and (3) Expand to write the results nicely.

expr0 = expr /. sol //
FullSimplify[#, {r, s, t} > 0] & //
Refine[#, C[1] \[Element] Integers && C[2] \[Element] Integers] & //
Expand

(*
{
r + s - t,
r - s + t,
-r + s + t,
-r - s - t,
(r s)/(2 t) + (r t)/(2 s) + (s t)/(2 r),
(r s)/(2 t) + (r t)/(2 s) + (s t)/(2 r)
}
*)


Check all of these stationary values against the conjectured upper bound.

ForAll[{r, s, t}, {r, s, t} > 0,
expr0 <= (r s)/(2 t) + (r t)/(2 s) + (s t)/(2 r)] // Resolve

(* True *)

• Great answer! Thanks a lot. Oct 15 '14 at 9:57

If you want get the same symbolic result, i'm afraid mathematica cant handle that. But still a few comments. The first is of course syntax problems (see example below). You can always consider numerical task: say, you want to maximize left side with known right side, i.e. known r,s,t. Another point - Maximize cant manage all the tasks for sure, consider using NMaximize. I would suggest:

r = 1;
t = 2;
s = 3;
NMaximize[{r Cos[a] + s Cos[b] + t Cos[c], a + b + c == Pi}, {a, b, c}]

• Ok, thanks. I am not interested in numerical solutions though; rather, I was hoping for an "inequality proving" routine within Mathematica. Oct 14 '14 at 15:05