MathGroup Archive 2007

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

Search the Archive

Re: Numerical Convolution Problem, different results by

  • To: mathgroup at smc.vnet.net
  • Subject: [mg73461] Re: [mg73436] Numerical Convolution Problem, different results by
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Sat, 17 Feb 2007 05:04:16 -0500 (EST)
  • Reply-to: hanlonr at cox.net

$Version

5.2 for Mac OS X (June 20, 2005)

test=DSolve[{x'[t]==y[t],y'[t]==x[t],x[0]==1, 
        y[0]==2},{x[t],y[t]},t];

ff1[t_]=test[[1,1,2]] ;

ff2[t_]=test[[1,2,2]];

convolve[f_,g_,t_]:=Integrate[f[u]*g[t-u],{u,0,t}];

ff3[t_]=convolve[ff1,ff2,t];

ff4[t_]=convolve[ff3,ff1,t];

ff5[t_]=convolve[ff4,ff3, t];

#[10.]&/@{ff3,ff4,ff5}

{495595.48026965134, 3.597197195474734*^6, 6.531225687989658*^7}

test=NDSolve[{x'[t]==y[t], y'[t]==x[t],
        x[0]==1, y[0]==2},{x[t], y[t]},{t,0,10}];

f1[t_]=test[[1,1,2]] ;

f2[t_]=test[[1,2,2]];

convolve[f_, g_, t_?NumericQ] := 
    NIntegrate[f[u]*g[t - u],{u,0,t}];

f3[t_?NumericQ] := convolve[f1, f2, t];

f4[t_?NumericQ] := convolve[f3, f1, t];

f5[t_?NumericQ] := convolve[f4, f3, t]; 

#[10]&/@{f3,f4,f5}

{495594.80331690225, 3.5971920326086623*^6, 6.531213402318461*^7}


Bob Hanlon

---- "Zhao wrote: 
> Hello,
> I guess I am running into a numerical problem when I am trying to 
> perform Convolutions on InterpolatingFunctions .
> Firstly, I get the "exact" answer by performing the convolution with 
> closed form functions and assign values to integral limits as shown as 
> follows.
> 
> test=DSolve[{x'[t]==y[t], y'[t]==x[t],x[0]==1, 
> y[0]==2}, {x[t], y[t]}, t]
> 
> ff1[t_]=test[[1]][[1]][[2]]
> 
> ff2[t_]=test[[1]][[2]][[2]]
> 
> convolve[f_,g_,t_]:=Integrate[f[u]*g[t-u],{u,0,t}]
> 
> ff3[t_]=convolve[ff1,ff2,t]
> 
> N[ff3[10]]
> 
> ff4[t_]=N[convolve[ff3,ff1,t]]
> 
> N[ff4[10]]
> 
> ff5[t_]:=convolve[ff4,ff3, t]
> 
> N[ff5[10]]
> 
> The above code gives:
> 
> 495595.
> 3.5972 10^6
> 
> 6.53123 10^7
> 
> However, when I calculate the same thing from the numerical route, it 
> gives different result.
> < /FONT>< /FONT>
> 
> test = NDSolve[{x'[t] == y[t],
> 
>        y'[t] == x[t], x[0] == 1, y[0] == 2}, {x[t], y[t]}, 
> {t, 0, 10}];
> 
> f1[t_] = test[[1]][[1]][[2]];
> 
> f2[t_] = test[[1]][[2]][[2]];
> 
> convolve[f_, g_, t_?NumericQ] := N[NIntegrate[f[u]*g[t - u], {u, 0, 
> t}]];
> 
> f3[t_?NumericQ] := convolve[f1, f2, t];
> 
> f3[10]
> 
> f4[t_?NumericQ] := convolve[f3, f1, t];
> 
> f4[10]
> 
> f5[t_?NumericQ] := convolve[f4, f3, t];
> 
> f5[10]
> 
> It gives
> 
> 495595.
> 
> 4.79075 10^6
> 
> 5.13256 10^17
> 
> Even more interestingly, when I sent the same code over to friend to run 
> it with Mathematica V3.0, the numerical solution rendered by the above 
> code is fine. I need your help to unpuzzle the myth!
> 
> 
> Liang Zhao



  • Prev by Date: Re: Re: Logical Expression
  • Next by Date: Re: FactorInteger - MathKernel crashes
  • Previous by thread: Re: cellform to console form
  • Next by thread: Automatic Notebook Evaluation