Bill Allombert on Fri, 26 Feb 2010 19:37:46 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Strange behaviour of intnum


On Fri, Feb 26, 2010 at 10:30:05AM +0100, Olivier Ramare wrote:
> Hello,
>
>  (1)----------------------------------------------------------------------
>
> Can anyone tell me what wrong with
>
> intnum(t = [0,0], [1], (sin(t)/t)^2)

Your function is oscillating at oo: the documentation says:

   The last two codes are reserved for oscillating functions.   Let k > 0 real,
and g(x) a non-oscillating function tending slowly to 0 (e.g.   like a negative
power of x), then

   * alpha = k * I assumes that the function behaves like cos(kx)g(x).

   * alpha = -k* I assumes that the function behaves like sin(kx)g(x).

   Here it is critical to give the exact value of k. If the oscillating part is
not  a pure sine or cosine,  one must expand it into a Fourier series,  use the
above  codings,   and sum the resulting contributions.   Otherwise you will get
nonsense.   Note that cos(kx), and similarly sin(kx), means that very function,
and not a translated version such as cos(kx+a).

so here you must replace sin(x)^2 by (1-cos(2*x))/2 and sum:
You get:

? intnum(t = 0, 1,if(t,(1-cos(2*t))/2/t^2,1))+intnum(t = 1, [[1],2*I],-cos(2*t)/2/t^2)+intnum(t=1,[1],1/2/t^2)
%1 = 1.5707963267948966192313216916397514421

> intnum(t = [0,0], 1000, 9*((sin(t)-t*cos(t))/t^3)^2)

? intnum(t = 0, 1, 9*((sin(t)-t*cos(t))/t^3)^2)
%1 = 0.E143

This one is a bug, I do not see any reason why it fails.

Cheers,
Bill.