TITLE: Find the maximum value of $f(\theta)=\frac{\sin(\theta-a)\sin(\theta-b)}{\sin(\theta-c)\sin(\theta-d)}$
QUESTION [6 upvotes]: Context: I am deriving the formula for active earth pressure for an inclined soil mass behind a retaining wall. The formula is given in a textbooks (page 25 of Theoretical Foundation Engineering by Braja M. Das). I am restating the problem without any soil mechanics terminology.
Problem: Find the maximum value of the following function $-$
$
f(\theta)=\dfrac{\sin(\theta-a)\sin(\theta-b)}{\sin(\theta-c)\sin(\theta-d)}
$
Solution: Maximum value of the function, as given in the book, is $-$
$
f_{max}=\dfrac{\sin^{2}(a-b)}{\left\{\sqrt{\sin(d-b)\sin(a-c)}+\sqrt{\sin(d-a)\sin(b-c)}\right\}^{2}}
$
My attempt: I tried deriving the above maxima by the following procedure $-$
Obtain the point of maxima, $\theta_{max}$, by $\left.\dfrac{df(\theta)}{d\theta}\right|_{\theta=\theta_{max}}=0$
I get the following equation $-$
$$
\begin{aligned}
\sin(2\theta_{max}-a-b)\cos(d-c)-\sin(2\theta_{max}-c-d)\cos(a-b)=\sin(c+d-a-b)
\end{aligned}
$$
Which can also be written as $-$
$$
\sin(2\theta_{max}-a-b-c-d)\left[\cos(d+c)\cos(d-c)-\cos(a+b)\cos(a-b)\right]+\cos(2\theta_{max}-a-b-c-d)\left[\sin(d+c)\cos(d-c)-\sin(a+b)\cos(a-b)\right]=\sin(c+d-a-b)
$$
I can obtain $2\theta_{max}-a-b-c-d$ (by writing the above equation as a quadratic), but the equation becomes too complicated to simplify and put back in $f(\theta)$.
Please let me know if there is a better method or if I should go ahead with this method.
Thanks
PS: I have checked the accuracy of the solution by comparing with the optimum solution in Python. The solution is correct.

REPLY [2 votes]: After a few hours, I get the following solution. This is clearly based on the form of known solution without which I would not know how to get the roots of those big equations (posted in the question).
Here is what I got:
We can rewrite $f(\theta)$ as
$$
f(\theta) = \dfrac{\sin(\theta-a)\sin((\theta-a)+(a-b))}{\sin((\theta-a)+(a-c))\sin((\theta-a)+(a-d))}
$$
Divide the numerator and denominator with $\sin^{2}(\theta-a)$ and expand the sines $-$
$$
f(\theta)= \dfrac{\cot(a-b)+\cot(\theta-a)}{\left\{\cot(a-c)+\cot(\theta-a)\right\}\left\{\cot(a-d)+\cot(\theta-a)\right\}}\dfrac{\sin(a-b)}{\sin(a-d)\sin(a-c)}
$$
We can rewrite above as $-$
$$
\tilde{f}(t) = k\dfrac{\alpha+t}{(\beta+t)(\gamma+t)}
$$
Where,
$$
t = \cot(\theta-a)\\
\alpha = \cot(a-b) \\
\beta = \cot(a-c) \\
\gamma = \cot(a-d) \\
k = \dfrac{\sin(a-b)}{\sin(a-d)\sin(a-c)}
$$
Now, by differentiating $\tilde{f}$ with respect to $t$ and obtaining the maximum value $-$
$$
\tilde{f}_{max}=k\dfrac{\sqrt{(\beta-\alpha)(\gamma-\alpha)}}{\left\{\sqrt{(\beta-\alpha)(\gamma-\alpha)}+(\beta-\alpha)\right\}\left\{\sqrt{(\beta-\alpha)(\gamma-\alpha)}+(\gamma-\alpha)\right\}}\\
= k\dfrac{\dfrac{1}{\sqrt{(\beta-\alpha)(\gamma-\alpha)}}}{\left\{1+\sqrt{\dfrac{\beta-\alpha}{\gamma-\alpha}}\right\}\left\{1+\sqrt{\dfrac{\gamma-\alpha}{\beta-\alpha}}\right\}}
$$
Now, by putting back the values of $\alpha,\beta,\gamma$ and $k$, we get
$f_{max}$.
$$
\sqrt{(\beta-\alpha)(\gamma-\alpha)} = \dfrac{1}{\sin(a-b)}\sqrt{\dfrac{\sin(c-b)\sin(d-b)}{\sin(c-a)\sin(d-a)}}\\
\sqrt{\dfrac{\beta-\alpha}{\gamma-\alpha}} = \sqrt{\dfrac{\sin(c-b)\sin(d-a)}{\sin(c-a)\sin(d-b)}}
$$
$$
f_{max} = \tilde{f}_{max} \\
f_{max} = \dfrac{\sin^{2}(a-b)}{\left[\sqrt{\sin(c-a)\sin(d-b)}+\sqrt{\sin(c-b)\sin(d-a)}\right]^{2}}
$$