rudransh verma said:
By the way why are we differentiating and why have we equated it to zero?
Recall our goal. We are trying to find the maximum range ##R## for a projectile launched at a known velocity ##v_0## at an unknown angle ##\theta## when the landing position is at the same elevation as the launching position. We are free to pick ##\theta## in order to maximize ##R##.
We have come up with a formula that gives the achieved range, call it ##R(\theta)## for any given angle. That formula is:$$R(\theta)=\frac{{v_0}^2 \sin 2\theta}{g}$$This formula has been given many times already in this thread.
When one has an arbitrary function ##f(x)## defined for ##x## in some interval, there only a few places where a maximum or a minimum can be.
The maximum can be at one of the end points of the interval. For example, the function ##f(x)=x## on the closed interval [0,1] has its maximum at the right hand end point and its minimum at the left hand end point.
The maximum can be at a place where the function is discontinuous or where it is not differentiable. For example, the function ##f(x) = |x|## on the closed interval [-1,1] has its minimum at the bottom of the V that the graph traces out. The first derivative there is undefined.
The maximum can be at a place where the first derivative of the function is zero. For instance, the function ##f(x)=\sqrt{1-x^2}## on the closed interval [-1,1] has its maximum at the peak of its circular arc where the first derivative is zero.
One crank-and-grind approach to optimization problems is, accordingly, to solve for places where the first derivative is zero. The maximum may be at such a place.
As
@haruspex points out, once one has a function of the form $$\text{some positive constant} \times \sin 2\theta$$there is no need to go the trouble of differentiating. It is clear by inspection where the maximum is to be found. [Still, nothing stops you from differentiating and solving ##\text{some positive constant} \times \cos 2\theta = 0## for ##2\theta##. Easily enough done. This yields the correct result, as it must]
If no such obvious solution is to be found and if one is being careful [as one should be], one should check at the endpoints of the interval (e.g. at ##\theta = 0 \text{ degrees}## and ##\theta = 90 \text{ degrees}##), at any possible points of discontinuity and at any points where the first derivative is zero or undefined to see at which point(s) the maximum (or minimum) is actually achieved.