The code would look something like this (may have some edge cases but it's the idea):
input: base length W, required length L. output: approximate correct H such that Length(W, H) = L 1. Let lo = 0, hi = 4h + c (twice the limit form plus some constant, try various c) 2. Compute H_mid = (lo + hi) / 2 3. Compute L' = Length(W, H_mid) 4. If L' < L, let lo = H_mid and goto 2 5. If L' > L, let hi = H_mid and goto 2 6. If L' is close to L, return H_mid
Though note that if arc length doesn't strictly increase with height with constant base width as I think it does, this might not work.
If w is a constant, then:
O(0.5√16h²+w² + [w²/(8h)][ln(4h + √16h²+w²) - ln(w)]) = O(0.5√16h² + [1/(8h)][ln(4h + √16h²)]) = O(2h + ln(8h)/(8h)) = O(2h + ln(8h)/(8h))
Which tends to 2h in the limit, so the arc length does increase monotonically with h, this should work.
You can also use Newton-Raphson instead by differentiating (have you seen this method at high school?), it would converge faster but each iteration takes more work, and the differentiated expression may not be so nice to compute.