While trying to find the magnetic field over a solenoid I ended up with two answers that through desmos look to be approximately the same: $$\frac{1}{α}\sum_{κ=0}^n \sin^3 (θ_2 + κdθ)$$ where $α$ the radius of the solenoid, $dθ = \frac {θ_1 - θ_2} {n}$ and, $$n(\cosθ_2 - \cosθ_1)$$
Is there a way to "pull" $dθ$ out of the function and get to the definition of the Riemann integral?
Let $$f(x)=\sin^3\big(\theta_2+x(\theta_1-\theta_2)\big).$$ Then $$\frac1n\sum_{\kappa=0}^n \sin^3(\theta_2+\kappa d\theta)=\frac1n\sum_{\kappa=0}^n f\left(\frac\kappa n\right),$$ which equals $$\int_0^1 f(x)\,dx$$ in the limit as $n\to\infty$. As a result, $$\frac1\alpha\sum_{\kappa=0}^n \sin^3(\theta_2+\kappa d\theta)\approx \frac n\alpha \int_0^1 \sin^3(\theta_2+x(\theta_1-\theta_2))\,dx.$$ You can calculate this integral as $$\int_0^1 \sin^3(\theta_2+x(\theta_1-\theta_2))\,dx=\frac{9(\cos\theta_1-\cos\theta_2)-(\cos(3\theta_1)-\cos(3\theta_2))}{12(\theta_1-\theta_2)}.$$ As far as I can tell this doesn't align exactly with what you've written, but it might be numerically close to $n(\cos\theta_2-\cos\theta_1)$ for the values of $\theta_1,\theta_2,\alpha$ you're using (or it might simplify for those values).