MathGroup Archive 2007

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

Search the Archive

Numerical Convolution Problem, different results by Mathematica V3

  • To: mathgroup at smc.vnet.net
  • Subject: [mg73475] Numerical Convolution Problem, different results by Mathematica V3
  • From: "zohrab.avdoyan" <zohrab.avdoyan at wanadoo.fr>
  • Date: Mon, 19 Feb 2007 01:26:33 -0500 (EST)

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: Coaxing N[] to work
  • Next by Date: Re: grouping similar list elements with gaps
  • Previous by thread: EXCEL-Mathematica Link for EXCEL & @Risk
  • Next by thread: Precision of a number raised to a power