Skip to content
DeepForgeby svx
All problems
MediumCalculusca-039

Arc Length Numeric

Problem

Approximate the arc length of y = f(x) over [a, b] with n straight segments, where f(x) = sum(coeffs[i] * x^i).

Sample n + 1 equally spaced points and sum sqrt(dx^2 + dy^2) over consecutive pairs. Return 0.0 when n <= 0.

Hint

A piecewise-linear approximation converges to the true arc length as n grows.

Test cases

case 1
in: [[3],0,4,8]
expected: 4
case 2
in: [[0,2],0,3,3]
expected: 6.708203932499369
case 3
in: [[0,0,1],0,2,4]
expected: 4.6267234873447
case 4
in: [[0,0,1],0,1,1]
expected: 1.4142135623730951
Starter codePython
def arc_length(coeffs, a, b, n):
    # Your code here
    pass

4 test cases · run your code against them in the editor