# Make a Module that calculates the arc length of a function?

**URL:** <https://community.wolfram.com/t/make-a-module-that-calculates-the-arc-length-of-a-function/8325>\
**Category:** Questions\
**Created:** [April 10, 2016, 2:47pm UTC](https://community.wolfram.com/t/make-a-module-that-calculates-the-arc-length-of-a-function/8325 "2016-04-10T14:47:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahmedo96](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/ahmedo96/32/26519_2.png) [@ahmedo96](https://community.wolfram.com/u/ahmedo96)\
**Post date:** [April 10, 2016, 2:47pm UTC](https://community.wolfram.com/t/make-a-module-that-calculates-the-arc-length-of-a-function/8325/1 "2016-04-10T14:47:44Z")

</div>

So I have project in Mathematica and to be honest I have no Idea how to do this:  
I have to make a Module which should calculate the arc length of this function

![ice_screenshot_20160410-164502.png](https://global.discourse-cdn.com/wolfram/original/3X/0/7/07d44f88146d193b59705e35afa14297ce3567e2.png)

Is there someone who could help me?

---

<div class="post-metadata">

**Author:** ![tasneemsmadi](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/tasneemsmadi/32/38007_2.png) [@tasneemsmadi](https://community.wolfram.com/u/tasneemsmadi)\
**Post date:** [April 11, 2016, 8:18am UTC](https://community.wolfram.com/t/make-a-module-that-calculates-the-arc-length-of-a-function/8325/2 "2016-04-11T08:18:24Z")

</div>

> **[ArcLength—Wolfram Documentation](https://reference.wolfram.com/language/ref/ArcLength.html)**
>
> ArcLength\[reg\] gives the length of the one-dimensional region reg. ArcLength\[{x1, ..., xn}, {t, tmin, tmax}\] gives the length of the parametrized curve whose Cartesian coordinates xi are functions of t. ArcLength\[{x1, ..., xn}, {t, tmin, tmax},...

This may be help you

---

<div class="post-metadata">

**Author:** ![hdolhaine](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/hdolhaine/32/35924_2.png) [@hdolhaine](https://community.wolfram.com/u/hdolhaine)\
**Post date:** [April 11, 2016, 10:19pm UTC](https://community.wolfram.com/t/make-a-module-that-calculates-the-arc-length-of-a-function/8325/3 "2016-04-11T22:19:57Z")

</div>

Well, the answer of Tasneem is cool, but I suppose not very helpful.

You have a vector X[t], its variation is d X[t] = D[X[ t], t ] dt, where D[…, t] ist the differentiation with repect to t. The length of this variation is Sqrt[d X[ t] . d X[t] ] dt , where the . indicates the scalar product of two vectors. This expression ist to be integrated between t1 and t2 to get the length you are looking for.

```
In[9]:= X[t] = { t^2, (1 - t)^2, 2 t};
dx = D[X[t], t]
dx2 = dx.dx // Expand
jj = Sqrt[dx2]
arc = Integrate[jj, {t, t1, t2}]

Out[10]= {2 t, -2 (1 - t), 2}

Out[11]= 8 - 8 t + 8 t^2

Out[12]= Sqrt[8 - 8 t + 8 t^2]

Out[13]= If[((Im[t2] Re[t1] <= Im[t1] Re[t2] && 
      Im[t1] >= Im[t2]) || (Im[t2] Re[t1] >= Im[t1] Re[t2] && 
      Im[t1] <= Im[t2])) && ((Im[t2] Re[t1] - 
       Im[t1] Re[t2])^2/(Re[t1] - Re[t2])^2 == 
     1 || (Im[t2] Re[t1] - Im[t1] Re[t2])^2/(Re[t1] - Re[t2])^2 <= 
     1), -((2 (-1 + 2 t1) Sqrt[1 - t1 + t1^2] - 
    3 ArcSinh[(1 - 2 t1)/Sqrt[3]])/(2 Sqrt[2])) + (
  2 (-1 + 2 t2) Sqrt[1 - t2 + t2^2] - 3 ArcSinh[(1 - 2 t2)/Sqrt[3]])/(
  2 Sqrt[2]), 
 Integrate[Sqrt[8 - 8 t + 8 t^2], {t, t1, t2}, 
  Assumptions -> ! (((Im[t2] Re[t1] <= Im[t1] Re[t2] && 
          Im[t1] >= Im[t2]) || (Im[t2] Re[t1] >= Im[t1] Re[t2] && 
          Im[t1] <= Im[t2])) && ((Im[t2] Re[t1] - 
           Im[t1] Re[t2])^2/(Re[t1] - Re[t2])^2 == 
         1 || (Im[t2] Re[t1] - Im[t1] Re[t2])^2/(Re[t1] - Re[t2])^2 <=
          1))]]

```

---

<div class="post-metadata">

**Author:** ![samcarrettie](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/samcarrettie/32/29668_2.png) [@samcarrettie](https://community.wolfram.com/u/samcarrettie)\
**Post date:** [April 12, 2016, 5:56am UTC](https://community.wolfram.com/t/make-a-module-that-calculates-the-arc-length-of-a-function/8325/4 "2016-04-12T05:56:36Z")

</div>

This is pretty easy to use. For general limiting points:

```
ArcLength[{t^2, (1 - t)^2, 2 t}, {t, a, b}]

```

![2016-04-12_00-54-52.png](https://global.discourse-cdn.com/wolfram/original/3X/e/0/e05ee82bbdde7ac7bbb68b54ba007e63c0c10f84.png)

and for say interval `{0,1}`:

```
ArcLength[{t^2, (1 - t)^2, 2 t}, {t, 0, 1}]

```

![2016-04-12_00-56-21.png](https://global.discourse-cdn.com/wolfram/original/2X/9/99635211071de81c230b4f99d0d0c509ff0c1152.png)

---

<div class="post-metadata">

**Author:** ![webauct](https://avatars.discourse-cdn.com/v4/letter/w/c89c15/32.png) [@webauct](https://community.wolfram.com/u/webauct)\
**Post date:** [April 12, 2016, 4:39pm UTC](https://community.wolfram.com/t/make-a-module-that-calculates-the-arc-length-of-a-function/8325/5 "2016-04-12T16:39:00Z")

</div>

Hello

To add to Hans Dolhaine answer with some assumptions the arc length expression simplifies a lot:

```
 arc = Integrate[jj, {t, t1, t2}, 
 Assumptions -> {t1 \[Element] Reals && t2 \[Element] Reals && 
 t2 > t1}]

 (2 Sqrt[1 - t1 + t1^2] - 4 t1 Sqrt[1 - t1 + t1^2] - (* answer *)
2 Sqrt[1 - t2 + t2^2] + 4 t2 Sqrt[1 - t2 + t2^2] - 
3 ArcSinh[(-1 + 2 t1)/Sqrt[3]] + 
3 ArcSinh[(-1 + 2 t2)/Sqrt[3]])/(2 Sqrt[2])

```

---

<div class="post-metadata">

**Author:** ![hdolhaine](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/hdolhaine/32/35924_2.png) [@hdolhaine](https://community.wolfram.com/u/hdolhaine)\
**Post date:** [April 12, 2016, 4:40pm UTC](https://community.wolfram.com/t/make-a-module-that-calculates-the-arc-length-of-a-function/8325/6 "2016-04-12T16:40:26Z")

</div>

ok, the output after the integration seems a bit puzzling. but we can ask mma to skip generating conditions and get the same result as Sam:

```
X[t] = {t^2, (1 - t)^2, 2 t};
dx = D[X[t], t] 
dx2 = dx.dx // Expand 
jj = Sqrt[dx2] 
SetOptions[Integrate, GenerateConditions -> False]
arc = Integrate[jj, {t, a, b}] // FullSimplify   

Out[2]= {2 t, -2 (1 - t), 2}

Out[3]= 8 - 8 t + 8 t^2

Out[4]= Sqrt[8 - 8 t + 8 t^2]

Out[5]= {Assumptions :> $Assumptions, GenerateConditions -> False, 
 PrincipalValue -> False}

Out[6]= (1/(2 Sqrt[2]))(2 (1 - 2 a) Sqrt[1 + (-1 + a) a] + 
  2 (-1 + 2 b) Sqrt[1 + (-1 + b) b] - 3 ArcSinh[(-1 + 2 a)/Sqrt[3]] + 
  3 ArcSinh[(-1 + 2 b)/Sqrt[3]])

```

But for sure there is a lot of cases where the (symbolic) integration is simpliy not feasible. In this case you should use numeric integration. for example

```
In[8]:= narc = NIntegrate[jj, {t, 1, 2.5}]
Out[8]= 6.54418

```
