Find the maximum value of $f(\theta)=\frac{\sin(\theta-a)\sin(\theta-b)}{\sin(\theta-c)\sin(\theta-d)}$ 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.
 A: Lots of algebra, but here we go.
Let $\alpha=\cos(a+b-c-d)$, $\beta=\sqrt{1-\alpha^2}$, $\gamma=\cos(d-c)$ and $\delta=\cos(b-a)$. Using the Prosthaphaeresis formulas, the end result can be written as $$f_\max=\frac{1-\delta^2}{\alpha-\gamma\delta+\sqrt\Delta}\tag1$$ where $\Delta=\alpha^2+\gamma^2+\delta^2-2\alpha\gamma\delta+1$. To prove that $(1)$ is the maximum of $$f(\theta)=\frac{\sin(\theta-a)\sin(\theta-b)}{\sin(\theta-c)\sin(\theta-d)}=\frac{\alpha\cos(2\theta-c-d)+\beta\sin(2\theta-c-d)-\delta}{\cos(2\theta-c-d)-\gamma},\tag2$$ we set the derivative with respect to $u=\cos(2\theta-c-d)$ to zero. This gives $$\small\left(\alpha\mp\frac{\hat u}{\sqrt{1-{\hat u}^2}}\beta\right)(\hat u-\gamma)=\alpha \hat u\pm\sqrt{1-{\hat u}^2}\beta-\delta\implies(\alpha\gamma-\delta)^2(1-{\hat u}^2)=\beta^2(\gamma\hat u-1)^2\tag3$$ so $$f_\max=\frac{\delta \hat u-\alpha}{\gamma \hat u-1}:\hat u=\frac{(1-\alpha^2)\gamma\pm(\alpha\gamma-\delta)\sqrt\Delta}{\gamma^2+\delta^2-2\alpha\gamma\delta}\tag4$$ using $(3)$ twice. Direct substitution yields \begin{align}f(\theta)&\le\frac{\delta((1-\alpha^2)\gamma\pm(\alpha\gamma-\delta)\sqrt\Delta)-\alpha(\gamma^2+\delta^2-2\alpha\gamma\delta)}{\gamma((1-\alpha^2)\gamma\pm(\alpha\gamma-\delta)\sqrt\Delta)-(\gamma^2+\delta^2-2\alpha\gamma\delta)}\\&=\small\frac{(1+\alpha^2)\gamma\delta-\alpha(\gamma^2+\delta^2)\pm\delta(\alpha\gamma-\delta)\sqrt\Delta}{-(\alpha\gamma-\delta)^2\pm\gamma(\alpha\gamma-\delta)\sqrt\Delta}\frac{(1+\alpha^2)\gamma\delta-\alpha(\gamma^2+\delta^2)\mp\delta(\alpha\gamma-\delta)\sqrt\Delta}{(1+\alpha^2)\gamma\delta-\alpha(\gamma^2+\delta^2)\mp\delta(\alpha\gamma-\delta)\sqrt\Delta}\\&=\frac{(\alpha\gamma-\delta)^2(\gamma^2-2\alpha\gamma\delta+\delta^2)(1-\delta^2)}{(\alpha\gamma-\delta)^2(\gamma^2-2\alpha\gamma\delta+\delta^2)(\alpha-\gamma\delta+\sqrt\Delta)}.\end{align} As this is equivalent to $(1)$, the proof is complete.
A: By the product-to-sum formula, the expression is
$$\frac{\cos(b-a)-\cos(2\theta-a-b)}{\cos(d-c)-\cos(2\theta-c-d)},$$
which can be rewritten in the form
$$\frac{p\cos(2\theta)+q\sin(2\theta)+r}{p'\cos(2\theta)+q'\sin(2\theta)+r'}.$$
Now we cancel the numerator of the derivative,
$$(qr'-q'r)\cos(2\theta)+(rp'-r'p)\sin(2\theta)+qp'-pv=0.$$
This is a linear trigonometric equation in $2\theta$, which we solve as follows:
$$u\cos(2\theta)+v\sin(2\theta)+w=0,$$
$$u^2\cos^2(2\theta)=(v\sin(2\theta)+w)^2,$$
$$(u^2+v^2)z^2+2vwz+w^2-u^2=0$$ where $z:=\sin(2\theta).$
We solve this quadratic equation for $z$ and draw $\cos(2\theta)$ from the first equation. Finally, the value at the extrema can be computed in terms of $u,v,w$, then $p,q,r,p',q',r'$ by tedious substitution.
A: 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}}
$$
A: I am not sure of my work as I find it hard to recheck, so if there's one, please comment on my answer.


