Maximize does not work

I try to maximise a following function:

 x[t_] :=
1/4 (-1 + a) + a/4 + 1/2 Sqrt[a - a^2] Cos[d] -
1/4 (1 - a) Cos[d + 2*t] + 1/4 a Cos[d - 2*t] +
1/2 Sqrt[a - a^2] Cos[2*t]


with respect to a and d. What is more, $$t \in (0,\frac{\pi}{4})$$. From NMaximize I know what the range of a and d should be (see figures, where, however, $$t \in (0,\frac{\pi}{2})$$),

but I am looking for the analytical formula.

I have written something like this

Maximize[{x[t], 0 < t < Pi/4, 4/5 < a < 1, 0 < d < Pi/2}, {a, d}]


(I have hoped that limiting the possible values of a and d will help Mathematica), but the output is the same as the input.

Does it mean that the Mathematica is not able to give the analytical form of the maximisation?

• "analytical formula" - considering the moderate complexity of your (transcendental!) function, expecting an analytic answer seems a little unreasonable. – J. M.'s technical difficulties May 16 at 13:00
• Can one say something more rather than it is unreasonable? I mean if one can exactly state, that, according to some theorems, such an analytical solution does not exist? – Agnieszka May 16 at 13:11
• If you recall that you essentially want to find the zero of a derivative, and then recall that there is usually no systematic method for finding roots of a transcendental equation... – J. M.'s technical difficulties May 16 at 13:15
• Hm, ok, this seems reasonable. Oh, damn it :(. – Agnieszka May 16 at 13:17
• Note that I didn't say there surely isn't a closed-form solution. Just that it's unlikely. – J. M.'s technical difficulties May 16 at 13:32

A non-rigorous approach.

Clear["Global*"]

x[t_] := 1/4 (-1 + a) + a/4 + 1/2 Sqrt[a - a^2] Cos[d] -
1/4 (1 - a) Cos[d + 2*t] + 1/4 a Cos[d - 2*t] + 1/2 Sqrt[a - a^2] Cos[2*t]

{max, arg} =
(NMaximize[{x[t], 0 < t < Pi/4, 4/5 < a < 1, 0 < d < Pi/2},
{a, d, t}, WorkingPrecision -> 20] // N // Chop) /.
v_?NumericQ :> RootApproximant[v]

(* {1/Sqrt[2], {a -> 1/4 (2 + Sqrt[2]), d -> 0, t -> 0}} *)


The derivatives are all identically zero at arg

Grad[x[t], {t, a, d}] /. arg // Simplify

(* {0, 0, 0} *)

nmax[t_?(0 <= # <= Pi/4 &)] := Module[
{tt = SetPrecision[t, 20]},
NMaxValue[{x[tt], 4/5 < a < 1, 0 < d < Pi/2},
{a, d}, WorkingPrecision -> 15]]

data = Table[{t, nmax[t]}, {t, 0, Pi/4, Pi/100}] // N;

ListLinePlot[data, Frame -> True, FrameLabel -> {"t", "nmax"}]


EDIT: Maximize finds the global maximum if the constraints are modified slightly.

{max, arg} =
Maximize[{x[t], 0 <= t < Pi/4, 0 < a < 1, 0 <= d < Pi/2}, {t, a, d}]

(* {1/Sqrt[2], {t -> 0, a -> 1/2 (1 + 1/Sqrt[2]), d -> 0}} *)


Setting d == 0, then the maximum for this special case as a function of t is

{maxd0, argd0} = Maximize[
{x[t] /. d -> 0 // Simplify, 0 <= t < Pi/4, 0 < a < 1}, a] //
Simplify[#, 0 <= t < Pi/4] &

(* {Cos[t]^2/Sqrt[2], {a -> 1/4 (2 + Sqrt[2])}} *)

Plot[maxd0, {t, 0, Pi/4},
PlotLabel -> StringForm["d = 0 && ", Equal @@ argd0[[1]]],
AxesLabel -> (Style[#, 12, Bold] & /@ {"t", "maxd0"})]


• Thanking for using RootApproximant, as I didn't know it yet, but these a and d do not maximise the function for all t: 0<t<Pi/4. E.g. a choice a -> 9/10, d -> 9/10*Pi/2 get greater max from ca. 0.5... – Agnieszka May 16 at 14:17
• 0.529791 < 1/Sqrt[2]` – Bob Hanlon May 16 at 14:26
• Oh, sorry, your maximisation is only for t=0, and there it is true. The problem is that I want to maximise the time function x[t] with respect to a and d, but not t. – Agnieszka May 16 at 14:40
• Hm, ok, bit this is not an analytical solution. I do not have problems to get the numerical one. – Agnieszka May 16 at 15:09