Re: Combining InterpolatingFunctions

• To: mathgroup at smc.vnet.net
• Subject: [mg107116] Re: Combining InterpolatingFunctions
• From: Peter Pein <petsie at dordos.net>
• Date: Wed, 3 Feb 2010 06:10:00 -0500 (EST)
• References: <hk8nqs\$8ne\$1@smc.vnet.net>

Am 02.02.2010 09:30, schrieb Simon Pearce:
> Hi MathGroup,
>
>
>
> I have two sets of InterpolatingFunctions coming from two separate
> NDSolve's. One of them is defined over the region [0,rc] and the other
> over the region [rc,2]. I would like Mathematica to automatically choose
> the correct one when I use a replacement rule. If I could tell it never
> to extrapolate this would be perfect, though I don't seem to be able to.
>
>
>
> I've tried using FunctionInterpolation, but in order to keep my error
> terms down I had to increase the InterpolationPoints to 1000, which
> increases the calculation time from approximately .5sec to 1.5sec.
>
>
>
> Can anyone suggest an efficient way of combining InterpolatingFunctions
> without re-interpolating them? Or turning the extrapolation off!
>
>
>
> Thanks,
>
>
>
> Simon Pearce
>
>

Hi Simon,

say f1 is the interpolating function for [0,rc] and f2 for [rc,2]; then

f[t_]:=Piecewise[{{f1[t],0<=t<=rc},{f2[t],rc<t<=2}}]

defines a function which returns 0 for t outside [0,2] and selects the
correct function for each subinterval (assuming they take the same value
at t==rc).

If you want to extrapolate outside [0,2], use

f[t_]:=Piecewise[{{f1[t],t<=rc}},f2[t]]

hope that helps,
Peter

• Prev by Date: Re: Can Mathematica solve this differential equation ?
• Next by Date: Re: Re: A question about a sphere
• Previous by thread: Re: Combining InterpolatingFunctions
• Next by thread: Re: Combining InterpolatingFunctions