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?