3
$\begingroup$

I want to use Mathematica to find the length of a curve and the sum of angles you would turn back and forth when travelling along that curve. To clarify, the angle I am looking for is the sum of all angular changes of travel direction I would have to make if I was a little ant crawling along the curve plotted by the function f between 0 and π. Every little turn the ant makes should add it's angular absolute value to the total angle.

I have tried to use ArcLength and ArcCurvature functions but can't get them to give me the correct answer. My math is basic, and I am new to Mathematica, so I suspect I am making some simple beginner mistakes. I tried with the simple curve Sin[x], which for $x = 0$ to $π$ should result in a total sum of angle turned of $π/2$. I did this:

(ArcLength[{x, Sin[x]}, {x, 0, π}])  / 
(Integrate[ArcCurvature[{a, Sin[a]},a],{a,0,π}]) 

But that does not give me the answer I am expecting.

The above is just a first simple example of a curve I used for my tests and for which I know the correct turned angle. The curves I actually need length and turned angle for look more like this: $f[x] = Sin[x] + 1/2 Sin[2x] + 1/7 Sin[3x + π/31]$

I have made a manual approximation of the results I want to see. I printed the curve of the complex function f[] above and measured the sum of angles between 0 and π on the printout, I get approximately 132 degrees total angle, or about 2.3 radians. My manual measurements are probably off a little, but not much more than 3-4 degree, I think.

When making a manual measurement of the curve length between 0 and π, I get approximately 4.24. Mathematica ArcLength gives (after a long time) the result 4.29363, which means in this case my manual measurement is not so bad, also indicating ArcLength can be trusted.

Is there any way to compute the total turn angle 2.3 radians given a function like f above based on sine and it's harmonics, and the length of it’s curve?

$\endgroup$

1 Answer 1

4
$\begingroup$

ArcLength gives the correct result.

ArcCurvature gives the curvature of a curve what is NOT the angle. The angle is: ArcTan[f'[x]]. The differential of this is:

dphi= D[ArcTan[f'[x]]]

Therefore , to get the turning angle you have to integrate:

f[x_] = Sin[x];
Integrate[D[ArcTan[f'[x]], x], {x, 0, Pi}]

-(\[Pi]/2)

This gives simply the change in the angle between start and end. If you want to know how much you turned without taking into account the sign, you integrate you must take the absolute value of the differential: Abs[D[ArcTan[f'[x]], x]]

Integrate[Abs[D[ArcTan[f'[x]], x]], {x, 0, Pi}]

\[Pi]/2
$\endgroup$
5
  • $\begingroup$ Daniel, I can only get your answer to work for Sin[x], and for x between 0 and π. See my updated question above. As I understand it, ArcCurvature gives the radius of a circle (which obviously has a corresponding curvature). You then wrap the curve length around the circumference of the circle with that radius to get the central angle, which is also the angle turned traveling along the curve. But, maybe that is a misunderstanding on my part. $\endgroup$
    – Mikl
    Commented Feb 29 at 13:31
  • $\begingroup$ The curvature is the INVERSE radius of the osculating circle. If I replace f[x] by f[x_] = Sin[x] + 1/2 Sin[2 x] + 1/7 Sin[3 x + \[Pi]/31];I get: -1.5829 what seems o.k. What does not work? $\endgroup$ Commented Feb 29 at 14:52
  • $\begingroup$ Let me just check if I understand this correctly. You are saying that the curvature of that function between 0 and π is that of a circle with 1/1.5829 radius? And thus a circumference of 1/1.5829 times 2π ≈ 3.97. Right? $\endgroup$
    – Mikl
    Commented Feb 29 at 18:28
  • $\begingroup$ No. The change of the angle between the x axis and the tangent (the slope) between start and end is -1.5829 $\endgroup$ Commented Feb 29 at 19:15
  • $\begingroup$ Ah, I just need to take the absolute value of the ArcTan derivative! Like this: Integrate[Abs[D[ArcTan[f'[x]], x]], {x, 0, Pi}] Thank you very much Daniel, you have saved my day! $\endgroup$
    – Mikl
    Commented Feb 29 at 20:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.