Calculation of the Length of an Arc of a Curve
​Authors: Housam Binous and Ahmed Bellagi

Consider a function defined by :
f(x)=
-x

+3Sin(x)
. We compute the length of an arc of a curve using the arc-length continuation.
​
Specifically, we find the length of the arc of the curve (indicated in red) for
x∈[-2,3.5]
. This length is equal to 13.6998.
In[]:=
f[x_]:=Exp[-x]+3Sin[x]
In[]:=
f[x]
Out[]=
-x

+3Sin[x]
In[]:=
p=Show[Plot[f[x],{x,-5,5},Frame->True,AspectRatio->1,GridLines->Automatic,PlotStyle->Darker@Blue,FrameLabel->{Style["x",16],Style["f(x)",16]},PlotRange->{{-5,5},{-5,60}}],Plot[f[x],{x,-2,3.5},Frame->True,AspectRatio->1,GridLines->Automatic,PlotStyle->Darker@Red],ImageSize->250{1,1}]
Out[]=
Method based on arc - length continuation
In[]:=
eq1=y[s]==f[x[s]](*equationofanellipse*)
Out[]=
y[s]
-x[s]

+3Sin[x[s]]
In[]:=
eq2=x'[s]^2+y'[s]^2==1(*auxiliaryequation*)
Out[]=
2
′
x
[s]
+
2
′
y
[s]
1
In[]:=
SOL=Quiet@First@NDSolve[{eq1,eq2,x[0]==0,y[0]==1,x'[0]==0.01,y'[0]==-0.01},{x,y},{s,-40,80},AccuracyGoal->10]
Out[]=
xInterpolatingFunction
Domain: {{-40.,80.}}
Output: scalar
,yInterpolatingFunction
Domain: {{-40.,80.}}
Output: scalar

In[]:=
p1=ParametricPlot[{x[s],y[s]}/.SOL,{s,-40,80},Frame->True,GridLines->Automatic,PlotRange->{{-5,5},{-5,60}},AspectRatio->1,PlotStyle->Darker@Green,FrameLabel->{Style["x",16],Style["f(x)",16]},ImageSize->250{1,1}]
Out[]=
In[]:=
s1=s/.FindRoot[(x[s]/.SOL)==-2,{s,25}]
Out[]=
6.1305
In[]:=
s2=s/.FindRoot[(x[s]/.SOL)==3.5,{s,-25}]
Out[]=
-7.56934
In[]:=
length=s1-s2
Out[]=
13.6998
In[]:=
p2=ParametricPlot[{x[s],y[s]}/.SOL,{s,s2,s1},Frame->True,GridLines->Automatic,ImageSize->Medium,PlotRange->{{-5,5},{-5,60}},AspectRatio->1,PlotStyle->Darker@Magenta,ImageSize->250{1,1}];
In[]:=
p3=Show[p1,p2]
Out[]=
In[]:=
GraphicsGrid[{{p3},{p}}]
Out[]=