Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168733
Image: ubuntu2004

We are exploring arc length. We want to understand what is happening. (We do NOT care whether we can integrate symbollically! Any program will integrate for us.)

YouTube Videos: Parameterization     Arc Length

Related Sage Pages: Arc Length of Parametric Curves in 2D     Arc Length of Curves in 3D

Related Wiki Pages: 

Credits: Jason Grout (3d graphs), Katie Glockner (3d sums), KCrisman (ggb embed)



Here is an interactive GeoGebra Applet to explore arc length for 2D explicit curves. Below in Sage, we can see the details of what is happening.

var ('x') #Define a 2d curve explicitly y=f(x) and an interval for x. f=cos(x) x1=0; x2=pi
#Let's plot C xmin=-3; xmax=3; ymin=-3; ymax=3 C=plot(f,(x,x1,x2),color='orange',thickness=3) show(C,aspect_ratio=1)

Look at the curve above and estimate a minimum and maximum value for its length L.


Arc Length of a Curve given explicity C=sC=s: y=f(x)y= f(x) for x[x1,x2]x \in [x1,x2]  is  L=Cds=x1x2 1+(y)2 dxL= \int_C \,ds =\int_{x1}^{x2} \, \sqrt{1 + (y')^2 } \, dx

df=diff(f,x) view(df)
\newcommand{\Bold}[1]{\mathbf{#1}}-\sin\left(x\right)
Lexact=integral(sqrt(1+df^2),(x,x1,x2)) n(Lexact)
\newcommand{\Bold}[1]{\mathbf{#1}}3.82019778903

So the arc length of this perfectly "normal" cos(x) curve using the formula (which we are calling our "exact" result even though it is being calculated numerically and CANNOT be calculated symbolically) is L=3.82L=3.82



Let us approximate this length by finding tangent line segments at regularly spaced values of x along the curve.

  • We decide how many steps.
  • The program calculates the stepsize of x.
  • We draw points on the curve regularly spaced with repect to stepsize. This is (j, y(j))
steps=4 stepsize=(x2-x1)/steps points=sum([point((j,f(x=j)), color='purple', size=30) for j in [x1..x2-stepsize,step=stepsize]]) show(C+points,aspect_ratio=1)

We draw pieces of tangent line segments starting at these points.

  • Since the segments are tangent, the slope is y(x)y'(x).
  • The segment needs to extend across the stepsize. So we simply add  (1,y(j))(1,y'(j)) \cdot stepsize to the first point.
    Sage does not allow "adding points". So we must add inside the point.
pieces=sum([line([(j,f(x=j)),(j+1*stepsize,f(x=j)+df(x=j)*stepsize)],thickness=2,color='purple') for j in [x1..x2-stepsize,step=stepsize]]) show(C+pieces+points,aspect_ratio=1)

So the approximate arc length of this "simple" curve using 4 tangent pieces is: L4=3.82L_4 =3.82.

We calculate our error.

Lapprox=sum([sqrt(1+(df(x=j))^2)*stepsize for j in [x1..x2-stepsize,step=stepsize]]) n(Lapprox)
\newcommand{\Bold}[1]{\mathbf{#1}}3.81994364317984

Our error is 0.007\approx 0.007%.



Let us try more or less step sizes - change the value of steps2 and revaluate.

error=abs((Lexact-Lapprox)/Lexact) n(error)
\newcommand{\Bold}[1]{\mathbf{#1}}0.0000665268820912695


Let us try more or less step sizes - change the value of steps2 and revaluate.

steps2=12 stepsize2=(x2-x1)/steps2 points2=sum([point((j,f(x=j)), color='purple', size=30) for j in [x1..x2-stepsize2,step=stepsize2]]) pieces2=sum([line([(j,f(x=j)),(j+1*stepsize2,f(x=j)+df(x=j)*stepsize2)],thickness=2,color='purple') for j in [x1..x2-stepsize2,step=stepsize2]]) show(C+pieces2+points2,aspect_ratio=1)

So the approximate arc length of the cos(x) curve using 12 tangent pieces is: L12=3.82L_{12} =3.82.

We calculate our new error.

Lapprox2=sum([sqrt(1+(df(x=j))^2)*stepsize2 for j in [x1..x2-stepsize2,step=stepsize2]]) n(Lapprox2)
\newcommand{\Bold}[1]{\mathbf{#1}}3.82019778899358

We check our new error. 

error2=abs((Lexact-Lapprox2)/Lexact) n(error2)
\newcommand{\Bold}[1]{\mathbf{#1}}8.93448829513871 \times 10^{-12}

Our error is now smaller than: 1.0×1011 1.0 \times 10^{-11}. 
We note that small errors are delicate things and in "real life" we must keep track of all of the possible types of errors that can occur here.