If you plug the desired integral into Mathematica or Wolfram Alpha, it should just spit out the relevant anti derivative expressed in terms of some standard elliptic function, which can then be calculated using some series expansion (or some library of math functions).
So, this would be a good topic for someone else to show off their math skills :)
Integrate[Sqrt[a + b u + c u^2 + d u^3], u]
Produces a huge expression which is a sum of EllipticF[ArcSin[#]] terms. I think it would be better to try and numerically compute the integral.r1,r2,r3 are roots of a+bu+cu^2+u^3,
Cleaning up the output a bit, you get
(2 (b c EllipticF[ArcSin[Sqrt[(-u+r3)/(-r2+r3)]],(r2-r3)/(r1-r3)] (u-r2) (u-r3) Sqrt[(-u+r1)/(r1-r3)]-9 a d EllipticF[ArcSin[Sqrt[(-u+r3)/(-r2+r3)]],(r2-r3)/(r1-r3)] (u-r2) (u-r3) Sqrt[(-u+r1)/(r1-r3)]+(c+3 d u) (a+u (b+u (c+d u))) Sqrt[((-u+r2) (u-r3))/(r2-r3)^2] (r2-r3)+2 c^2 (u-r2) (u-r3) Sqrt[(-u+r1)/(r1-r3)] (EllipticF[ArcSin[Sqrt[(-u+r3)/(-r2+r3)]],(r2-r3)/(r1-r3)] r1+EllipticE[ArcSin[Sqrt[(-u+r3)/(-r2+r3)]],(r2-r3)/(r1-r3)] (-r1+r3))-6 b d (u-r2) (u-r3) Sqrt[(-u+r1)/(r1-r3)] (EllipticF[ArcSin[Sqrt[(-u+r3)/(-r2+r3)]],(r2-r3)/(r1-r3)] r1+EllipticE[ArcSin[Sqrt[(-u+r3)/(-r2+r3)]],(r2-r3)/(r1-r3)] (-r1+r3))))/(15 d Sqrt[a+u (b+u (c+d u))] Sqrt[-(((u-r2) (u-r3))/(r2-r3)^2)] (r2-r3)).
But I guess if EllipticF is fast to compute, finding the roots can also be done pretty quickly, so yes its probably not that bad.
Long story short, it looks doable, but is a lot of work to get right and has almost no chance of beating out numerical integration in performance.
Raph, did you try adaptive sampling? How does the performance compare if you sample with an upper bound on change in angle, versus regular sampling?
Also curious if you wouldn’t mind expanding on use cases that need this much accuracy. The main things I’ve had to use Bezier arc length for are graphics related, e.g. hair rendering, and in that domain you don’t need much accuracy at all.
One reason to compute with excess accuracy is so that you can compute partial derivatives of arclength with respect to some parameter in the inner loop of an optimizer, to drive Newton or related solving. If the estimate has significant errors, then it can throw off the outer optimization loops. Of course, this only makes sense if it's cheap to compute the inner terms; if you have to pay dearly for accuracy, then use a more robust optimizer.