I have the following differential equation $$\ddot\theta(t) = -k\sin{\omega t}\sin{\theta(t)} \quad \text{where} \quad \theta(0)=\theta_0, \dot\theta(0)=v_0$$ where $\omega$ is a known constant and $k$ is a positive parameter, the optimal value of which I am trying to find out. Here is what I mean by the optimal value of $k$: $$k_{optimal} = \arg \max_k \frac{1}{T}\int_0^T|\dot\theta(t)|dt$$ where $T > 0$ is fixed. I am not sure if it makes sense to let $T \rightarrow \infty$ (I don't know if the integral would have a limit) but if possible, this should be the way to go rather than a finite $T$.
I tried the following approach. First I fix $T$ and I use the objective function $$\frac{1}{T}\int_0^T\dot\theta(t)^2dt$$ instead of the one with the absolute value. I take the partial derivative with respect to $k$ to obtain $$\frac{\partial}{\partial k}\left(\frac{1}{T}\int_0^T\dot\theta(t)^2dt\right) = \frac{2}{T}\int_0^T\dot\theta(t)\frac{\partial \dot\theta}{\partial k}dt$$ To calculate $\frac{\partial \dot\theta}{\partial k}$ I make use of the differential equation constraint. Namely,
$$\frac{\partial }{\partial t}\left(\frac{\partial \dot\theta}{\partial k}\right) = \frac{\partial}{\partial k}\left(\frac{\partial \dot\theta}{\partial t}\right)=\frac{\partial }{\partial k}\ddot\theta$$
Even though $\frac{\partial }{\partial k}\ddot\theta$ seemed nice in the beginning, I realized I have to include the term $\frac{\partial }{\partial k}\theta$, which messes things up. This is more or less where I am stuck. Any help/pointer would be appreciated.