Mr F says: The red stuff in this line is unnecessary (since you don't use it in your solution) and in fact unhelpful and potentially confusing to the OP.
Differentiate!
Maximum occurs when
(Remember that ) Mr F says: Alternatively and more efficiently, remember the Pythagorean Identity . I'll pick up from here in my main reply below.
Remember that
Mr F says: This line does not lead anywhere helpful and may well reinforce a common misconception regarding the null factor law and its misuse.
Take it from here?