Lesson 1 of 18
Arc Length
Arc Length
The length of a curve from to :
Why It Works
At each , the curve moves right by and up by . By the Pythagorean theorem, the infinitesimal piece has length .
Examples
Straight line on : , so
- on :
- on :
Numerical Approach
Use the midpoint rule with a central difference derivative:
double dx = (b - a) / n;
for each midpoint x:
double deriv = (f(x+h) - f(x-h)) / (2*h);
sum += my_sqrt(1.0 + deriv * deriv);
return sum * dx;
Your Task
Implement double arc_length(double (*f)(double), double a, double b, int n, double h).
Use the midpoint rule with step and central difference with step for the derivative. A Newton's-method sqrt helper is provided.
TCC compiler loading...
Loading...
Click "Run" to execute your code.