Re: Combining InterpolatingFunctions
- To: mathgroup at smc.vnet.net
- Subject: [mg107125] Re: Combining InterpolatingFunctions
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Wed, 3 Feb 2010 06:11:40 -0500 (EST)
On 2/2/10 at 3:30 AM, Simon.Pearce at nottingham.ac.uk (Simon Pearce) wrote: >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. >Can anyone suggest an efficient way of combining >InterpolatingFunctions without re-interpolating them? Or turning the >extrapolation off! Use Piecewise to construct a new function that combines the two InterpolatingFunctions returned. Something like f[x_]:=Piecewise[{{u[x], 0<x<rc}, {y[x], rc<x<2}}] where u,v are the two interpolating functions you want to combine. When combined as above outside the range of 0 to 2, f is not defined. So, no extrapolation will be done.