Find the maximum value of $f(\theta) = \dfrac{\sin(\theta-a)\sin(\theta-b)}{\sin(\theta-c)\sin(\theta-d)}$.

To simplify this one, you can use the product-to-sum identity:

For angles $\alpha$ and $\beta$, $\sin\alpha\sin\beta = \frac{1}{2}\left[\cos(\alpha - \beta)- \cos(\alpha+\beta)\right]$.

Then, \begin{align*}\sin(\theta-a)\sin(\theta-b)&=\frac{1}{2}\left[\cos(b- a)- \cos\Big(2\theta - (b + a)\Big)\right] \\ \sin(\theta-c)\sin(\theta-d) & =\frac{1}{2}\left[\cos(d - c)- \cos\Big(2\theta - (d + c)\Big)\right].\end{align*}
By substitution, we get that $$f(\theta) = \frac{\cos(b- a)- \cos\Big(2\theta - (b + a)\Big)}{\cos(d - c)- \cos\Big(2\theta - (d + c)\Big)}.$$
Finding the critical point of $f$ means that we need to make the equation $f'(\theta) = 0$. We can just solve for the numerator and equate it to zero.
\begin{align*}f'(\theta) &= \left[\cos(d - c)- \cos\Big(2\theta - (d + c)\Big)\right]\left[\cos(b - a)- \cos\Big(2\theta - (b + a)\Big)\right]' - \left[\cos(b - a)- \cos\Big(2\theta - (b + a)\Big)\right]\left[\cos(d - c)- \cos\Big(2\theta - (d + c)\Big)\right]' \\&\end{align*}
Assuming that $a$, $b$, $c$, and $d$ are constants, then $\cos(d - c)$ and $\cos(b - a)$ must also be constants. Proceeding,
\begin{align*}f'(\theta) &= \left[\cos(d - c)- \cos\Big(2\theta - (d + c)\Big)\right]\left[2\sin\Big(2\theta - (b + a)\Big)\right] - \left[\cos(b - a)- \cos\Big(2\theta - (b + a)\Big)\right]\left[2\sin\Big(2\theta - (d + c)\Big)\right]\end{align*}
By equating $f'(\theta)$ to zero,
\begin{align*}f'(\theta) &= 0 \\ \left[\cos(d - c)- \cos\Big(2\theta - (d + c)\Big)\right]\left[2\sin\Big(2\theta - (b + a)\Big)\right] - \left[\cos(b - a)- \cos\Big(2\theta - (b + a)\Big)\right]\left[2\sin\Big(2\theta - (d + c)\Big)\right] &= 0 \\ \left[\cos(d - c)- \cos\Big(2\theta - (d + c)\Big)\right]\left[2\sin\Big(2\theta - (b + a)\Big)\right] &= \left[\cos(b - a)- \cos\Big(2\theta - (b + a)\Big)\right]\left[2\sin\Big(2\theta - (d + c)\Big)\right]\end{align*}
Notice that $$\left[\cos(d - c)- \cos\Big(2\theta - (d + c)\Big)\right]\left[2\sin\Big(2\theta - (b + a)\Big)\right] = \left[\cos(b - a)- \cos\Big(2\theta - (b + a)\Big)\right]\left[2\sin\Big(2\theta - (d + c)\Big)\right]$$ can be modified to be $$\dfrac{\cos(b - a)- \cos\Big(2\theta - (b + a)\Big)}{\cos(d - c)- \cos\Big(2\theta - (d + c)\Big)} = \frac{\sin\Big(2\theta - (b + a)\Big)}{\sin\Big(2\theta - (d + c)\Big)}.$$
We can then simplify $f(\theta)$ as $\dfrac{\sin\Big(2\theta - (b + a)\Big)}{\sin\Big(2\theta - (d + c)\Big)}$. Can you take it from here?
