MathGroup Archive 2007

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

Search the Archive

Re: Joining InterpolatingFunctions into Piecewise - doman?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg83579] Re: Joining InterpolatingFunctions into Piecewise - doman?
  • From: dh <dh at metrohm.ch>
  • Date: Fri, 23 Nov 2007 05:36:33 -0500 (EST)
  • References: <fi133t$cq8$1@smc.vnet.net>


Hi Janos,

note that Piecewise has the attribute HoldAll. However, you want to 

evaluate the body of Pieceweise before feeding it to Piecewise. I do 

this with "tt":

f[ini_,tlast_]:=Module[{from=tlast,to=tlast+1,X},{X=(x/.NDSolve[{x'[t]==-0.5 

x[t],ini},x,{t,from,to}])[[1]],to,X[to]}]

nl=NestList[f[x[#[[2]]]==#[[3]],#[[2]]]&,{zzz,0,2.0},3];

tt=Transpose[{Table[nl[[k,1]][t],{k,2,4}],Table[k<=t<k+1,{k,0,2}]}];

Plot[Piecewise[tt],{t,0,3}]

hope this helps, Daniel



janos wrote:

> I would like to solve a diff eq on a very large interval, therefore I

> solve it on successive intervals.

> When putting the results together I get a _relatively_ good figure and

> an error message.

> Note that there is a hole on the graph of the function. Any other

> solution to join InterpolatingFunction objects would be appreciated.

> 

> Thank you, Janos

> 

> f[ini_, tlast_] :=

>  Module[{from = tlast, to = tlast + 1,

>    X}, {X = (x /.

>        NDSolve[{x'[t] == -0.5 x[t], ini}, x, {t, from, to }])[[1]],

>    to, X[to]}]

> nl = NestList[f[x[#[[2]]] == #[[3]], #[[2]]] &, {zzz, 0, 2.0}, 3];

> full[t_] :=

>  Piecewise[

>   Transpose[{Table[nl[[k, 1]][t], {k, 2, 4}],

>     Table[k <= t < k + 1, {k, 0, 2}]}]]

> Plot[full[t], {t, 0, 3}]

> 




  • Prev by Date: Re: Interpolating arrays
  • Next by Date: Button[label, action] Change Font?
  • Previous by thread: Joining InterpolatingFunctions into Piecewise - doman?
  • Next by thread: How can I find roots in Mathematica 6?