need help w/ MONSTERTRIG endless recursion



It seems to me that substituting 2x->y to make the cos(2x) "good",
will make sin(x) "bad", then monstertrig tries to fix the "bad" sin,
which would make cos bad again, ... I would say that what monstertrig
is trying to do is a good idea (not as good as integration by parts,
though) in a case such as f(x)*trig(a*x+b), where trig is a simple
sin, cos, ..., but if the trig function is a sum of other ("simpler")
trig functions, then it should try to multiply out and break the
integral into a sum of integrals. Rish probably works fine here
because n (from the monstertrig comment below) is 2 in this case. Of
course, an automatic "multiply out, ..." is not always the best thing
to do either:)

hth,
Milan

* Robert Dodier <robert.dodier at gmail.com> [2007-12-26 11:23:31 -0700]:

> The aptly-named MONSTERTRIG (I'm tempted to compose this message
> in html so that I can make it bold and blinking text ...) tries to reduce some
> trig expressions and start over. However I've encountered an expression
> for which the attempted reduction has no effect, so it loops endlessly.
> 
> e.g.
> 
> trace (integrate, ?monstertrig);
> integrate (x*(cos(2*x) + sin(x)), x);
>  =>
> 1 Enter integrate [x*(cos(2*x)+sin(x)),x]
>  1 Enter ?monstertrig [x*(cos(2*x)+sin(x)),x,x]
>  1 Exit  ?monstertrig false
>  1 Enter ?monstertrig [x*(cos(2*x)+sin(x)),x,2*x]
>   2 Enter integrate [?new\-var\-15974*(cos(?new\-var\-15974)
>                   +sin(?new\-var\-15974/2))
>   /2,?new\-var\-15974]
>    2 Enter ?monstertrig [?new\-var\-15974*(cos(?new\-var\-15974)
>                   +sin(?new\-var\-15974/2)),?new\-var\-15974,
>  ?new\-var\-15974/2]
>     3 Enter integrate [2*?new\-var\-15975
>   *(cos(2*?new\-var\-15975)+sin(?new\-var\-15975)),
>  ?new\-var\-15975]
>      3 Enter ?monstertrig [?new\-var\-15975*(cos(2*?new\-var\-15975)
>                   +sin(?new\-var\-15975)),?new\-var\-15975,
>  ?new\-var\-15975]
>      3 Exit  ?monstertrig false
> 
> ... etc etc.
> 
> Here's the relevant code from MONSTERTRIG (src/sin.lisp).
> 
>          ;; We have trig(c*x+b).  Use the substitution y=c*x+b to
>          ;; try to compute the integral.  Why?  Because x*sin(n*x)
>          ;; takes longer and longer as n gets larger and larger.
>          ;; This is caused by the Risch integrator.  This is a
>          ;; work-around for this issue.
>          (let ((c (cdras 'c arg))
>            (b (cdras 'b arg))
>            (new-var (gensym "NEW-VAR-")))
>            (let ((new-int (div ($integrate (maxima-substitute (div
> (sub new-var b) c)
>                                   var exp)
>                            new-var)
>                    c)))
>          (return-from monstertrig (maxima-substitute *trigarg* new-var
> new-int)))))
> 
> risch has no trouble with the example shown above, although the
> comments in MONSTERTRIG suggest risch has trouble in some cases.
> 
> What can we do here?
> 
> Robert
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima

--