       Re: Derivative of Interpolation function is

• To: mathgroup at smc.vnet.net
• Subject: [mg107302] Re: [mg107295] Derivative of Interpolation function is
• From: Leonid Shifrin <lshifr at gmail.com>
• Date: Mon, 8 Feb 2010 07:54:18 -0500 (EST)
• References: <201002080835.DAA29833@smc.vnet.net>

```Hi Dominic,

NIntegrateInterpolatingFunction from FunctionApproximations` package will do
the trick:

In:= Needs["FunctionApproximations`"]

In:= NIntegrateInterpolatingFunction[
1/(xfun[t] + I yfun[t]) (xdfun[t] + I ydfun[t]), {t, 1, 884}]

Out= -7.16706*10^-17 + 6.28319 I

Regards,
Leonid

On Mon, Feb 8, 2010 at 12:35 AM, Dominic <miliotodc at rtconline.com> wrote:

> Hi.
>
> I'd like to obtain greater numerical accuracy on a contour integral I'm
> working on over a closed contour that I'd like to represent
> parametrically as {x(t),y(t)} in the form of InterpolationFunctions.
> However I noticed when I attempt to obtain the derivatives of the
> Interpolation, these derivatives are highly-oscillatory which I suspect
> causes the numerical integration to suffer.  For example, suppose I just
> use  1/z over the unit circle as an example here, plot the contour
> parametrically, extract the x and y points, then do an Interpolation on
> the x and y lists to obtain {x(t),y(t)}.  In order to next integrate 1/z
> over this contour, I'd need to calculate the derivatives of x(t) and
> y(t) and then calculate numerically 1/(x(t)+iy(t)(x'(t)+iy'(t)) dt.
> However when I do that, the resulting derivative plot (thederiv below)
> is highly oscillatory and  NIntegrate reports that  the integration is
> converging too slowly.  The following code demonstrates this with the
> interpolation functions.  The result should be 2pi i and it's close but
> only to 2 digits accuracy.
>
> Is there any way to improve the accuracy of the numerically-computed
> derivative of an Interpolation function and obtain an integration value
> closer to the actual value of 2pi i?
>
> Thanks guys!
> Dominic
>
> p1 = ParametricPlot[{Cos[t], Sin[t]}, {t, 0, 2 \[Pi]}]
> lns = Cases[Normal[First[p1]], Line[pts_] -> pts, {0, Infinity}];
> myxval = (#1[] &) /@ lns[];
> myyval = (#1[] &) /@ lns[];
>
> xfun = Interpolation[myxval, InterpolationOrder -> 10]
> yfun = Interpolation[myyval, InterpolationOrder -> 10]
> xdfun[t_] = D[xfun[t], t];
> ydfun[t_] = D[yfun[t], t];
> thederiv = Plot[{xdfun[t]}, {t, 1, 884}]
> NIntegrate[1/(xfun[t] + I yfun[t]) (xdfun[t] + I ydfun[t]), {t, 1, 884}]
>
> (* integral using actual functions and derivatives *)
> NIntegrate[1/(Cos[t] + I Sin[t]) (-Sin[t] + I Cos[t]), {t, 0, 2 \[Pi]}]
>
>
>

```

• Prev by Date: Re: LaplaceTransform[SquareWave[]] ??
• Next by Date: Launching several Mathematica programs from DOS command
• Previous by thread: Derivative of Interpolation function is highly-oscillatory
• Next by thread: Re: Derivative of Interpolation function is highly-oscillatory