if nops(locp) > 0 then

subsop( locp=T, K );

collect( %, [T,cos,sin], factor );

K := subs( T=p, % );

else

K := collect( K, [cos,sin], factor );

fi;

debug_print( procname,

`cost of simplified new integrand:`, 1, cost(K) );

# put back into integral and the integral back

# into the remainder integral expression and we're done

debug_print(procname,`new definite integral:`,0);

subsop( 1=K, H );

subsop( locI=%, remdr );

end:

Now we begin the calculation. We'll apply this integration by parts procedure several times, until

the polynomial term of the integrand is differentiated into oblivion. Notice the *huge* amount of

simplification being done, as evidenced by the "cost" diagnostics.

time0 := time(): #reset print timing

_k_ := '_k_': #reset parts index

verbosity := 2: #not too verbose, please

ugh( integral );

ugh[0]: polynomial factor p:

+

+

+

+

*a*

0

*a*

1

*x*

*a*

2

*x*

2

*a*

3

*x*

3

*a*

4

*x*

4

ugh[0]: location of p in integrand:

[ ]

1

ugh[0]: integrating by parts...

ugh[0]: cost of evaluated part of integral:

+

+

+

+

91 *additions*

164 *multiplications*

28 *divisions*

26 *functions*

46 *subscripts*

ugh[0]: evaluated part of integral is stored in parts[0]

ugh[0]: new polynomial factor p:

+

+ +

2 *x a*

2

3 *x*

2

*a*

3

*a*

1

4 *x*

3

*a*

4

ugh[0]: location of p in integrand:

[ ]

1

ugh[0]: full non-sin/cos term:

+

+ +

2 *x a*

2

3 *x*

2

*a*

3

*a*

1

4 *x*

3

*a*

4

ugh[0]: cost of new integrand:

+

+

+

+

44 *additions*

81 *multiplications*

14 *divisions*

13 *functions*

4 *subscripts*

ugh[0]: simplifying sin/cos part of new integrand...

ugh[0]: cost of simplified new integrand:

+

+

+

+

44 *additions*

71 *multiplications*

16 *divisions*

13 *functions*

4 *subscripts*

ugh[0]: new definite integral:

Page 9