integrating trig functions with large constants, exponent out of range
Subject: integrating trig functions with large constants, exponent out of range
From: Richard Fateman
Date: Fri, 5 Jan 2007 21:05:51 -0800
There is a question as to whether you want to slow maxima down to allow for
the case that a polynomial in rational form will have a maximum degree of
more than 2^31 (or whatever the boundary is between fixnum and arbitrary
precision). Presumably the declarations don't have to do with the
coefficients, but with the exponents.
The particular bug here is presumably provoked by a bad algorithm that
converts sin(n*x) into a polynomial of degree n. (in exp(%i*x) presumably).
The Risch algorithm, which should not be called here, is apparently being
called. It would perhaps not happen if %i were not there.
RJF
> -----Original Message-----
> From: maxima-bounces at math.utexas.edu [mailto:maxima-
> bounces at math.utexas.edu] On Behalf Of Robert Dodier
> Sent: Friday, January 05, 2007 8:38 PM
> To: Daniel Lakeland
> Cc: Maxima Mailing List
> Subject: Re: [Maxima] integrating trig functions with large
> constants,exponent out of range
>
> 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
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima