Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: How to Calculatelength of an Spline curve between two points?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg104891] Re: How to Calculatelength of an Spline curve between two points?
  • From: Mark Fisher <particlefilter at gmail.com>
  • Date: Thu, 12 Nov 2009 06:07:57 -0500 (EST)
  • References: <hdbhcp$jj4$1@smc.vnet.net>

On Nov 10, 6:04 am, alfaeco <alfa... at gmail.com> wrote:
> I need some help.
>
> Given an Interpolating function with method-> Spline.
>
> sp = Interpolation[tbl, Method -> "Spline"];
>
> How can I calculate the distance between two arbitrary points of the
> splines?

I'm assuming you want to compute the distance along the spline. In
principle it should be easy, but because of a bug (that produces a
kernel crash) it's a bit harder.

Here's the setup:

data = Table[{i, RandomReal[{-10, 10}]}, {i, 5}];
ifun = Interpolation[data, Method -> "Spline"];

Now let's simply use the formula for arc length to compute the
distance from x = 1.5 to x = 3.1:

NIntegrate[Sqrt[1 + ifun'[x]^2], {x, 1.5, 3.1}]

But on my system (Windows XP, Mathematica Version 7.0.1) this crashes the
kernel. So does FunctionInterpolation[ifun'[x], {x, 1, 5}], so that's
out too.

OK, we can do this "by hand":

difun = Interpolation[Table[{x, ifun'[x]}, {x, 1, 5, .01}]]

Then use the arc length formula:

NIntegrate[Sqrt[1 + difun[x]^2], {x, 1.5, 3.1}]

On the other hand, if this is not what you want, then never mind.

--Mark


  • Prev by Date: Importing Excel File into mathematica
  • Next by Date: Re: Solving Weissinger's ODE
  • Previous by thread: Re: How to Calculatelength of an Spline curve between two points?
  • Next by thread: Re: Re: How to Calculatelength of an Spline curve between