# Finding the maximum value from the roots of a solution when there is an ambiguity

I have a variable

x = l*Cos[t]*Cos[a] - Sin[t]*Sin[a]


and I want to find the maximum value of x with respect to a, as well as access the roots. I have tried MaxValue[x, a] but but just get

MaxValue[l Cos[a] Cos[t]-Sin[a] Sin[t],a]


So I did b = D[x, a] and was returned

-l Cos[t] Sin[a]-Cos[a] Sin[t]


I then did sx=Solve[b ==0, a] and was returned

so what I would like to do next is something like

mx =x/. a-> sx[[1]]


but I am not sure how to how to handle the 2 PI ambiguity in the roots. Note that I want to extract the ambiguous roots even if it is possible to make MaxValue work. I just want the roots with c_1 = 0.

• it shows that C1 is complex, what about domain of other values !? any extra info!? May 31 '21 at 2:14
• c_1 is in Z, and in this case, Z is just the integers, i.e. not complex May 31 '21 at 9:41

Try Weierstrass-Subsitution: a->2 ArcTan[u] && u->Tan[a/2] which restricts a to the range -Pi<a<Pi and transforms the equation to a rational form.

x = l*Cos[t]*Cos[a] - Sin[t]*Sin[a]
xu = x /. a -> 2 ArcTan[u] // TrigExpand
(*(l Cos[t])/(1 + u^2) - (l u^2 Cos[t])/(1 + u^2) - (2 u Sin[t])/(1 + u^2)*)


Now MaxValue evaluates maximum of x

max=MaxValue[xu, u] /. u -> Tan[a/2]
(*-Sqrt[l^2 Cos[t]^2 + Sin[t]^2]*)


ArgMax evaluates for which argument u the maximum is found

maxu = ArgMax[xu, u]
(*-(Sin[t]/(l Cos[t] + Sqrt[l^2 Cos[t]^2 + Sin[t]^2])) ...*)



All valid solutions a follow to a==2 ArcTan[maxu]+2 Pi Integer

• I like this, it is elegant. However, as mentioned in the question, I also want to know the value of the roots, i.e of a. How do I do this? May 31 '21 at 9:42
• Now my answer includes the value of the roots... May 31 '21 at 10:15
• Thank you, I have upvoted and accepted your answer. If you think the question may be of use to others, then please upvote it. I suggest we delete our comments as all the information needed is now in the answer. May 31 '21 at 21:59