Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

All published worksheets from http://sagenb.org

189900 views
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 Explicit Curves in 2D     Arc Length of Curves in 3D

Related Wiki Pages: 

var ('t') #Define a 2d curve s parametrically and an interval for t s=vector((4*cos(t),3*t)) t1=0; t2=pi
#Let's plot C xmin=-3; xmax=3; ymin=-3; ymax=3 C=parametric_plot(s,(t,t1,t2),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 parametrically C=sC=s: <x(t),y(t)>\lt x(t),\, y(t) \gt for t[t1,t2]t \in [t1,t2]  is  L=Cds=t1t2 x˙2+y˙2 dtL= \int_C \,ds =\int_{t1}^{t2} \, \sqrt{{\dot{x}}^2 + {\dot{y}}^2 } \, dt

ds=diff(s,t) view(ds)
\newcommand{\Bold}[1]{\mathbf{#1}}\left(-4 \, \sin\left(t\right),\,3\right)
Lexact=integral(norm(ds),(t,t1,t2)) n(Lexact)
\newcommand{\Bold}[1]{\mathbf{#1}}12.7634994317

So the arc length of this weirdo curve using the formula (which we are calling our "exact" result even though it is being calculated numerically) is L=12.76L=12.76



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

This algorithm is exactly the same as for parametric curves in 3d!

  • We decide how many steps.
  • The program calculates the stepsize of t.
  • We draw points on the curve regularly spaced with repect to stepsize. They are the points: (s(j))
steps=4 stepsize=(t2-t1)/steps points=sum([point(s(t=j), color='purple', size=30) for j in [t1..t2-stepsize,step=stepsize]]) show(C+points,aspect_ratio=1)

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

  • Start point is s(j)
  • Slope is value of the derivative vector ds(j). 
  • Length is ds \left\| {ds} \right\| \cdot stepsize = x˙2+y˙2+z˙2\sqrt{{\dot{x}}^2 + {\dot{y}}^2 + {\dot{z}}^2} \cdot stepsize.

So parametrically these line segments are: s(j)+λ·ds(j) for λ=[0, stepsize].

pieces=sum([line([(s(t=j)),(s(t=j)+ds(t=j)*stepsize)],thickness=2,color='purple') for j in [t1..t2-stepsize,step=stepsize]]) show(C+pieces+points,aspect_ratio=1)

We sum the length of these pieces. They are each of length:   ds \left\| {ds} \right\| \cdot stepsize = x˙2+y˙2 \sqrt{{\dot{x}}^2 + {\dot{y}}^2}  \cdot stepsize, where the derivative is evaluated at the starting points of the pieces.

Lapprox=sum([norm(ds(t=j))*stepsize for j in [t1..t2-stepsize,step=stepsize]]) n(Lapprox)
\newcommand{\Bold}[1]{\mathbf{#1}}12.7597444788872

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

We calculate our error.

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

Our error is 0.03\approx 0.03%.



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

steps2=12 stepsize2=(t2-t1)/steps2 points2=sum([point(s(t=j), color='purple', size=30) for j in [t1..t2-stepsize2,step=stepsize2]]) pieces2=sum([line([(s(t=j)),(s(t=j)+ds(t=j)*stepsize2)],thickness=2,color='purple') for j in [t1..t2-stepsize2,step=stepsize2]]) show(C+pieces2+points2,aspect_ratio=1)

We sum the length of these pieces.

Lapprox2=sum([norm(ds(t=j))*stepsize2 for j in [t1..t2-stepsize2,step=stepsize2]]) n(Lapprox2)
\newcommand{\Bold}[1]{\mathbf{#1}}12.7634994214955

So the approximate arc length of this weirdo curve using 12 tangent pieces is: L12=12.76L_{12} =12.76.

We calculate our new error.

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

Our error is now smaller than: 1.0×109 1.0 \times 10^{-9}. 
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.