Integration of (a-b)^n



 On 9/19/10 12:50 PM, Ian Bell wrote:
> Hello all,
>
> I'm a relatively new Maxima user, though I have found the software to
> be user friendly enough, and you can't beat the price.
>
> My question relates to definite integration, a tricky subject, and one
> which a lot of CAS programs struggle with.  So what I want to know is
> how I get
You mean indefinite integration, not definite integration?
>  
> integrate((a-b)^2,a) to give me the factored solution (a-b)^3/3 .
> Maxima (and Mathematica for that matter), expand the product and then
> group all the constants together since mathematically they all drop
> out when you plug in limits.  In this way it makes it impossible to
> refactor the anti-derivative back to the form (a-b)^3 .   I've got a
> lot of other integrals that I have a similar problem with, like
> (a-b)^n*sin(a) with n an integer.  For what its worth, in MATLAB (w/
> MuPaD) int((a-b)^2,a) yields (a-b)^3/3
>
This has come up before in some bug report.  Currently, you can't do
that.  The issue is that in the function diffdiv, there is a test for
the exponent.  If the 0 < exponent < 6, then the integrand is expanded
out before integrating.  If the exponent is not in that range, a
different method is used, which, in this case, gives the form you want: 
integrate((a-b)^6,a) -> (a-b)^7/7.

There is no documentation on why this is done or why 6 and not some
other number is used.

If you want to, you could just take the diffdiv function and change the
6 to 1 and load it in your running lisp to get your desired answer.   Or
maxima could make the 6 some variable that the user could set, but there
are enough random global variables already.  Or maxima could just cut
out that test completely.

What is the issue with integrate((a-b)^n*sin(a),n)?  Off the top of my
head, the only way I'd integrate that would be to expand (a-b)^n out so
the result would be a sum of integrals of the form integral(a^n*sin(a),a).

Ray