FAQ
Hi:

If your curve is in a 2-dim plane, then you can use the following
formula (in Tex notation):

\int_a^b \sqrt{1 + (\frac{df}{dx})^2} dx

So you need to take the derivative of your function first, and then
compute the integral of sqrt(1 + deriv^2) from a to b.

Here is a simple code to find the arclength of the curve: sin(x),
between -pi and pi.
##########################
arclen <- function(gexp, a, b) {
g <- function(x) { }
body(g) <- D(gexp, "x")
farc <- function(x) sqrt(1 + g(x)^2)
integrate(farc,low=a,upp=b)\$val
}

gexp <- expression(sin(x))
arclen(gexp,-pi,pi)
###########################

Best,
Ravi.

----- Original Message -----
From: Greg Trafton <trafton@itd.nrl.navy.mil>
Date: Thursday, November 13, 2003 9:37 pm
Subject: [R] calculating arc length using R?
Hi, All. I have a function I want to know the plotted length of.
is it
possible to calculate the length of the function (e.g., arc length)?

for example, if I want to know the length of the line of
sin(x) from -pi to pi, how can I do that in R?

thanks!
greg

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

## Related Discussions

 view thread | post posts ‹ prev | 6 of 6 | next ›
Discussion Overview
 group r-help categories r posted Mar 18, '03 at 6:26p active Nov 14, '03 at 5:44p posts 6 users 4 website r-project.org irc #r

### 4 users in discussion

Content

People

Support

Translate

site design / logo © 2018 Grokbase