I'm using cubic Bezier curves to connect two points $p_0$ and $p_1$ with given normalized tangent vectors $v_0$ and $v_1$ (Only direction is given, not length). The length of the tangent vectors $a_0$ and $a_1$ should be adjusted in order to minimize the squared curvature along the path.
$$ B(t) = (1-t)^3p_0+3(1-t)^2t(p_0+a_0v_0)+3*(1-t)t^2(p_1+a_1v_1)+t^3p_1 \quad , t \in [0,1] $$
$$ min_{a_0,a_1} \int_0^1 \kappa(t)^2 dt \qquad ,with \quad \kappa(t) = \frac{\vert det(B'(t),B''(t))\vert}{\Vert B'(t)\Vert^3} $$
The inequality constraint for the system is that the curvature should not exceed a certain maximum $\kappa_{max}$.
$$ \kappa(t) \leq \kappa_{max} \quad \forall t \in [0,1] $$
I am able to compute this by randomly varying the parameters $a_0$ and $a_1$ but I would like to use a more sophisticated method to compute the result.
The method I was aiming for was Lagrangian multipliers or gradient descent but the limiting factor is calculating the derivative of the above functional. What methods are feasible in order to minimze the above functional?