The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » sci.math.* » sci.math.symbolic

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Recusively calculating curve length question
Replies: 2   Last Post: Nov 23, 2012 10:23 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Brad Cooper

Posts: 171
Registered: 12/8/04
Recusively calculating curve length question
Posted: Nov 23, 2012 5:16 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I have spent quite a few hours trying to write a recursive routine
to calculate the length of a curve by adding up small secants.

I use a straight forward summation to calculate a correct approx. length


Set up the curve using X(t) = E^t and Y(t) = sin(t)

X := t -> E^t:
Y := t -> sin(t):

Use the interval [a, b] where a = -1.0 and b = 1.0

Firstly, use a straight forward summation to get the correct length:

a := -1.0:
b := 1.0:

n := 50: //use 50 secants
h := (b-a)/n: //width of each secant

Now calculate the approx. length of the curve

sum(sqrt( (X(a+h*(i))-X(a+h*(i-1)))^2 +
(Y(a+h*(i))-Y(a+h*(i-1)))^2 ), i=1..n);

Answer for length is 2.99758079


Now set up a recursive routine to calculate the curve length:
(One of many variations)

secantLen := proc(a, b, tolerance)
L := sqrt( (X(b)-X(a))^2 + (Y(b)-Y(a))^2 ):
c := (a+b)/2:

if L > tolerance then
L := secantLen(a, c, tolerance) + secantLen(c, b, tolerance):


Call the recursive routine:

a := -1.0:
b := 1.0:
tolerance := 0.05:

secantLen(a, b, tolerance):

This gives 5.984159884 (incorrect)

It is difficult to debug. Any help appreciated.


Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.