integrating trig functions with large constants, exponent out of range
Subject: integrating trig functions with large constants, exponent out of range
From: Robert Dodier
Date: Fri, 5 Jan 2007 21:38:28 -0700
On 1/5/07, Daniel Lakeland <dlakelan at street-artists.org> wrote:
> > but had to interrupt it since it seemed to take forever. I found that
> > the integration time is dependent on the size of the constant in the
> > expression. integrate(%i*sin((3*x3))*x3, x3) happens fast,
> > integrate(%i*sin((30000*x3))*x3, x3) takes several seconds etc.
>
> This executes in no time flat for me on windows stock maxima 5.10.0 in
> GCL.
>
> ****** It also gives a wrong answer!!! ******
>
>
> (%i1) integrate(%i*sin(34037595938027*x3)*x3, x3);
> %i (sin(2 x3) - 2 x3 cos(2 x3))
> (%o1) -------------------------------
> 4
I'll make a guess that's because a fixnum has overflowed and GCL
didn't notice it.
In integrate(sin(N*x)*x, x) with values of N < 2^31, integrate takes
a long time. With N > 2^31, integrate returns immediately with an
incorrect answer.
The message 'Exponent out of range' comes from PCOEFADD
in src/rat3a.lisp. There are several variables declared fixnum there
and I guess it would help to cut out those declarations, but I think
it won't solve this problem: it looks like PCOEFADD is called
with N, N - 1, N - 2, N - 3, .... I don't know what is supposed to be
computed in that loop, but whatever it is, it won't work for really
large N.
With symbolic N integrate returns (sin(x*N)-x*N*cos(x*N))/N^2
right away. I guess this is a case in which Maxima knows the
general solution but fails on a special case; I'm pretty sure
other examples have been observed. If this is common enough
we might consider a heuristic such as replacing constants with
symbols and trying to solve that. Just a thought.
Hope this helps,
Robert