MathGroup Archive 2010

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

Search the Archive

Re: Combining InterpolatingFunctions

  • To: mathgroup at
  • Subject: [mg107166] Re: Combining InterpolatingFunctions
  • From: JH <jlucio at>
  • Date: Thu, 4 Feb 2010 06:28:56 -0500 (EST)
  • References: <hk8nqs$8ne$>

On 2 feb, 09:30, Simon Pearce <Simon.Pea... at> wrote:
> 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

Hello, Simon:

The other solutions are good, but be careful with the values of your
new function outside its domain [0, 2]. Note that Piecewise gives 0 by
default for values outside of the specified domain. So I suggest
something like this:

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

f[t_] := f1[t] /; 0 <= t < rc
f[t_] := f2[t] /;rc <= t <= 2

In both cases f[t] is undefined outside its domain [0, 2].



  • Prev by Date: Re: Glynn and Gray ebook
  • Next by Date: Localize Pattern variables
  • Previous by thread: Re: Combining InterpolatingFunctions
  • Next by thread: Re: Combining InterpolatingFunctions