1COMMENT
2
3                 THE REDUCE INTEGRATION TEST PACKAGE
4
5                              Edited By
6
7                           Anthony C. Hearn
8			 The RAND Corporation
9
10
11This file is designed to provide a set of representative tests of the
12Reduce integration package.  Not all examples go through, even when an
13integral exists, since some of the arguments are outside the domain of
14applicability of the current package.  However, future improvements to
15the package will result in more closed-form evaluations in later
16releases.  We would appreciate any additional contributions to this test
17file either because they illustrate some feature (good or bad) of the
18current package, or suggest domains which future versions should handle.
19Any suggestions for improved organization of this test file (e.g., in a
20way which corresponds more directly to the organization of a standard
21integration table book such as Gradshteyn and Ryznik) are welcome.
22
23Acknowledgments:
24
25The examples in this file have been contributed by the following.
26Any omissions to this list should be reported to the Editor.
27
28David M. Dahm
29James H. Davenport
30John P. Fitch
31Steven Harrington
32Anthony C. Hearn
33K. Siegfried Koelbig
34Ernst Krupnikov
35Arthur C. Norman
36Herbert Stoyan
37;
38
39
40Comment we first set up a suitable testing functions;
41
42
43fluid '(gcknt!*);
44
45
46
47global '(faillist!* gcnumber!* inittime number!-of!-integrals
48         unintlist!*);
49
50
51
52symbolic operator time;
53
54
55
56symbolic procedure initialize!-integral!-test;
57   begin
58      faillist!* := unintlist!* := nil;
59      number!-of!-integrals := 0;
60      gcnumber!* := gcknt!*;
61      inittime := time()
62   end;
63
64
65initialize!-integral!-test
66
67
68symbolic procedure summarize!-integral!-test;
69   begin scalar totaltime;
70      totaltime := time()-inittime;
71      prin2t
72   "                *****     SUMMARY OF INTEGRAL TESTS     *****";
73      terpri();
74      prin2 "Number of integrals tested: ";
75      prin2t number!-of!-integrals;
76      terpri();
77      prin2 "Total time taken: ";
78      prin2 totaltime;
79      prin2t " ms";
80      terpri();
81      if gcnumber!*
82        then <<prin2 "Number of garbage collections: ";
83               prin2t (gcknt!* - gcnumber!*);
84               terpri()>>;
85      prin2 "Number of incorrect integrals: ";
86            prin2t length faillist!*;
87      terpri();
88      prin2 "Number of unevaluated integrals: ";
89      prin2t length unintlist!*;
90      terpri();
91      if faillist!*
92        then <<prin2t "Integrands of incorrect integrals are:";
93               for each x in reverse faillist!* do mathprint car x>>;
94      if unintlist!*
95        then <<prin2t "Integrands of unevaluated integrals are:";
96               terpri();
97               for each x in reverse unintlist!* do mathprint car x>>
98   end;
99
100
101summarize!-integral!-test
102
103
104procedure testint(a,b);
105  begin scalar der,diffce,res,tt;
106      tt:=time();
107      symbolic (number!-of!-integrals := number!-of!-integrals + 1);
108      res:=int(a,b);
109%     write "time for integral:  ",time()-tt," ms";
110      off precise;
111      der := df(res,b);
112      diffce := der-a;
113      if diffce neq 0
114	then  begin for all x let cot x=cos x/sin x,
115				  sec x=1/cos x,
116				  sin x**2=1-cos x**2,
117				  tan(x/2)=sin x/(1+cos x),
118				  tan x=sin x/cos x,
119		    		  tanh x=
120				     (e**(x)-e**(-x))/(e**x+e**(-x)),
121				  coth x= 1/tanh x;
122	       	    diffce := diffce;
123		    for all x clear cot x,sec x,sin x**2,tan x,tan(x/2),
124				    tanh x,coth x
125	      end;
126	%hopefully, difference appeared non-zero due to absence of
127	%above transformations;
128      if diffce neq 0
129	then <<on combineexpt; diffce := diffce; off combineexpt>>;
130      if diffce neq 0
131	then begin scalar !*reduced;
132		symbolic(!*reduced := t);
133		for all x let cos(2x)= 1-2sin x**2, sin x**2=1-cos x**2;
134		diffce := diffce;
135	       for all x clear cos(2x),sin x**2
136	     end;
137      if diffce neq 0
138	then <<write
139       "     ***** DERIVATIVE OF INTEGRAL NOT EQUAL TO INTEGRAND *****";
140	       symbolic(faillist!* := list(a,b,res,der) . faillist!*)>>;
141               symbolic if smemq('int,res)
142                    then unintlist!* := list(a,b,res) . unintlist!*;
143      on precise;
144      return res
145  end;
146
147
148testint
149
150
151symbolic initialize!-integral!-test();
152
153
154
155% References are to Gradshteyn and Ryznik.
156
157testint(1+x+x**2,x);
158
159
160       2
161 x*(2*x  + 3*x + 6)
162--------------------
163         6
164
165testint(x**2*(2*x**2+x)**2,x);
166
167
168  5      2
169 x *(60*x  + 70*x + 21)
170------------------------
171          105
172
173testint(x*(x**2+2*x+1),x);
174
175
176  2     2
177 x *(3*x  + 8*x + 6)
178---------------------
179         12
180
181testint(1/x,x);
182
183
184log(x)
185                 % 2.01 #2
186testint((x+1)**3/(x-1)**4,x);
187
188
189               3                 2                                      3
190 3*log(x - 1)*x  - 9*log(x - 1)*x  + 9*log(x - 1)*x - 3*log(x - 1) - 6*x  - 2
191------------------------------------------------------------------------------
192                               3      2
193                           3*(x  - 3*x  + 3*x - 1)
194
195testint(1/(x*(x-1)*(x+1)**2),x);
196
197
198(log(x - 1)*x + log(x - 1) + 3*log(x + 1)*x + 3*log(x + 1) - 4*log(x)*x
199
200  - 4*log(x) + 2*x)/(4*(x + 1))
201
202testint((a*x+b)/((x-p)*(x-q)),x);
203
204
205 log(p - x)*a*p + log(p - x)*b - log(q - x)*a*q - log(q - x)*b
206---------------------------------------------------------------
207                             p - q
208
209testint(1/(a*x**2+b*x+c),x);
210
211
212                 2           2*a*x + b
213 2*sqrt(4*a*c - b )*atan(------------------)
214                                        2
215                          sqrt(4*a*c - b )
216---------------------------------------------
217                          2
218                 4*a*c - b
219
220testint((a*x+b)/(1+x**2),x);
221
222
223                    2
224 2*atan(x)*b + log(x  + 1)*a
225-----------------------------
226              2
227
228testint(1/(x**2-2*x+3),x);
229
230
231                x - 1
232 sqrt(2)*atan(---------)
233               sqrt(2)
234-------------------------
235            2
236
237
238% Rational function examples from Hardy, Pure Mathematics, p 253 et seq.
239
240testint(1/((x-1)*(x**2+1))**2,x);
241
242
243          3            2                              2       3        2       2
244(atan(x)*x  - atan(x)*x  + atan(x)*x - atan(x) + log(x  + 1)*x  - log(x  + 1)*x
245
246         2               2                      3                 2
247  + log(x  + 1)*x - log(x  + 1) - 2*log(x - 1)*x  + 2*log(x - 1)*x
248
249                                     3                 3    2
250  - 2*log(x - 1)*x + 2*log(x - 1) - x  - 2*x + 1)/(4*(x  - x  + x - 1))
251
252testint(x/((x-a)*(x-b)*(x-c)),x);
253
254
255(log(a - x)*a*b - log(a - x)*a*c - log(b - x)*a*b + log(b - x)*b*c
256
257                                       2      2        2      2    2        2
258  + log(c - x)*a*c - log(c - x)*b*c)/(a *b - a *c - a*b  + a*c  + b *c - b*c )
259
260testint(x/((x**2+a**2)*(x**2+b**2)),x);
261
262
263         2    2         2    2
264  - log(a  + x ) + log(b  + x )
265--------------------------------
266              2    2
267          2*(a  - b )
268
269testint(x**2/((x**2+a**2)*(x**2+b**2)),x);
270
271
272       x             x
273 atan(---)*a - atan(---)*b
274       a             b
275---------------------------
276           2    2
277          a  - b
278
279testint(x/((x-1)*(x**2+1)),x);
280
281
282                  2
283 2*atan(x) - log(x  + 1) + 2*log(x - 1)
284----------------------------------------
285                   4
286
287testint(x/(1+x**3),x);
288
289
290                 2*x - 1          2
291 2*sqrt(3)*atan(---------) + log(x  - x + 1) - 2*log(x + 1)
292                 sqrt(3)
293------------------------------------------------------------
294                             6
295
296testint(x**3/((x-1)**2*(x**3+1)),x);
297
298
299           2                     2
300( - 4*log(x  - x + 1)*x + 4*log(x  - x + 1) + 9*log(x - 1)*x - 9*log(x - 1)
301
302  - log(x + 1)*x + log(x + 1) - 6*x)/(12*(x - 1))
303
304testint(1/(1+x**4),x);
305
306
307                     sqrt(2) - 2*x             sqrt(2) + 2*x
308(sqrt(2)*( - 2*atan(---------------) + 2*atan(---------------)
309                        sqrt(2)                   sqrt(2)
310
311                                 2                         2
312           - log( - sqrt(2)*x + x  + 1) + log(sqrt(2)*x + x  + 1)))/8
313
314testint(x**2/(1+x**4),x);
315
316
317                     sqrt(2) - 2*x             sqrt(2) + 2*x
318(sqrt(2)*( - 2*atan(---------------) + 2*atan(---------------)
319                        sqrt(2)                   sqrt(2)
320
321                                 2                         2
322           + log( - sqrt(2)*x + x  + 1) - log(sqrt(2)*x + x  + 1)))/8
323
324testint(1/(1+x**2+x**4),x);
325
326
327                 2*x - 1                     2*x + 1            2
328(2*sqrt(3)*atan(---------) + 2*sqrt(3)*atan(---------) - 3*log(x  - x + 1)
329                 sqrt(3)                     sqrt(3)
330
331           2
332  + 3*log(x  + x + 1))/12
333
334
335% Examples involving a+b*x.
336
337z := a+b*x;
338
339
340z := a + b*x
341
342
343testint(z**p,x);
344
345
346          p
347 (a + b*x) *(a + b*x)
348----------------------
349      b*(p + 1)
350
351testint(x*z**p,x);
352
353
354          p      2              2    2    2  2
355 (a + b*x) *( - a  + a*b*p*x + b *p*x  + b *x )
356------------------------------------------------
357                2   2
358               b *(p  + 3*p + 2)
359
360testint(x**2*z**p,x);
361
362
363          p
364((a + b*x)
365
366      3      2            2  2  2      2    2    3  2  3      3    3      3  3
367 *(2*a  - 2*a *b*p*x + a*b *p *x  + a*b *p*x  + b *p *x  + 3*b *p*x  + 2*b *x ))
368
369   3   3      2
370/(b *(p  + 6*p  + 11*p + 6))
371
372testint(1/z,x);
373
374
375 log(a + b*x)
376--------------
377      b
378
379testint(1/z**2,x);
380
381
382      x
383-------------
384 a*(a + b*x)
385
386testint(x/z,x);
387
388
389  - log(a + b*x)*a + b*x
390-------------------------
391            2
392           b
393
394testint(x**2/z,x);
395
396
397                 2              2  2
398 2*log(a + b*x)*a  - 2*a*b*x + b *x
399-------------------------------------
400                   3
401                2*b
402
403testint(1/(x*z),x);
404
405
406  - log(a + b*x) + log(x)
407--------------------------
408            a
409
410testint(1/(x**2*z),x);
411
412
413 log(a + b*x)*b*x - log(x)*b*x - a
414-----------------------------------
415                2
416               a *x
417
418testint(1/(x*z)**2,x);
419
420
421                                        2  2                              2  2
422(2*log(a + b*x)*a*b*x + 2*log(a + b*x)*b *x  - 2*log(x)*a*b*x - 2*log(x)*b *x
423
424     2      2  2    3
425  - a  + 2*b *x )/(a *x*(a + b*x))
426
427testint(1/(c**2+x**2),x);
428
429
430       x
431 atan(---)
432       c
433-----------
434     c
435
436testint(1/(c**2-x**2),x);
437
438
439 log( - c - x) - log(c - x)
440----------------------------
441            2*c
442
443
444% More complicated rational function examples, mostly contributed
445% by David M. Dahm, who also developed the code to integrate them.
446
447testint(1/(2*x**3-1),x);
448
449
450                             1/3
451  2/3                     2*2   *x + 1          2/3  2    1/3
452(2   *( - 2*sqrt(3)*atan(--------------) - log(2   *x  + 2   *x + 1)
453                            sqrt(3)
454
455                 1/3
456        + 2*log(2   *x - 1)))/12
457
458testint(1/(x**3-2),x);
459
460
461                            1/3
462  1/3                      2    + 2*x           2/3    1/3      2
463(2   *( - 2*sqrt(3)*atan(--------------) - log(2    + 2   *x + x )
464                           1/3
465                          2   *sqrt(3)
466
467                    1/3
468        + 2*log( - 2    + x)))/12
469
470testint(1/(a*x**3-b),x);
471
472
473                             1/3      1/3
474  1/3                     2*a   *x + b             2/3  2    1/3  1/3      2/3
475(b   *( - 2*sqrt(3)*atan(-----------------) - log(a   *x  + b   *a   *x + b   )
476                            1/3
477                           b   *sqrt(3)
478
479                 1/3      1/3        1/3
480        + 2*log(a   *x - b   )))/(6*a   *b)
481
482testint(1/(x**4-2),x);
483
484
485  1/4              x            1/4                1/4
486 2   *( - 2*atan(------) - log(2    + x) + log( - 2    + x))
487                   1/4
488                  2
489-------------------------------------------------------------
490                              8
491
492testint(1/(5*x**4-1),x);
493
494
495          1/4             sqrt(5)*x          1/4               1/4
496 sqrt(5)*5   *( - 2*atan(-----------) + log(5   *x - 1) - log(5   *x + 1))
497                             1/4
498                            5
499---------------------------------------------------------------------------
500                                    20
501
502testint(1/(3*x**4+7),x);
503
504
505                                     1/4
506           1/4             sqrt(2)*21    - 2*sqrt(3)*x
507(sqrt(6)*21   *( - 2*atan(-----------------------------)
508                                            1/4
509                                  sqrt(2)*21
510
511                                     1/4
512                           sqrt(2)*21    + 2*sqrt(3)*x
513                 + 2*atan(-----------------------------)
514                                            1/4
515                                  sqrt(2)*21
516
517                                    1/4                        2
518                 - log( - sqrt(2)*21   *x + sqrt(7) + sqrt(3)*x )
519
520                                 1/4                        2
521                 + log(sqrt(2)*21   *x + sqrt(7) + sqrt(3)*x )))/168
522
523testint(1/(x**4+3*x**2-1),x);
524
525
526                                                         2*x
527(sqrt(2)*(6*sqrt(sqrt(13) + 3)*sqrt(13)*atan(----------------------------)
528                                              sqrt(sqrt(13) + 3)*sqrt(2)
529
530                                                    2*x
531           - 26*sqrt(sqrt(13) + 3)*atan(----------------------------) + 3
532                                         sqrt(sqrt(13) + 3)*sqrt(2)
533
534          *sqrt(sqrt(13) - 3)*sqrt(13)*log( - sqrt(sqrt(13) - 3) + sqrt(2)*x)
535
536           - 3*sqrt(sqrt(13) - 3)*sqrt(13)*log(sqrt(sqrt(13) - 3) + sqrt(2)*x)
537
538           + 13*sqrt(sqrt(13) - 3)*log( - sqrt(sqrt(13) - 3) + sqrt(2)*x)
539
540           - 13*sqrt(sqrt(13) - 3)*log(sqrt(sqrt(13) - 3) + sqrt(2)*x)))/104
541
542testint(1/(x**4-3*x**2-1),x);
543
544
545                                                            2*x
546(sqrt(2)*( - 6*sqrt(sqrt(13) - 3)*sqrt(13)*atan(----------------------------)
547                                                 sqrt(sqrt(13) - 3)*sqrt(2)
548
549                                                    2*x
550           - 26*sqrt(sqrt(13) - 3)*atan(----------------------------) - 3
551                                         sqrt(sqrt(13) - 3)*sqrt(2)
552
553          *sqrt(sqrt(13) + 3)*sqrt(13)*log( - sqrt(sqrt(13) + 3) + sqrt(2)*x)
554
555           + 3*sqrt(sqrt(13) + 3)*sqrt(13)*log(sqrt(sqrt(13) + 3) + sqrt(2)*x)
556
557           + 13*sqrt(sqrt(13) + 3)*log( - sqrt(sqrt(13) + 3) + sqrt(2)*x)
558
559           - 13*sqrt(sqrt(13) + 3)*log(sqrt(sqrt(13) + 3) + sqrt(2)*x)))/104
560
561testint(1/(x**4-3*x**2+1),x);
562
563
564( - sqrt(5)*log( - sqrt(5) + 2*x - 1) - sqrt(5)*log( - sqrt(5) + 2*x + 1)
565
566  + sqrt(5)*log(sqrt(5) + 2*x - 1) + sqrt(5)*log(sqrt(5) + 2*x + 1)
567
568  + 5*log( - sqrt(5) + 2*x - 1) - 5*log( - sqrt(5) + 2*x + 1)
569
570  + 5*log(sqrt(5) + 2*x - 1) - 5*log(sqrt(5) + 2*x + 1))/20
571
572testint(1/(x**4-4*x**2+1),x);
573
574
575                                  2*x                            2*x
576(sqrt(2)*(2*sqrt(3)*atanh(-------------------) + 6*atanh(-------------------)
577                           sqrt(6) - sqrt(2)              sqrt(6) - sqrt(2)
578
579                           - sqrt(6) - sqrt(2) + 2*x
580           - sqrt(3)*log(----------------------------)
581                                      2
582
583                          sqrt(6) + sqrt(2) + 2*x
584           + sqrt(3)*log(-------------------------)
585                                     2
586
587                     - sqrt(6) - sqrt(2) + 2*x
588           + 3*log(----------------------------)
589                                2
590
591                    sqrt(6) + sqrt(2) + 2*x
592           - 3*log(-------------------------)))/24
593                               2
594
595testint(1/(x**4+4*x**2+1),x);
596
597
598                                 2*x                           2*x
599(sqrt(2)*(2*sqrt(3)*atan(-------------------) - 6*atan(-------------------)
600                          sqrt(6) + sqrt(2)             sqrt(6) + sqrt(2)
601
602                           - sqrt(6)*i + sqrt(2)*i + 2*x
603           - sqrt(3)*log(--------------------------------)*i
604                                        2
605
606                          sqrt(6)*i - sqrt(2)*i + 2*x
607           + sqrt(3)*log(-----------------------------)*i
608                                       2
609
610                     - sqrt(6)*i + sqrt(2)*i + 2*x
611           - 3*log(--------------------------------)*i
612                                  2
613
614                    sqrt(6)*i - sqrt(2)*i + 2*x
615           + 3*log(-----------------------------)*i))/24
616                                 2
617
618testint(1/(x**4+x**2+2),x);
619
620
621                                     sqrt(2*sqrt(2) - 1) - 2*x
622(2*sqrt(2*sqrt(2) + 1)*sqrt(2)*atan(---------------------------)
623                                        sqrt(2*sqrt(2) + 1)
624
625                                sqrt(2*sqrt(2) - 1) - 2*x
626  - 8*sqrt(2*sqrt(2) + 1)*atan(---------------------------)
627                                   sqrt(2*sqrt(2) + 1)
628
629                                        sqrt(2*sqrt(2) - 1) + 2*x
630  - 2*sqrt(2*sqrt(2) + 1)*sqrt(2)*atan(---------------------------)
631                                           sqrt(2*sqrt(2) + 1)
632
633                                sqrt(2*sqrt(2) - 1) + 2*x
634  + 8*sqrt(2*sqrt(2) + 1)*atan(---------------------------)
635                                   sqrt(2*sqrt(2) + 1)
636
637                                                                          2
638  - sqrt(2*sqrt(2) - 1)*sqrt(2)*log( - sqrt(2*sqrt(2) - 1)*x + sqrt(2) + x )
639
640                                                                       2
641  + sqrt(2*sqrt(2) - 1)*sqrt(2)*log(sqrt(2*sqrt(2) - 1)*x + sqrt(2) + x )
642
643                                                                    2
644  - 4*sqrt(2*sqrt(2) - 1)*log( - sqrt(2*sqrt(2) - 1)*x + sqrt(2) + x )
645
646                                                                 2
647  + 4*sqrt(2*sqrt(2) - 1)*log(sqrt(2*sqrt(2) - 1)*x + sqrt(2) + x ))/56
648
649testint(1/(x**4-x**2+2),x);
650
651
652                                        sqrt(2*sqrt(2) + 1) - 2*x
653( - 2*sqrt(2*sqrt(2) - 1)*sqrt(2)*atan(---------------------------)
654                                           sqrt(2*sqrt(2) - 1)
655
656                                sqrt(2*sqrt(2) + 1) - 2*x
657  - 8*sqrt(2*sqrt(2) - 1)*atan(---------------------------)
658                                   sqrt(2*sqrt(2) - 1)
659
660                                        sqrt(2*sqrt(2) + 1) + 2*x
661  + 2*sqrt(2*sqrt(2) - 1)*sqrt(2)*atan(---------------------------)
662                                           sqrt(2*sqrt(2) - 1)
663
664                                sqrt(2*sqrt(2) + 1) + 2*x
665  + 8*sqrt(2*sqrt(2) - 1)*atan(---------------------------)
666                                   sqrt(2*sqrt(2) - 1)
667
668                                                                          2
669  + sqrt(2*sqrt(2) + 1)*sqrt(2)*log( - sqrt(2*sqrt(2) + 1)*x + sqrt(2) + x )
670
671                                                                       2
672  - sqrt(2*sqrt(2) + 1)*sqrt(2)*log(sqrt(2*sqrt(2) + 1)*x + sqrt(2) + x )
673
674                                                                    2
675  - 4*sqrt(2*sqrt(2) + 1)*log( - sqrt(2*sqrt(2) + 1)*x + sqrt(2) + x )
676
677                                                                 2
678  + 4*sqrt(2*sqrt(2) + 1)*log(sqrt(2*sqrt(2) + 1)*x + sqrt(2) + x ))/56
679
680testint(1/(x**6-1),x);
681
682
683                    2*x - 1                     2*x + 1          2
684( - 2*sqrt(3)*atan(---------) - 2*sqrt(3)*atan(---------) + log(x  - x + 1)
685                    sqrt(3)                     sqrt(3)
686
687         2
688  - log(x  + x + 1) + 2*log(x - 1) - 2*log(x + 1))/12
689
690testint(1/(x**6-2),x);
691
692
693                         1/6                              1/6
694  1/6                   2    - 2*x                       2    + 2*x
695(2   *(2*sqrt(3)*atan(--------------) - 2*sqrt(3)*atan(--------------)
696                        1/6                              1/6
697                       2   *sqrt(3)                     2   *sqrt(3)
698
699                 1/6                  1/6                1/6      1/3    2
700        - 2*log(2    + x) + 2*log( - 2    + x) + log( - 2   *x + 2    + x )
701
702               1/6      1/3    2
703        - log(2   *x + 2    + x )))/24
704
705testint(1/(x**6+2),x);
706
707
708                   1/6                            1/6
709  1/6             2   *sqrt(3) - 2*x             2   *sqrt(3) + 2*x
710(2   *( - 2*atan(--------------------) + 2*atan(--------------------)
711                          1/6                            1/6
712                         2                              2
713
714                   x                       1/6              1/3    2
715        + 4*atan(------) - sqrt(3)*log( - 2   *sqrt(3)*x + 2    + x )
716                   1/6
717                  2
718
719                       1/6              1/3    2
720        + sqrt(3)*log(2   *sqrt(3)*x + 2    + x )))/24
721
722testint(1/(x**8+1),x);
723
724
725                              sqrt( - sqrt(2) + 2) - 2*x
726( - 2*sqrt(sqrt(2) + 2)*atan(----------------------------)
727                                  sqrt(sqrt(2) + 2)
728
729                              sqrt( - sqrt(2) + 2) + 2*x
730  + 2*sqrt(sqrt(2) + 2)*atan(----------------------------)
731                                  sqrt(sqrt(2) + 2)
732
733                                 sqrt(sqrt(2) + 2) - 2*x
734  - 2*sqrt( - sqrt(2) + 2)*atan(-------------------------)
735                                  sqrt( - sqrt(2) + 2)
736
737                                 sqrt(sqrt(2) + 2) + 2*x
738  + 2*sqrt( - sqrt(2) + 2)*atan(-------------------------)
739                                  sqrt( - sqrt(2) + 2)
740
741                                                          2
742  - sqrt( - sqrt(2) + 2)*log( - sqrt( - sqrt(2) + 2)*x + x  + 1)
743
744                                                       2
745  + sqrt( - sqrt(2) + 2)*log(sqrt( - sqrt(2) + 2)*x + x  + 1)
746
747                                                    2
748  - sqrt(sqrt(2) + 2)*log( - sqrt(sqrt(2) + 2)*x + x  + 1)
749
750                                                 2
751  + sqrt(sqrt(2) + 2)*log(sqrt(sqrt(2) + 2)*x + x  + 1))/16
752
753testint(1/(x**8-1),x);
754
755
756                 sqrt(2) - 2*x                     sqrt(2) + 2*x
757(2*sqrt(2)*atan(---------------) - 2*sqrt(2)*atan(---------------) - 4*atan(x)
758                    sqrt(2)                           sqrt(2)
759
760                                2                                 2
761  + sqrt(2)*log( - sqrt(2)*x + x  + 1) - sqrt(2)*log(sqrt(2)*x + x  + 1)
762
763  + 2*log(x - 1) - 2*log(x + 1))/16
764
765testint(1/(x**8-x**4+1),x);
766
767
768                                         sqrt(6) + sqrt(2) - 4*x
769( - 2*sqrt( - sqrt(3) + 2)*sqrt(3)*atan(-------------------------)
770                                         2*sqrt( - sqrt(3) + 2)
771
772                                 sqrt(6) + sqrt(2) - 4*x
773  - 6*sqrt( - sqrt(3) + 2)*atan(-------------------------)
774                                 2*sqrt( - sqrt(3) + 2)
775
776                                         sqrt(6) + sqrt(2) + 4*x
777  + 2*sqrt( - sqrt(3) + 2)*sqrt(3)*atan(-------------------------)
778                                         2*sqrt( - sqrt(3) + 2)
779
780                                 sqrt(6) + sqrt(2) + 4*x
781  + 6*sqrt( - sqrt(3) + 2)*atan(-------------------------)
782                                 2*sqrt( - sqrt(3) + 2)
783
784                    2*sqrt( - sqrt(3) + 2) - 4*x
785  - 2*sqrt(6)*atan(------------------------------)
786                         sqrt(6) + sqrt(2)
787
788                    2*sqrt( - sqrt(3) + 2) + 4*x
789  + 2*sqrt(6)*atan(------------------------------)
790                         sqrt(6) + sqrt(2)
791
792                                                                  2
793  - sqrt( - sqrt(3) + 2)*sqrt(3)*log( - sqrt( - sqrt(3) + 2)*x + x  + 1)
794
795                                                               2
796  + sqrt( - sqrt(3) + 2)*sqrt(3)*log(sqrt( - sqrt(3) + 2)*x + x  + 1)
797
798                                                            2
799  - 3*sqrt( - sqrt(3) + 2)*log( - sqrt( - sqrt(3) + 2)*x + x  + 1)
800
801                                                         2
802  + 3*sqrt( - sqrt(3) + 2)*log(sqrt( - sqrt(3) + 2)*x + x  + 1)
803
804                                               2
805                  - sqrt(6)*x - sqrt(2)*x + 2*x  + 2
806  - sqrt(6)*log(-------------------------------------)
807                                  2
808
809                                            2
810                 sqrt(6)*x + sqrt(2)*x + 2*x  + 2
811  + sqrt(6)*log(----------------------------------))/24
812                                2
813
814testint(x**7/(x**12+1),x);
815
816
817                                       sqrt(6) + sqrt(2) - 4*x
818( - sqrt( - sqrt(3) + 2)*sqrt(6)*atan(-------------------------)
819                                       2*sqrt( - sqrt(3) + 2)
820
821                                         sqrt(6) + sqrt(2) - 4*x
822  - 3*sqrt( - sqrt(3) + 2)*sqrt(2)*atan(-------------------------)
823                                         2*sqrt( - sqrt(3) + 2)
824
825                                       sqrt(6) + sqrt(2) + 4*x
826  - sqrt( - sqrt(3) + 2)*sqrt(6)*atan(-------------------------)
827                                       2*sqrt( - sqrt(3) + 2)
828
829                                         sqrt(6) + sqrt(2) + 4*x
830  - 3*sqrt( - sqrt(3) + 2)*sqrt(2)*atan(-------------------------)
831                                         2*sqrt( - sqrt(3) + 2)
832
833                                       2*sqrt( - sqrt(3) + 2) - 4*x
834  + sqrt( - sqrt(3) + 2)*sqrt(6)*atan(------------------------------)
835                                            sqrt(6) + sqrt(2)
836
837                                         2*sqrt( - sqrt(3) + 2) - 4*x
838  + 3*sqrt( - sqrt(3) + 2)*sqrt(2)*atan(------------------------------)
839                                              sqrt(6) + sqrt(2)
840
841                                       2*sqrt( - sqrt(3) + 2) + 4*x
842  + sqrt( - sqrt(3) + 2)*sqrt(6)*atan(------------------------------)
843                                            sqrt(6) + sqrt(2)
844
845                                         2*sqrt( - sqrt(3) + 2) + 4*x
846  + 3*sqrt( - sqrt(3) + 2)*sqrt(2)*atan(------------------------------)
847                                              sqrt(6) + sqrt(2)
848
849                                     2                              2
850  + log( - sqrt( - sqrt(3) + 2)*x + x  + 1) - 2*log( - sqrt(2)*x + x  + 1)
851
852                                  2                           2
853  + log(sqrt( - sqrt(3) + 2)*x + x  + 1) - 2*log(sqrt(2)*x + x  + 1)
854
855                                       2
856          - sqrt(6)*x - sqrt(2)*x + 2*x  + 2
857  + log(-------------------------------------)
858                          2
859
860                                    2
861         sqrt(6)*x + sqrt(2)*x + 2*x  + 2
862  + log(----------------------------------))/24
863                        2
864
865
866% Examples involving logarithms.
867
868testint(log x,x);
869
870
871x*(log(x) - 1)
872
873testint(x*log x,x);
874
875
876  2
877 x *(2*log(x) - 1)
878-------------------
879         4
880
881testint(x**2*log x,x);
882
883
884  3
885 x *(3*log(x) - 1)
886-------------------
887         9
888
889testint(x**p*log x,x);
890
891
892  p
893 x *x*(log(x)*p + log(x) - 1)
894------------------------------
895          2
896         p  + 2*p + 1
897
898testint((log x)**2,x);
899
900
901         2
902x*(log(x)  - 2*log(x) + 2)
903
904testint(x**9*log x**11,x);
905
906
907  10                 11                  10                  9
908(x  *(15625000*log(x)   - 17187500*log(x)   + 17187500*log(x)
909
910                        8                  7                 6                 5
911       - 15468750*log(x)  + 12375000*log(x)  - 8662500*log(x)  + 5197500*log(x)
912
913                       4                 3                2
914       - 2598750*log(x)  + 1039500*log(x)  - 311850*log(x)  + 62370*log(x)
915
916       - 6237))/156250000
917
918testint(log x**2/x,x);
919
920
921       3
922 log(x)
923---------
924    3
925
926testint(1/log x,x);
927
928
929ei(log(x))
930
931testint(1/log(x+1),x);
932
933
934ei(log(x + 1))
935
936testint(1/(x*log x),x);
937
938
939log(log(x))
940
941testint(1/(x*log x)**2,x);
942
943
944  - (ei( - log(x))*log(x)*x + 1)
945---------------------------------
946            log(x)*x
947
948testint((log x)**p/x,x);
949
950
951       p
952 log(x) *log(x)
953----------------
954     p + 1
955
956testint(log x *(a*x+b),x);
957
958
959 x*(2*log(x)*a*x + 4*log(x)*b - a*x - 4*b)
960-------------------------------------------
961                     4
962
963testint((a*x+b)**2*log x,x);
964
965
966              2  2                                2      2  2                 2
967(x*(6*log(x)*a *x  + 18*log(x)*a*b*x + 18*log(x)*b  - 2*a *x  - 9*a*b*x - 18*b )
968
969 )/18
970
971testint(log x/(a*x+b)**2,x);
972
973
974  - log(a*x + b)*a*x - log(a*x + b)*b + log(x)*a*x
975---------------------------------------------------
976                   a*b*(a*x + b)
977
978testint(x*log (a*x+b),x);
979
980
981                 2  2                   2    2  2
982 2*log(a*x + b)*a *x  - 2*log(a*x + b)*b  - a *x  + 2*a*b*x
983------------------------------------------------------------
984                               2
985                            4*a
986
987testint(x**2*log(a*x+b),x);
988
989
990                 3  3                   3      3  3      2    2        2
991 6*log(a*x + b)*a *x  + 6*log(a*x + b)*b  - 2*a *x  + 3*a *b*x  - 6*a*b *x
992---------------------------------------------------------------------------
993                                       3
994                                   18*a
995
996testint(log(x**2+a**2),x);
997
998
999        x            2    2
10002*atan(---)*a + log(a  + x )*x - 2*x
1001        a
1002
1003testint(x*log(x**2+a**2),x);
1004
1005
1006      2    2   2        2    2   2    2
1007 log(a  + x )*a  + log(a  + x )*x  - x
1008----------------------------------------
1009                   2
1010
1011testint(x**2*log(x**2+a**2),x);
1012
1013
1014            x    3          2    2   3      2        3
1015  - 6*atan(---)*a  + 3*log(a  + x )*x  + 6*a *x - 2*x
1016            a
1017-------------------------------------------------------
1018                           9
1019
1020testint(x**4*log(x**2+a**2),x);
1021
1022
1023          x    5           2    2   5       4         2  3      5
1024 30*atan(---)*a  + 15*log(a  + x )*x  - 30*a *x + 10*a *x  - 6*x
1025          a
1026------------------------------------------------------------------
1027                                75
1028
1029testint(log(x**2-a**2),x);
1030
1031
1032           2    2              2    2
1033 - log( - a  + x )*a + log( - a  + x )*x + 2*log( - a - x)*a - 2*x
1034
1035testint(log(log(log(log(x)))),x);
1036
1037
1038                         1
1039 - int(-------------------------------------,x) + log(log(log(log(x))))*x
1040        log(log(log(x)))*log(log(x))*log(x)
1041
1042
1043% Examples involving circular functions.
1044
1045testint(sin x,x);
1046
1047
1048 - cos(x)
1049                 % 2.01 #5
1050testint(cos x,x);
1051
1052
1053sin(x)
1054                 %     #6
1055testint(tan x,x);
1056
1057
1058           2
1059 log(tan(x)  + 1)
1060------------------
1061        2
1062                 %     #11
1063testint(1/tan(x),x);
1064
1065
1066              2
1067  - log(tan(x)  + 1) + 2*log(tan(x))
1068-------------------------------------
1069                  2
1070              % 2.01 #12
1071testint(1/(1+tan(x))**2,x);
1072
1073
1074              2                         2
1075( - log(tan(x)  + 1)*tan(x) - log(tan(x)  + 1) + 2*log(tan(x) + 1)*tan(x)
1076
1077  + 2*log(tan(x) + 1) + 2*tan(x))/(4*(tan(x) + 1))
1078
1079testint(1/cos x,x);
1080
1081
1082            x                   x
1083 - log(tan(---) - 1) + log(tan(---) + 1)
1084            2                   2
1085
1086testint(1/sin x,x);
1087
1088
1089         x
1090log(tan(---))
1091         2
1092
1093testint(sin x**2,x);
1094
1095
1096  - cos(x)*sin(x) + x
1097----------------------
1098          2
1099
1100testint(x**3*sin(x**2),x);
1101
1102
1103         2   2        2
1104  - cos(x )*x  + sin(x )
1105-------------------------
1106            2
1107
1108testint(sin x**3,x);
1109
1110
1111                 2
1112  - cos(x)*sin(x)  - 2*cos(x) + 2
1113----------------------------------
1114                3
1115
1116testint(sin x**p,x);
1117
1118
1119          p
1120int(sin(x) ,x)
1121
1122testint((sin x**2+1)**2*cos x,x);
1123
1124
1125                 4            2
1126 sin(x)*(3*sin(x)  + 10*sin(x)  + 15)
1127--------------------------------------
1128                  15
1129
1130testint(cos x**2,x);
1131
1132
1133 cos(x)*sin(x) + x
1134-------------------
1135         2
1136
1137testint(cos x**3,x);
1138
1139
1140                  2
1141 sin(x)*( - sin(x)  + 3)
1142-------------------------
1143            3
1144
1145testint(sin(a*x+b),x);
1146
1147
1148  - cos(a*x + b)
1149-----------------
1150        a
1151
1152testint(1/cos x**2,x);
1153
1154
1155 sin(x)
1156--------
1157 cos(x)
1158
1159testint(sin x*sin(2*x),x);
1160
1161
1162  - 2*cos(2*x)*sin(x) + cos(x)*sin(2*x)
1163----------------------------------------
1164                   3
1165
1166testint(x*sin x,x);
1167
1168
1169 - cos(x)*x + sin(x)
1170
1171testint(x**2*sin x,x);
1172
1173
1174           2
1175 - cos(x)*x  + 2*cos(x) + 2*sin(x)*x
1176
1177testint(x*sin x**2,x);
1178
1179
1180                              2    2
1181  - 2*cos(x)*sin(x)*x + sin(x)  + x  - 2
1182-----------------------------------------
1183                    4
1184
1185testint(x**2*sin x**2,x);
1186
1187
1188                     2                             2        3
1189  - 6*cos(x)*sin(x)*x  + 3*cos(x)*sin(x) + 6*sin(x) *x + 2*x  - 3*x
1190--------------------------------------------------------------------
1191                                 12
1192
1193testint(x*sin x**3,x);
1194
1195
1196                   2                        3
1197  - 3*cos(x)*sin(x) *x - 6*cos(x)*x + sin(x)  + 6*sin(x)
1198---------------------------------------------------------
1199                            9
1200
1201testint(x*cos x,x);
1202
1203
1204cos(x) + sin(x)*x
1205
1206testint(x**2*cos x,x);
1207
1208
1209                     2
12102*cos(x)*x + sin(x)*x  - 2*sin(x)
1211
1212testint(x*cos x**2,x);
1213
1214
1215                           2    2
1216 2*cos(x)*sin(x)*x - sin(x)  + x  + 2
1217--------------------------------------
1218                  4
1219
1220testint(x**2*cos x**2,x);
1221
1222
1223                  2                             2        3
1224 6*cos(x)*sin(x)*x  - 3*cos(x)*sin(x) - 6*sin(x) *x + 2*x  + 3*x
1225-----------------------------------------------------------------
1226                               12
1227
1228testint(x*cos x**3,x);
1229
1230
1231                 2                      3
1232  - cos(x)*sin(x)  + 7*cos(x) - 3*sin(x) *x + 9*sin(x)*x + 1
1233-------------------------------------------------------------
1234                              9
1235
1236testint(sin x/x,x);
1237
1238
1239si(x)
1240
1241testint(cos x/x,x);
1242
1243
1244ci(x)
1245
1246testint(sin x/x**2,x);
1247
1248
1249 ci(x)*x - sin(x)
1250------------------
1251        x
1252
1253testint(sin x**2/x,x);
1254
1255
1256  - ci(2*x) + log(x)
1257---------------------
1258          2
1259
1260testint(tan x**3,x);
1261
1262
1263              2              2
1264  - log(tan(x)  + 1) + tan(x)
1265-------------------------------
1266               2
1267
1268% z := a+b*x;
1269testint(sin z,x);
1270
1271
1272  - cos(a + b*x)
1273-----------------
1274        b
1275
1276testint(cos z,x);
1277
1278
1279 sin(a + b*x)
1280--------------
1281      b
1282
1283testint(tan z,x);
1284
1285
1286                 2
1287 log(tan(a + b*x)  + 1)
1288------------------------
1289          2*b
1290
1291testint(1/tan z,x);
1292
1293
1294                    2
1295  - log(tan(a + b*x)  + 1) + 2*log(tan(a + b*x))
1296-------------------------------------------------
1297                       2*b
1298
1299testint(1/sin z,x);
1300
1301
1302          a + b*x
1303 log(tan(---------))
1304             2
1305---------------------
1306          b
1307
1308testint(1/cos z,x);
1309
1310
1311             a + b*x                   a + b*x
1312  - log(tan(---------) - 1) + log(tan(---------) + 1)
1313                2                         2
1314------------------------------------------------------
1315                          b
1316
1317testint(sin z**2,x);
1318
1319
1320  - cos(a + b*x)*sin(a + b*x) + b*x
1321------------------------------------
1322                2*b
1323
1324testint(sin z**3,x);
1325
1326
1327                             2
1328  - cos(a + b*x)*sin(a + b*x)  - 2*cos(a + b*x) + 2
1329----------------------------------------------------
1330                        3*b
1331
1332testint(cos z**2,x);
1333
1334
1335 cos(a + b*x)*sin(a + b*x) + b*x
1336---------------------------------
1337               2*b
1338
1339testint(cos z**3,x);
1340
1341
1342                              2
1343 sin(a + b*x)*( - sin(a + b*x)  + 3)
1344-------------------------------------
1345                 3*b
1346
1347testint(1/cos z**2,x);
1348
1349
1350  sin(a + b*x)
1351----------------
1352 cos(a + b*x)*b
1353
1354testint(1/(1+cos x),x);
1355
1356
1357     x
1358tan(---)
1359     2
1360
1361testint(1/(1-cos x),x);
1362
1363
1364    - 1
1365----------
1366      x
1367 tan(---)
1368      2
1369
1370testint(1/(1+sin x),x);
1371
1372
1373         x
1374  2*tan(---)
1375         2
1376--------------
1377      x
1378 tan(---) + 1
1379      2
1380
1381testint(1/(1-sin x),x);
1382
1383
1384           x
1385  - 2*tan(---)
1386           2
1387---------------
1388      x
1389 tan(---) - 1
1390      2
1391
1392testint(1/(a+b*sin x),x);
1393
1394
1395                            x
1396                       tan(---)*a + b
1397         2    2             2
1398 2*sqrt(a  - b )*atan(----------------)
1399                             2    2
1400                       sqrt(a  - b )
1401----------------------------------------
1402                 2    2
1403                a  - b
1404
1405testint(1/(a+b*sin x+cos x),x);
1406
1407
1408                                x            x
1409                           tan(---)*a - tan(---) + b
1410         2    2                 2            2
1411 2*sqrt(a  - b  - 1)*atan(---------------------------)
1412                                     2    2
1413                               sqrt(a  - b  - 1)
1414-------------------------------------------------------
1415                       2    2
1416                      a  - b  - 1
1417
1418testint(x**2*sin z**2,x);
1419
1420
1421                                 2  2
1422( - 6*cos(a + b*x)*sin(a + b*x)*b *x  + 3*cos(a + b*x)*sin(a + b*x)
1423
1424                  2                3  3               3
1425  + 6*sin(a + b*x) *b*x + 9*a + 2*b *x  - 3*b*x)/(12*b )
1426
1427testint(cos x*cos(2*x),x);
1428
1429
1430  - cos(2*x)*sin(x) + 2*cos(x)*sin(2*x)
1431----------------------------------------
1432                   3
1433
1434testint(x**2*cos z**2,x);
1435
1436
1437                              2  2
1438(6*cos(a + b*x)*sin(a + b*x)*b *x  - 3*cos(a + b*x)*sin(a + b*x)
1439
1440                  2          3  3               3
1441  - 6*sin(a + b*x) *b*x + 2*b *x  + 3*b*x)/(12*b )
1442
1443testint(1/tan x**3,x);
1444
1445
1446           2            2                       2
1447 log(tan(x)  + 1)*tan(x)  - 2*log(tan(x))*tan(x)  - 1
1448------------------------------------------------------
1449                              2
1450                      2*tan(x)
1451
1452testint(x**3*tan(x)**4,x);
1453
1454
1455                2                  2                3  3           2  2
1456(48*int(tan(x)*x ,x) - 6*log(tan(x)  + 1) + 4*tan(x) *x  - 6*tan(x) *x
1457
1458               3                    4      2
1459  - 12*tan(x)*x  + 12*tan(x)*x + 3*x  - 6*x )/12
1460
1461testint(x**3*tan(x)**6,x);
1462
1463
1464                    2                   2                 5  3           4  2
1465( - 276*int(tan(x)*x ,x) + 60*log(tan(x)  + 1) + 12*tan(x) *x  - 9*tan(x) *x
1466
1467             3  3           3              2  2           2              3
1468  - 20*tan(x) *x  + 6*tan(x) *x + 48*tan(x) *x  - 3*tan(x)  + 60*tan(x)*x
1469
1470                       4       2
1471  - 114*tan(x)*x - 15*x  + 57*x )/60
1472
1473testint(x*tan(x)**2,x);
1474
1475
1476              2                      2
1477  - log(tan(x)  + 1) + 2*tan(x)*x - x
1478---------------------------------------
1479                   2
1480
1481testint(sin(2*x)*cos(3*x),x);
1482
1483
1484 2*cos(3*x)*cos(2*x) + 3*sin(3*x)*sin(2*x)
1485-------------------------------------------
1486                     5
1487
1488testint(sin x**2*cos x**2,x);
1489
1490
1491                3
1492 2*cos(x)*sin(x)  - cos(x)*sin(x) + x
1493--------------------------------------
1494                  8
1495
1496testint(1/(sin x**2*cos x**2),x);
1497
1498
1499         2
1500 2*sin(x)  - 1
1501---------------
1502 cos(x)*sin(x)
1503
1504testint(d**x*sin x,x);
1505
1506
1507  x
1508 d *( - cos(x) + log(d)*sin(x))
1509--------------------------------
1510                2
1511          log(d)  + 1
1512
1513testint(d**x*cos x,x);
1514
1515
1516  x
1517 d *(cos(x)*log(d) + sin(x))
1518-----------------------------
1519               2
1520         log(d)  + 1
1521
1522testint(x*d**x*sin x,x);
1523
1524
1525  x                  2                                        3
1526(d *( - cos(x)*log(d) *x + 2*cos(x)*log(d) - cos(x)*x + log(d) *sin(x)*x
1527
1528              2                                            4           2
1529      - log(d) *sin(x) + log(d)*sin(x)*x + sin(x)))/(log(d)  + 2*log(d)  + 1)
1530
1531testint(x*d**x*cos x,x);
1532
1533
1534  x               3                  2
1535(d *(cos(x)*log(d) *x - cos(x)*log(d)  + cos(x)*log(d)*x + cos(x)
1536
1537              2                                                4           2
1538      + log(d) *sin(x)*x - 2*log(d)*sin(x) + sin(x)*x))/(log(d)  + 2*log(d)  + 1
1539
1540   )
1541
1542testint(x**2*d**x*sin x,x);
1543
1544
1545  x                  4  2                  3                    2  2
1546(d *( - cos(x)*log(d) *x  + 4*cos(x)*log(d) *x - 2*cos(x)*log(d) *x
1547
1548                       2                               2
1549      - 6*cos(x)*log(d)  + 4*cos(x)*log(d)*x - cos(x)*x  + 2*cos(x)
1550
1551              5         2           4                    3         2
1552      + log(d) *sin(x)*x  - 2*log(d) *sin(x)*x + 2*log(d) *sin(x)*x
1553
1554                3                         2
1555      + 2*log(d) *sin(x) + log(d)*sin(x)*x  - 6*log(d)*sin(x) + 2*sin(x)*x))/(
1556
1557         6           4           2
1558   log(d)  + 3*log(d)  + 3*log(d)  + 1)
1559
1560testint(x**2*d**x*cos x,x);
1561
1562
1563  x               5  2                  4                    3  2
1564(d *(cos(x)*log(d) *x  - 2*cos(x)*log(d) *x + 2*cos(x)*log(d) *x
1565
1566                       3                  2
1567      + 2*cos(x)*log(d)  + cos(x)*log(d)*x  - 6*cos(x)*log(d) + 2*cos(x)*x
1568
1569              4         2           3                    2         2
1570      + log(d) *sin(x)*x  - 4*log(d) *sin(x)*x + 2*log(d) *sin(x)*x
1571
1572                2                                      2                     6
1573      + 6*log(d) *sin(x) - 4*log(d)*sin(x)*x + sin(x)*x  - 2*sin(x)))/(log(d)
1574
1575              4           2
1576    + 3*log(d)  + 3*log(d)  + 1)
1577
1578testint(x**3*d**x*sin x,x);
1579
1580
1581  x                  6  3                  5  2                  4  3
1582(d *( - cos(x)*log(d) *x  + 6*cos(x)*log(d) *x  - 3*cos(x)*log(d) *x
1583
1584                        4                     3  2                   3
1585      - 18*cos(x)*log(d) *x + 12*cos(x)*log(d) *x  + 24*cos(x)*log(d)
1586
1587                       2  3                   2                      2
1588      - 3*cos(x)*log(d) *x  - 12*cos(x)*log(d) *x + 6*cos(x)*log(d)*x
1589
1590                                   3                      7         3
1591      - 24*cos(x)*log(d) - cos(x)*x  + 6*cos(x)*x + log(d) *sin(x)*x
1592
1593                6         2           5         3           5
1594      - 3*log(d) *sin(x)*x  + 3*log(d) *sin(x)*x  + 6*log(d) *sin(x)*x
1595
1596                4         2           4                  3         3
1597      - 3*log(d) *sin(x)*x  - 6*log(d) *sin(x) + 3*log(d) *sin(x)*x
1598
1599                 3                    2         2            2
1600      - 12*log(d) *sin(x)*x + 3*log(d) *sin(x)*x  + 36*log(d) *sin(x)
1601
1602                       3                                  2
1603      + log(d)*sin(x)*x  - 18*log(d)*sin(x)*x + 3*sin(x)*x  - 6*sin(x)))/(
1604
1605         8           6           4           2
1606   log(d)  + 4*log(d)  + 6*log(d)  + 4*log(d)  + 1)
1607
1608testint(x**3*d**x*cos x,x);
1609
1610
1611  x               7  3                  6  2                  5  3
1612(d *(cos(x)*log(d) *x  - 3*cos(x)*log(d) *x  + 3*cos(x)*log(d) *x
1613
1614                       5                    4  2                  4
1615      + 6*cos(x)*log(d) *x - 3*cos(x)*log(d) *x  - 6*cos(x)*log(d)
1616
1617                       3  3                   3                    2  2
1618      + 3*cos(x)*log(d) *x  - 12*cos(x)*log(d) *x + 3*cos(x)*log(d) *x
1619
1620                        2                  3                                  2
1621      + 36*cos(x)*log(d)  + cos(x)*log(d)*x  - 18*cos(x)*log(d)*x + 3*cos(x)*x
1622
1623                         6         3           5         2           4         3
1624      - 6*cos(x) + log(d) *sin(x)*x  - 6*log(d) *sin(x)*x  + 3*log(d) *sin(x)*x
1625
1626                 4                     3         2            3
1627      + 18*log(d) *sin(x)*x - 12*log(d) *sin(x)*x  - 24*log(d) *sin(x)
1628
1629                2         3            2                             2
1630      + 3*log(d) *sin(x)*x  + 12*log(d) *sin(x)*x - 6*log(d)*sin(x)*x
1631
1632                                   3                       8           6
1633      + 24*log(d)*sin(x) + sin(x)*x  - 6*sin(x)*x))/(log(d)  + 4*log(d)
1634
1635              4           2
1636    + 6*log(d)  + 4*log(d)  + 1)
1637
1638testint(sin x*sin(2*x)*sin(3*x),x);
1639
1640
1641( - cos(3*x)*cos(2*x)*cos(x) + 6*cos(3*x)*cos(2*x)*sin(x)*x
1642
1643  + 6*cos(3*x)*cos(x)*sin(2*x)*x - 8*cos(3*x)*sin(2*x)*sin(x)
1644
1645  - 6*cos(2*x)*cos(x)*sin(3*x)*x + 3*cos(2*x)*sin(3*x)*sin(x)
1646
1647  + 6*sin(3*x)*sin(2*x)*sin(x)*x)/24
1648
1649testint(cos x*cos(2*x)*cos(3*x),x);
1650
1651
1652(6*cos(3*x)*cos(2*x)*cos(x)*x + 8*cos(3*x)*cos(2*x)*sin(x)
1653
1654  + 5*cos(3*x)*cos(x)*sin(2*x) - 6*cos(3*x)*sin(2*x)*sin(x)*x
1655
1656  + 6*cos(2*x)*sin(3*x)*sin(x)*x + 6*cos(x)*sin(3*x)*sin(2*x)*x
1657
1658  + 9*sin(3*x)*sin(2*x)*sin(x))/24
1659
1660testint(sin(x*kx)**3*x**2,x);
1661
1662
1663                         2   2  2                        2                  2  2
1664( - 9*cos(kx*x)*sin(kx*x) *kx *x  + 2*cos(kx*x)*sin(kx*x)  - 18*cos(kx*x)*kx *x
1665
1666                              3                                      3
1667  + 40*cos(kx*x) + 6*sin(kx*x) *kx*x + 36*sin(kx*x)*kx*x + 16)/(27*kx )
1668
1669testint(x*cos(xi/sin(x))*cos(x)/sin(x)**2,x);
1670
1671
1672            xi
1673     cos(--------)*cos(x)*x
1674          sin(x)
1675int(------------------------,x)
1676                  2
1677            sin(x)
1678
1679
1680% Mixed angles and half angles.
1681
1682int(cos(x)/(sin(x)*tan(x/2)),x);
1683
1684
1685          x
1686  - (tan(---)*x + 1)
1687          2
1688---------------------
1689           x
1690      tan(---)
1691           2
1692
1693
1694% This integral produces a messy result because the code for
1695% converting half angle tans to sin and cos is not effective enough.
1696
1697testint(sin(a*x)/(b+c*sin(a*x))**2,x);
1698
1699
1700                               a*x
1701                          tan(-----)*b + c
1702            2    2              2                      2
1703( - 2*sqrt(b  - c )*atan(------------------)*sin(a*x)*c
1704                                 2    2
1705                           sqrt(b  - c )
1706
1707                               a*x
1708                          tan(-----)*b + c
1709            2    2              2                            3               2
1710  - 2*sqrt(b  - c )*atan(------------------)*b*c - cos(a*x)*b  + cos(a*x)*b*c )/
1711                                 2    2
1712                           sqrt(b  - c )
1713
1714              4                 2  3             5    5      3  2      4
1715(a*(sin(a*x)*b *c - 2*sin(a*x)*b *c  + sin(a*x)*c  + b  - 2*b *c  + b*c ))
1716
1717
1718% Examples involving logarithms and circular functions.
1719
1720testint(sin log x,x);
1721
1722
1723 x*( - cos(log(x)) + sin(log(x)))
1724----------------------------------
1725                2
1726
1727testint(cos log x,x);
1728
1729
1730 x*(cos(log(x)) + sin(log(x)))
1731-------------------------------
1732               2
1733
1734
1735% Examples involving exponentials.
1736
1737testint(e**x,x);
1738
1739
1740 x
1741e
1742                % 2.01 #3
1743testint(a**x,x);
1744
1745
1746    x
1747   a
1748--------
1749 log(a)
1750                % 2.01 #4
1751testint(e**(a*x),x);
1752
1753
1754  a*x
1755 e
1756------
1757  a
1758
1759testint(e**(a*x)/x,x);
1760
1761
1762ei(a*x)
1763
1764testint(1/(a+b*e**(m*x)),x);
1765
1766
1767         m*x
1768  - log(e   *b + a) + m*x
1769--------------------------
1770           a*m
1771
1772testint(e**(2*x)/(1+e**x),x);
1773
1774
1775 x        x
1776e  - log(e  + 1)
1777
1778testint(e**(2*x)*e**(a*x),x);
1779
1780
1781  a*x + 2*x
1782 e
1783------------
1784   a + 2
1785
1786testint(1/(a*e**(m*x)+b*e**(-m*x)),x);
1787
1788
1789                            m*x
1790                           e   *a
1791 sqrt(b)*sqrt(a)*atan(-----------------)
1792                       sqrt(b)*sqrt(a)
1793-----------------------------------------
1794                  a*b*m
1795
1796testint(x*e**(a*x),x);
1797
1798
1799  a*x
1800 e   *(a*x - 1)
1801----------------
1802        2
1803       a
1804
1805testint(x**20*e**x,x);
1806
1807
1808 x   20       19        18         17           16            15             14
1809e *(x   - 20*x   + 380*x   - 6840*x   + 116280*x   - 1860480*x   + 27907200*x
1810
1811                  13               12                11                 10
1812     - 390700800*x   + 5079110400*x   - 60949324800*x   + 670442572800*x
1813
1814                      9                   8                    7
1815     - 6704425728000*x  + 60339831552000*x  - 482718652416000*x
1816
1817                         6                      5                       4
1818     + 3379030566912000*x  - 20274183401472000*x  + 101370917007360000*x
1819
1820                           3                        2
1821     - 405483668029440000*x  + 1216451004088320000*x  - 2432902008176640000*x
1822
1823     + 2432902008176640000)
1824
1825testint(a**x/b**x,x);
1826
1827
1828           x
1829          a
1830----------------------
1831  x
1832 b *(log(a) - log(b))
1833
1834testint(a**x*b**x,x);
1835
1836
1837       x  x
1838      b *a
1839-----------------
1840 log(a) + log(b)
1841
1842testint(a**x/x**2,x);
1843
1844
1845                          x
1846 ei(log(a)*x)*log(a)*x - a
1847----------------------------
1848             x
1849
1850testint(x*a**x/(1+b*x)**2,x);
1851
1852
1853                                x
1854                               a *x
1855int(-----------------------------------------------------------,x)*(log(a) - b)
1856             2  2                            3  2      2
1857     log(a)*b *x  + 2*log(a)*b*x + log(a) - b *x  - 2*b *x - b
1858
1859testint(x*e**(a*x)/(1+a*x)**2,x);
1860
1861
1862      a*x
1863     e
1864--------------
1865  2
1866 a *(a*x + 1)
1867
1868testint(x*k**(x**2),x);
1869
1870
1871     2
1872    x
1873   k
1874----------
1875 2*log(k)
1876
1877testint(e**(x**2),x);
1878
1879
1880  - sqrt(pi)*erf(i*x)*i
1881------------------------
1882           2
1883
1884testint(2**(x**2),x);
1885
1886
1887  - sqrt(pi)*erf(sqrt(log(2))*i*x)*i
1888-------------------------------------
1889           2*sqrt(log(2))
1890
1891testint(2**(2*x**2),x);
1892
1893
1894  - sqrt(pi)*erf(sqrt(log(2))*sqrt(2)*i*x)*i
1895---------------------------------------------
1896           2*sqrt(log(2))*sqrt(2)
1897
1898testint(e**(a*x**2),x);
1899
1900
1901  - sqrt(pi)*erf(sqrt(a)*i*x)*i
1902--------------------------------
1903           2*sqrt(a)
1904
1905testint(e**(a**2*x**2),x);
1906
1907
1908  - sqrt(pi)*erf(abs(a)*i*x)*i
1909-------------------------------
1910           2*abs(a)
1911
1912testint(x*e**(x**2),x);
1913
1914
1915   2
1916  x
1917 e
1918-----
1919  2
1920
1921testint((x+1)*e**(1/x)/x**4,x);
1922
1923
1924  1/x      2
1925 e   *( - x  + x - 1)
1926----------------------
1927           2
1928          x
1929
1930testint((2*x**3+x)*(e**(x**2))**2*e**(1-x*e**(x**2))/(1-x*e**(x**2))**2,
1931	x);
1932
1933
1934         - e
1935--------------------
1936    2
1937   x       2
1938  e  *x   x
1939 e     *(e  *x - 1)
1940
1941testint(e**(e**(e**(e**x))),x);
1942
1943
1944        x
1945       e
1946      e
1947     e
1948int(e    ,x)
1949
1950
1951% Examples involving exponentials and logarithms.
1952
1953testint(e**x*log x,x);
1954
1955
1956            x
1957 - ei(x) + e *log(x)
1958
1959testint(x*e**x*log x,x);
1960
1961
1962         x             x           x
1963ei(x) + e *log(x)*x - e *log(x) - e
1964
1965testint(e**(2*x)*log(e**x),x);
1966
1967
1968  2*x
1969 e   *(2*x - 1)
1970----------------
1971       4
1972
1973
1974% Examples involving square roots.
1975
1976testint(sqrt(2)*x**2 + 2*x,x);
1977
1978
1979  2
1980 x *(sqrt(2)*x + 3)
1981--------------------
1982         3
1983
1984testint(log x/sqrt(a*x+b),x);
1985
1986
1987(2*(sqrt(a*x + b)*log(x) - 2*sqrt(a*x + b)
1988
1989     - 2*sqrt(b)*log(sqrt(a*x + b) - sqrt(b)) + sqrt(b)*log(x)))/a
1990
1991u:=sqrt(a+b*x);
1992
1993
1994u := sqrt(a + b*x)
1995
1996v:=sqrt(c+d*x);
1997
1998
1999v := sqrt(c + d*x)
2000
2001testint(u*v,x);
2002
2003
2004                                  2                                2
2005(sqrt(c + d*x)*sqrt(a + b*x)*a*b*d  + sqrt(c + d*x)*sqrt(a + b*x)*b *c*d
2006
2007                                   2  2
2008  + 2*sqrt(c + d*x)*sqrt(a + b*x)*b *d *x
2009
2010                         sqrt(d)*sqrt(a + b*x) + sqrt(b)*sqrt(c + d*x)    2  2
2011  - sqrt(d)*sqrt(b)*log(-----------------------------------------------)*a *d  +
2012                                        sqrt(a*d - b*c)
2013
2014                         sqrt(d)*sqrt(a + b*x) + sqrt(b)*sqrt(c + d*x)
2015  2*sqrt(d)*sqrt(b)*log(-----------------------------------------------)*a*b*c*d
2016                                        sqrt(a*d - b*c)
2017
2018                         sqrt(d)*sqrt(a + b*x) + sqrt(b)*sqrt(c + d*x)    2  2
2019  - sqrt(d)*sqrt(b)*log(-----------------------------------------------)*b *c )/
2020                                        sqrt(a*d - b*c)
2021
2022    2  2
2023(4*b *d )
2024
2025testint(u,x);
2026
2027
2028 2*sqrt(a + b*x)*(a + b*x)
2029---------------------------
2030            3*b
2031
2032testint(x*u,x);
2033
2034
2035                        2              2  2
2036 2*sqrt(a + b*x)*( - 2*a  + a*b*x + 3*b *x )
2037---------------------------------------------
2038                        2
2039                    15*b
2040
2041testint(x**2*u,x);
2042
2043
2044                     3      2            2  2       3  3
2045 2*sqrt(a + b*x)*(8*a  - 4*a *b*x + 3*a*b *x  + 15*b *x )
2046----------------------------------------------------------
2047                               3
2048                          105*b
2049
2050testint(u/x,x);
2051
2052
20532*sqrt(a + b*x) + sqrt(a)*log(sqrt(a + b*x) - sqrt(a))
2054
2055 - sqrt(a)*log(sqrt(a + b*x) + sqrt(a))
2056
2057testint(u/x**2,x);
2058
2059
2060( - 2*sqrt(a + b*x)*a + sqrt(a)*log(sqrt(a + b*x) - sqrt(a))*b*x
2061
2062  - sqrt(a)*log(sqrt(a + b*x) + sqrt(a))*b*x)/(2*a*x)
2063
2064testint(1/u,x);
2065
2066
2067 2*sqrt(a + b*x)
2068-----------------
2069        b
2070
2071testint(x/u,x);
2072
2073
2074 2*sqrt(a + b*x)*( - 2*a + b*x)
2075--------------------------------
2076                 2
2077              3*b
2078
2079testint(x**2/u,x);
2080
2081
2082                     2                2  2
2083 2*sqrt(a + b*x)*(8*a  - 4*a*b*x + 3*b *x )
2084--------------------------------------------
2085                       3
2086                   15*b
2087
2088testint(1/(x*u),x);
2089
2090
2091 sqrt(a)*(log(sqrt(a + b*x) - sqrt(a)) - log(sqrt(a + b*x) + sqrt(a)))
2092-----------------------------------------------------------------------
2093                                   a
2094
2095testint(1/(x**2*u),x);
2096
2097
2098( - 2*sqrt(a + b*x)*a - sqrt(a)*log(sqrt(a + b*x) - sqrt(a))*b*x
2099
2100                                                  2
2101  + sqrt(a)*log(sqrt(a + b*x) + sqrt(a))*b*x)/(2*a *x)
2102
2103testint(u**p,x);
2104
2105
2106            p/2
2107 2*(a + b*x)   *(a + b*x)
2108--------------------------
2109        b*(p + 2)
2110
2111testint(x*u**p,x);
2112
2113
2114            p/2        2              2    2      2  2
2115 2*(a + b*x)   *( - 2*a  + a*b*p*x + b *p*x  + 2*b *x )
2116--------------------------------------------------------
2117                    2   2
2118                   b *(p  + 6*p + 8)
2119
2120testint(atan((-sqrt(2)+2*x)/sqrt(2)),x);
2121
2122
2123                 sqrt(2) - 2*x             sqrt(2) - 2*x
2124(2*sqrt(2)*atan(---------------) - 4*atan(---------------)*x
2125                    sqrt(2)                   sqrt(2)
2126
2127                             2
2128  - sqrt(2)*log(sqrt(2)*x - x  - 1))/4
2129
2130testint(1/sqrt(x**2-1),x);
2131
2132
2133          2
2134log(sqrt(x  - 1) + x)
2135
2136testint(sqrt(x+1)*sqrt x,x);
2137
2138
2139 2*sqrt(x)*sqrt(x + 1)*x + sqrt(x)*sqrt(x + 1) - log(sqrt(x + 1) + sqrt(x))
2140----------------------------------------------------------------------------
2141                                     4
2142
2143
2144testint(sin(sqrt x),x);
2145
2146
21472*( - sqrt(x)*cos(sqrt(x)) + sin(sqrt(x)))
2148
2149testint(x*(1-x^2)^(-9/4),x);
2150
2151
2152              2     1/4
2153     - 2*( - x  + 1)
2154----------------------------
2155            2        2
2156 5*sqrt( - x  + 1)*(x  - 1)
2157
2158testint(x/sqrt(1-x^4),x);
2159
2160
2161       2
2162 asin(x )
2163----------
2164    2
2165
2166testint(1/(x*sqrt(1+x^4)),x);
2167
2168
2169           4         2                  4         2
2170 log(sqrt(x  + 1) + x  - 1) - log(sqrt(x  + 1) + x  + 1)
2171---------------------------------------------------------
2172                            2
2173
2174testint(x/sqrt(1+x^2+x^4),x);
2175
2176
2177              4    2           2
2178      2*sqrt(x  + x  + 1) + 2*x  + 1
2179 log(--------------------------------)
2180                 sqrt(3)
2181---------------------------------------
2182                   2
2183
2184testint(1/(x*sqrt(x^2-1-x^4)),x);
2185
2186
2187                 4    2
2188        sqrt( - x  + x  - 1)
2189 - int(----------------------,x)
2190             5    3
2191            x  - x  + x
2192
2193
2194% Examples from James Davenport's thesis:
2195
2196testint(1/sqrt(x**2-1)+10/sqrt(x**2-4),x);
2197
2198
2199                                      2
2200          2                     sqrt(x  - 4) + x
2201log(sqrt(x  - 1) + x) + 10*log(------------------)
2202                                       2
2203      % p. 173
2204testint(sqrt(x+sqrt(x**2+a**2))/x,x);
2205
2206
2207                2    2
2208     sqrt(sqrt(a  + x ) + x)
2209int(-------------------------,x)
2210                x
2211
2212
2213% Examples generated by differentiating various functions.
2214
2215testint(df(sqrt(1+x**2)/(1-x),x),x);
2216
2217
2218          2
2219  - sqrt(x  + 1)
2220-----------------
2221      x - 1
2222
2223testint(df(log(x+sqrt(1+x**2)),x),x);
2224
2225
2226          2
2227log(sqrt(x  + 1) + x)
2228
2229testint(df(sqrt(x)+sqrt(x+1)+sqrt(x+2),x),x);
2230
2231
2232sqrt(x + 2) + sqrt(x + 1) + sqrt(x)
2233
2234testint(df(sqrt(x**5-2*x+1)-sqrt(x**3+1),x),x);
2235
2236
2237      5                    3
2238sqrt(x  - 2*x + 1) - sqrt(x  + 1)
2239
2240
2241% Another such example from James Davenport's thesis (p. 146).
2242% It contains a point of order 3, which is found by use of Mazur's
2243% bound on the torsion of elliptic curves over the rationals;
2244
2245testint(df(log(1+sqrt(x**3+1)),x),x);
2246
2247
2248                  3
2249            sqrt(x  + 1)
2250 3*( - int(--------------,x) + log(x))
2251                4
2252               x  + x
2253---------------------------------------
2254                   2
2255
2256
2257% Examples quoted by Joel Moses:
2258
2259testint(1/sqrt(2*h*r**2-alpha**2),r);
2260
2261
2262                                   2        2
2263                      sqrt( - alpha  + 2*h*r ) + sqrt(h)*sqrt(2)*r
2264 sqrt(h)*sqrt(2)*log(----------------------------------------------)
2265                                         alpha
2266---------------------------------------------------------------------
2267                                 2*h
2268
2269testint(1/(r*sqrt(2*h*r**2-alpha**2-epsilon**2)),r);
2270
2271
2272             2          2
2273(2*sqrt(alpha  + epsilon )
2274
2275                     2          2        2
2276        sqrt( - alpha  - epsilon  + 2*h*r ) + sqrt(h)*sqrt(2)*r          2
2277 *atan(---------------------------------------------------------))/(alpha
2278                                  2          2
2279                        sqrt(alpha  + epsilon )
2280
2281             2
2282    + epsilon )
2283
2284testint(1/(r*sqrt(2*h*r**2-alpha**2-2*k*r)),r);
2285
2286
2287                              2        2
2288         sqrt(h)*sqrt( - alpha  + 2*h*r  - 2*k*r)*sqrt(2) + 2*h*r
2289 2*atan(----------------------------------------------------------)
2290                          sqrt(h)*sqrt(2)*alpha
2291--------------------------------------------------------------------
2292                               alpha
2293
2294testint(1/(r*sqrt(2*h*r**2-alpha**2-epsilon**2-2*k*r)),r);
2295
2296
2297             2          2
2298(2*sqrt(alpha  + epsilon )
2299
2300                             2          2        2
2301        sqrt(h)*sqrt( - alpha  - epsilon  + 2*h*r  - 2*k*r)*sqrt(2) + 2*h*r
2302 *atan(---------------------------------------------------------------------))/(
2303                                        2          2
2304                      sqrt(h)*sqrt(alpha  + epsilon )*sqrt(2)
2305
2306        2          2
2307   alpha  + epsilon )
2308
2309testint(r/sqrt(2*e*r**2-alpha**2),r);
2310
2311
2312              2        2
2313 sqrt( - alpha  + 2*e*r )
2314--------------------------
2315           2*e
2316
2317testint(r/sqrt(2*e*r**2-alpha**2-epsilon**2),r);
2318
2319
2320              2        2          2
2321 sqrt( - alpha  + 2*e*r  - epsilon )
2322-------------------------------------
2323                 2*e
2324
2325testint(r/sqrt(2*e*r**2-alpha**2-2*k*r**4),r);
2326
2327
2328                                          2
2329                             e*i - 2*i*k*r
2330 sqrt(k)*sqrt(2)*asinh(--------------------------)*i
2331                                       2      2
2332                        sqrt( - 2*alpha *k + e )
2333-----------------------------------------------------
2334                         4*k
2335
2336testint(r/sqrt(2*e*r**2-alpha**2-2*k*r),r);
2337
2338
2339                2        2
2340(2*sqrt( - alpha  + 2*e*r  - 2*k*r)*e + sqrt(e)*sqrt(2)
2341
2342                            2        2
2343       sqrt(e)*sqrt( - alpha  + 2*e*r  - 2*k*r)*sqrt(2) + 2*e*r - k          2
2344 *log(--------------------------------------------------------------)*k)/(4*e )
2345                                      2      2
2346                          sqrt(2*alpha *e + k )
2347
2348
2349% These two integrals will evaluate, but they take a very long time
2350% and the results are messy (compared with the algint results).
2351
2352% testint(1/(r*sqrt(2*h*r**2-alpha**2-2*k*r**4)),r);
2353% testint(1/(r*sqrt(2*h*r**2-alpha**2-epsilon**2-2*k*r**4)),r);
2354
2355
2356Comment many of these integrals used to require Steve Harrington's
2357	code to evaluate. They originated in Novosibirsk as examples
2358	of using Analytik. There are still a few examples that could
2359	be evaluated using better heuristics;
2360
2361
2362testint(a*sin(3*x+5)**2*cos(3*x+5),x);
2363
2364
2365             3
2366 sin(3*x + 5) *a
2367-----------------
2368        9
2369
2370testint(log(x**2)/x**3,x);
2371
2372
2373          2
2374  - (log(x ) + 1)
2375------------------
2376          2
2377       2*x
2378
2379testint(x*sin(x+a),x);
2380
2381
2382 - cos(a + x)*x + sin(a + x)
2383
2384testint((log(x)*(1-x)-1)/(e**x*log(x)**2),x);
2385
2386
2387     x
2388-----------
2389  x
2390 e *log(x)
2391
2392testint(x**3*(a*x**2+b)**(-1),x);
2393
2394
2395           2             2
2396  - log(a*x  + b)*b + a*x
2397---------------------------
2398              2
2399           2*a
2400
2401testint(x**(1/2)*(x+1)**(-7/2),x);
2402
2403
2404                      2                                                2
2405(2*( - 2*sqrt(x + 1)*x  - 4*sqrt(x + 1)*x - 2*sqrt(x + 1) + 2*sqrt(x)*x
2406
2407                                       2
2408     + 5*sqrt(x)*x))/(15*sqrt(x + 1)*(x  + 2*x + 1))
2409
2410testint(x**(-1)*(x+1)**(-1),x);
2411
2412
2413 - log(x + 1) + log(x)
2414
2415testint(x**(-1/2)*(2*x-1)**(-1),x);
2416
2417
2418 sqrt(2)*(log(2*sqrt(x) - sqrt(2)) - log(2*sqrt(x) + sqrt(2)))
2419---------------------------------------------------------------
2420                               2
2421
2422testint((x**2+1)*x**(1/2),x);
2423
2424
2425                 2
2426 2*sqrt(x)*x*(3*x  + 7)
2427------------------------
2428           21
2429
2430testint(x**(-1)*(x-a)**(1/3),x);
2431
2432
2433                                1/6    1/6
2434                    2*( - a + x)    - a   *sqrt(3)
2435( - 2*sqrt(3)*atan(--------------------------------)*a
2436                                  1/6
2437                                 a
2438
2439                                1/6    1/6
2440                    2*( - a + x)    + a   *sqrt(3)          2/3           1/3
2441  + 2*sqrt(3)*atan(--------------------------------)*a + 6*a   *( - a + x)
2442                                  1/6
2443                                 a
2444
2445                    1/3    1/3
2446  - 2*log(( - a + x)    + a   )*a
2447
2448            1/6           1/6                     1/3    1/3
2449  + log( - a   *( - a + x)   *sqrt(3) + ( - a + x)    + a   )*a
2450
2451         1/6           1/6                     1/3    1/3         2/3
2452  + log(a   *( - a + x)   *sqrt(3) + ( - a + x)    + a   )*a)/(2*a   )
2453
2454testint(x*sinh(x),x);
2455
2456
2457cosh(x)*x - sinh(x)
2458
2459testint(x*cosh(x),x);
2460
2461
2462 - cosh(x) + sinh(x)*x
2463
2464testint(sinh(2*x)/cosh(2*x),x);
2465
2466
2467 log(cosh(2*x))
2468----------------
2469       2
2470
2471testint((i*eps*sinh x-1)/(eps*i*cosh x+i*a-x),x);
2472
2473
2474log(cosh(x)*eps*i + a*i - x)
2475
2476testint(sin(2*x+3)*cos(x)**2,x);
2477
2478
2479                                                          2
2480( - 4*cos(2*x + 3)*cos(x)*sin(x)*x + 2*cos(2*x + 3)*sin(x)  - 3*cos(2*x + 3)
2481
2482                         2
2483  - 4*sin(2*x + 3)*sin(x) *x + 2*sin(2*x + 3)*x + 3)/8
2484
2485testint(x*atan(x),x);
2486
2487
2488          2
2489 atan(x)*x  + atan(x) - x
2490--------------------------
2491            2
2492
2493testint(x*acot(x),x);
2494
2495
2496          2
2497 acot(x)*x  + acot(x) + x
2498--------------------------
2499            2
2500
2501testint(x*log(x**2+a),x);
2502
2503
2504          2               2   2    2
2505 log(a + x )*a + log(a + x )*x  - x
2506-------------------------------------
2507                  2
2508
2509testint(sin(x+a)*cos(x),x);
2510
2511
2512  - cos(a + x)*cos(x) - cos(a + x)*sin(x)*x + cos(x)*sin(a + x)*x
2513------------------------------------------------------------------
2514                                2
2515
2516testint(cos(x+a)*sin(x),x);
2517
2518
2519  - cos(a + x)*cos(x) + cos(a + x)*sin(x)*x - cos(x)*sin(a + x)*x
2520------------------------------------------------------------------
2521                                2
2522
2523testint((1+sin(x))**(1/2),x);
2524
2525
2526int(sqrt(sin(x) + 1),x)
2527
2528testint((1-sin(x))**(1/2),x);
2529
2530
2531int(sqrt( - sin(x) + 1),x)
2532
2533testint((1+cos(x))**(1/2),x);
2534
2535
2536int(sqrt(cos(x) + 1),x)
2537
2538testint((1-cos(x))**(1/2),x);
2539
2540
2541int(sqrt( - cos(x) + 1),x)
2542
2543testint(1/(x**(1/2)-(x-1)**(1/2)),x);
2544
2545
2546 2*(sqrt(x - 1)*x - sqrt(x - 1) + sqrt(x)*x)
2547---------------------------------------------
2548                      3
2549
2550testint(1/(1-(x+1)**(1/2)),x);
2551
2552
2553 - 2*(sqrt(x + 1) + log(sqrt(x + 1) - 1))
2554
2555testint(x/(x**4+36)**(1/2),x);
2556
2557
2558            4          2
2559      sqrt(x  + 36) + x
2560 log(--------------------)
2561              6
2562---------------------------
2563             2
2564
2565testint(1/(x**(1/3)+x**(1/2)),x);
2566
2567
2568   1/6      1/3                      1/6
25696*x    - 3*x    + 2*sqrt(x) - 6*log(x    + 1)
2570
2571testint(log(2+3*x**2),x);
2572
2573
2574                   3*x                2
2575 2*sqrt(6)*atan(---------) + 3*log(3*x  + 2)*x - 6*x
2576                 sqrt(6)
2577-----------------------------------------------------
2578                          3
2579
2580testint(cot(x),x);
2581
2582
2583            x  2                 x
2584 - log(tan(---)  + 1) + log(tan(---))
2585            2                    2
2586
2587testint(cot x**4,x);
2588
2589
2590          3
2591  - cot(x)  + 3*cot(x) + 3*x
2592-----------------------------
2593              3
2594
2595testint(tanh(x),x);
2596
2597
2598     2*x
2599log(e    + 1) - x
2600
2601testint(coth(x),x);
2602
2603
2604     x             x
2605log(e  - 1) + log(e  + 1) - x
2606
2607testint(b**x,x);
2608
2609
2610    x
2611   b
2612--------
2613 log(b)
2614
2615testint((x**4+x**(-4)+2)**(1/2),x);
2616
2617
2618  4
2619 x  - 3
2620--------
2621  3*x
2622
2623testint((2*x+1)/(3*x+2),x);
2624
2625
2626  - log(3*x + 2) + 6*x
2627-----------------------
2628           9
2629
2630testint(x*log(x+(x**2+1)**(1/2)),x);
2631
2632
2633          2                      2            2             2
2634  - sqrt(x  + 1)*x + 2*log(sqrt(x  + 1) + x)*x  + log(sqrt(x  + 1) + x)
2635------------------------------------------------------------------------
2636                                   4
2637
2638testint(x*(e**x*sin(x)+1)**2,x);
2639
2640
2641       2*x                    2*x                    x               x
2642( - 2*e   *cos(x)*sin(x)*x + e   *cos(x)*sin(x) - 8*e *cos(x)*x + 8*e *cos(x)
2643
2644       2*x       2      2*x      2*x      x               2
2645  + 2*e   *sin(x) *x + e   *x - e    + 8*e *sin(x)*x + 4*x )/8
2646
2647testint(x*e**x*cos(x),x);
2648
2649
2650  x
2651 e *(cos(x)*x + sin(x)*x - sin(x))
2652-----------------------------------
2653                 2
2654
2655
2656Comment the following set came from Herbert Stoyan;
2657
2658
2659testint(1/(x-3)**4,x);
2660
2661
2662            - 1
2663---------------------------
2664     3      2
2665 3*(x  - 9*x  + 27*x - 27)
2666
2667testint(x/(x**3-1),x);
2668
2669
2670                 2*x + 1          2
2671 2*sqrt(3)*atan(---------) - log(x  + x + 1) + 2*log(x - 1)
2672                 sqrt(3)
2673------------------------------------------------------------
2674                             6
2675
2676testint(x/(x**4-1),x);
2677
2678
2679         2
2680  - log(x  + 1) + log(x - 1) + log(x + 1)
2681------------------------------------------
2682                    4
2683
2684testint(log(x)*(x**3+1)/(x**4+2),x);
2685
2686
2687            log(x)               log(x)             2
2688  - 4*int(----------,x) + 2*int(--------,x) + log(x)
2689            5                     4
2690           x  + 2*x              x  + 2
2691------------------------------------------------------
2692                          2
2693
2694testint(log(x)+log(x+1)+log(x+2),x);
2695
2696
2697log(x + 2)*x + 2*log(x + 2) + log(x + 1)*x + log(x + 1) + log(x)*x - 3*x
2698
2699testint(1/(x**3+5),x);
2700
2701
2702                            1/3
2703  1/3                      5    - 2*x           2/3    1/3      2
2704(5   *( - 2*sqrt(3)*atan(--------------) - log(5    - 5   *x + x )
2705                                   1/3
2706                          sqrt(3)*5
2707
2708                 1/3
2709        + 2*log(5    + x)))/30
2710
2711testint(1/sqrt(1+x**2),x);
2712
2713
2714          2
2715log(sqrt(x  + 1) + x)
2716
2717testint(sqrt(x**2+3),x);
2718
2719
2720                               2
2721       2                 sqrt(x  + 3) + x
2722 sqrt(x  + 3)*x + 3*log(------------------)
2723                             sqrt(3)
2724--------------------------------------------
2725                     2
2726
2727testint(x/(x+1)**2,x);
2728
2729
2730 log(x + 1)*x + log(x + 1) - x
2731-------------------------------
2732             x + 1
2733
2734
2735COMMENT The following integrals were used among others as a test of
2736	Moses' SIN program;
2737
2738
2739testint(asin x,x);
2740
2741
2742                     2
2743asin(x)*x + sqrt( - x  + 1)
2744
2745testint(x**2*asin x,x);
2746
2747
2748            3            2       2              2
2749 3*asin(x)*x  + sqrt( - x  + 1)*x  + 2*sqrt( - x  + 1)
2750-------------------------------------------------------
2751                           9
2752
2753testint(sec x**2/(1+sec x**2-3*tan x),x);
2754
2755
2756                        x                                x
2757log( - sqrt(5) + 2*tan(---) + 1) - log( - sqrt(2) + tan(---) + 1)
2758                        2                                2
2759
2760                        x                             x
2761 + log(sqrt(5) + 2*tan(---) + 1) - log(sqrt(2) + tan(---) + 1)
2762                        2                             2
2763
2764testint(1/sec x**2,x);
2765
2766
2767 cos(x)*sin(x) + x
2768-------------------
2769         2
2770
2771testint((5*x**2-3*x-2)/(x**2*(x-2)),x);
2772
2773
2774 3*log(x - 2)*x + 2*log(x)*x - 1
2775---------------------------------
2776                x
2777
2778testint(1/(4*x**2+9)**(1/2),x);
2779
2780
2781              2
2782      sqrt(4*x  + 9) + 2*x
2783 log(----------------------)
2784               3
2785-----------------------------
2786              2
2787
2788testint((x**2+4)**(-1/2),x);
2789
2790
2791           2
2792     sqrt(x  + 4) + x
2793log(------------------)
2794            2
2795
2796testint(1/(9*x**2-12*x+10),x);
2797
2798
2799               3*x - 2
2800 sqrt(6)*atan(---------)
2801               sqrt(6)
2802-------------------------
2803           18
2804
2805testint(1/(x**8-2*x**7+2*x**6-2*x**5+x**4),x);
2806
2807
2808        2       4          2       3                  4                  3
2809(3*log(x  + 1)*x  - 3*log(x  + 1)*x  - 30*log(x - 1)*x  + 30*log(x - 1)*x
2810
2811               4              3       4       2                 3
2812  + 24*log(x)*x  - 24*log(x)*x  - 30*x  + 12*x  + 8*x + 4)/(12*x *(x - 1))
2813
2814testint((a*x**3+b*x**2+c*x+d)/((x+1)*x*(x-3)),x);
2815
2816
2817(27*log(x - 3)*a + 9*log(x - 3)*b + 3*log(x - 3)*c + log(x - 3)*d
2818
2819  - 3*log(x + 1)*a + 3*log(x + 1)*b - 3*log(x + 1)*c + 3*log(x + 1)*d
2820
2821  - 4*log(x)*d + 12*a*x)/12
2822
2823testint(1/(2-log(x**2+1))**5,x);
2824
2825
2826               2     5           2     4           2     3           2     2
2827 - int(1/(log(x  + 1)  - 10*log(x  + 1)  + 40*log(x  + 1)  - 80*log(x  + 1)
2828
2829                     2
2830           + 80*log(x  + 1) - 32),x)
2831
2832
2833% The next integral appeared in Risch's 1968 paper.
2834
2835testint(2*x*e**(x**2)*log(x)+e**(x**2)/x+(log(x)-2)/(log(x)**2+x)**2+
2836    ((2/x)*log(x)+(1/x)+1)/(log(x)**2+x),x);
2837
2838
2839   2             2
2840  x        3    x                       2            2             2
2841(e  *log(x)  + e  *log(x)*x + log(log(x)  + x)*log(x)  + log(log(x)  + x)*x
2842
2843                   2
2844  - log(x))/(log(x)  + x)
2845
2846
2847% The following integral would not evaluate in REDUCE 3.3.
2848
2849testint(exp(x*ze+x/2)*sin(pi*ze)**4*x**4,ze);
2850
2851
2852  (2*x*ze + x)/2  3                             3   3
2853(e              *x *( - 16*cos(pi*ze)*sin(pi*ze) *pi *x
2854
2855                              3     3                              3
2856     - 4*cos(pi*ze)*sin(pi*ze) *pi*x  - 24*cos(pi*ze)*sin(pi*ze)*pi *x
2857
2858                   4   2  2             4  4                2   2  2        4
2859     + 4*sin(pi*ze) *pi *x  + sin(pi*ze) *x  + 12*sin(pi*ze) *pi *x  + 24*pi ))/
2860
2861      4        2  2    4
2862(64*pi  + 20*pi *x  + x )
2863
2864
2865% This one evaluates:
2866
2867testint(erf(x),x);
2868
2869
2870   2
2871  x
2872 e  *erf(x)*pi*x + sqrt(pi)
2873----------------------------
2874             2
2875            x
2876           e  *pi
2877
2878
2879% So why not this one?
2880
2881testint(erf(x+a),x);
2882
2883
2884int(erf(a + x),x)
2885
2886
2887Comment here is an example of using the integrator with pattern
2888	matching;
2889
2890
2891for all m,n let int(k1**m*log(k1)**n/(p**2-k1**2),k1)=foo(m,n),
2892		int(k1*log(k1)**n/(p**2-k1**2),k1)=foo(1,n),
2893		int(k1**m*log(k1)/(p**2-k1**2),k1)=foo(m,1),
2894		int(k1*log(k1)/(p**2-k1**2),k1)=foo(1,1),
2895		int(log(k1)**n/(k1*(p**2-k1**2)),k1)=foo(-1,n);
2896
2897
2898
2899int(k1**2*log(k1)/(p**2-k1**2),k1);
2900
2901
2902*** foo declared operator
2903
2904foo(2,1)
2905
2906
2907Comment It is interesting to see how much of this one can be done;
2908
2909
2910let f1s= (12*log(s/mc**2)*s**2*pi**2*mc**3*(-8*s-12*mc**2+3*mc)
2911	+ pi**2*(12*s**4*mc+3*s**4+176*s**3*mc**3-24*s**3*mc**2
2912	-144*s**2*mc**5-48*s*mc**7+24*s*mc**6+4*mc**9-3*mc**8))
2913	 /(384*e**(s/y)*s**2);
2914
2915
2916
2917int(f1s,s);
2918
2919
2920   2        s/y      - s     9        s/y      - s     8
2921(pi *( - 4*e   *ei(------)*mc *s + 3*e   *ei(------)*mc *s
2922                     y                         y
2923
2924             s/y      - s     7           s/y      - s     6
2925       - 48*e   *ei(------)*mc *s*y + 24*e   *ei(------)*mc *s*y
2926                      y                            y
2927
2928              s/y      - s     5    2       s/y      - s     4    2
2929       - 144*e   *ei(------)*mc *s*y  + 36*e   *ei(------)*mc *s*y
2930                       y                             y
2931
2932             s/y      - s     3    3             s      5    2
2933       - 96*e   *ei(------)*mc *s*y  + 144*log(-----)*mc *s*y
2934                      y                           2
2935                                                mc
2936
2937                  s      4    2            s      3  2  2
2938       - 36*log(-----)*mc *s*y  + 96*log(-----)*mc *s *y
2939                   2                        2
2940                 mc                       mc
2941
2942                  s      3    3       9         8           5    2
2943       + 96*log(-----)*mc *s*y  - 4*mc *y + 3*mc *y + 144*mc *s*y
2944                   2
2945                 mc
2946
2947               3  2  2        3    3        2  2  2        2    3          3  2
2948       - 176*mc *s *y  - 80*mc *s*y  + 24*mc *s *y  + 24*mc *s*y  - 12*mc*s *y
2949
2950                2  3            4      3  2      2  3        4         s/y
2951       - 24*mc*s *y  - 24*mc*s*y  - 3*s *y  - 6*s *y  - 6*s*y ))/(384*e   *s*y)
2952
2953
2954factor ei,log;
2955
2956
2957
2958ws;
2959
2960
2961  s/y      - s     3   2
2962(e   *ei(------)*mc *pi *s
2963           y
2964
2965          6       5        4          3           2  2          2       3
2966 *( - 4*mc  + 3*mc  - 48*mc *y + 24*mc *y - 144*mc *y  + 36*mc*y  - 96*y )
2967
2968             s      3   2    2       2                         2           9
2969  + 12*log(-----)*mc *pi *s*y *(12*mc  - 3*mc + 8*s + 8*y) + pi *y*( - 4*mc
2970              2
2971            mc
2972
2973           8         5             3  2          3    2        2  2
2974     + 3*mc  + 144*mc *s*y - 176*mc *s *y - 80*mc *s*y  + 24*mc *s *y
2975
2976            2    2          3            2  2            3      3        2  2
2977     + 24*mc *s*y  - 12*mc*s *y - 24*mc*s *y  - 24*mc*s*y  - 3*s *y - 6*s *y
2978
2979            3         s/y
2980     - 6*s*y ))/(384*e   *s*y)
2981
2982
2983Comment the following is an example of integrals that used to loop
2984        forever.  They were first revealed by problems with Bessel
2985	function integration when specfn was loaded,
2986	e.g., int(x*besseli(2,x),x) or int(besselj(n,x),x);
2987
2988
2989operator f;
2990
2991 let {df(f(~x),x) => x*f(x-1)};
2992
2993
2994
2995int(f x,x);
2996
2997
2998int(f(x),x)
2999
3000
3001
3002Comment the following integrals reveal deficiencies in the current
3003integrator;
3004
3005
3006%high degree denominator;
3007%testint(1/(2-log(x**2+1))**5,x);
3008
3009%this example should evaluate;
3010testint(sin(2*x)/cos(x),x);
3011
3012
3013     sin(2*x)
3014int(----------,x)
3015      cos(x)
3016
3017
3018%this example, which appeared in Tobey's thesis, needs factorization
3019%over algebraic fields. It currently gives an ugly answer and so has
3020%been suppressed;
3021
3022% testint((7*x**13+10*x**8+4*x**7-7*x**6-4*x**3-4*x**2+3*x+3)/
3023%         (x**14-2*x**8-2*x**7-2*x**4-4*x**3-x**2+2*x+1),x);
3024
3025symbolic summarize!-integral!-test();
3026
3027                *****     SUMMARY OF INTEGRAL TESTS     *****
3028
3029Number of integrals tested: 280
3030
3031
3032Number of incorrect integrals: 0
3033
3034Number of unevaluated integrals: 18
3035
3036Integrands of unevaluated integrals are:
3037
3038
3039log(log(log(log(x))))
3040
3041
3042      p
3043sin(x)
3044
3045
3046      4  3
3047tan(x) *x
3048
3049
3050      6  3
3051tan(x) *x
3052
3053
3054        xi
3055 cos(--------)*cos(x)*x
3056      sin(x)
3057------------------------
3058              2
3059        sin(x)
3060
3061
3062        x
3063       a *x
3064-------------------
3065  2  2
3066 b *x  + 2*b*x + 1
3067
3068
3069    x
3070   e
3071  e
3072 e
3073e
3074
3075
3076           1
3077------------------------
3078          4    2
3079 sqrt( - x  + x  - 1)*x
3080
3081
3082            2    2
3083 sqrt(sqrt(a  + x ) + x)
3084-------------------------
3085            x
3086
3087
3088              2
3089           3*x
3090---------------------------
3091         3           3
3092 2*sqrt(x  + 1) + 2*x  + 2
3093
3094
3095sqrt(sin(x) + 1)
3096
3097
3098sqrt( - sin(x) + 1)
3099
3100
3101sqrt(cos(x) + 1)
3102
3103
3104sqrt( - cos(x) + 1)
3105
3106
3107         3
3108 log(x)*x  + log(x)
3109--------------------
3110        4
3111       x  + 2
3112
3113
3114             2     5           2     4           2     3           2     2
3115( - 1)/(log(x  + 1)  - 10*log(x  + 1)  + 40*log(x  + 1)  - 80*log(x  + 1)
3116
3117                   2
3118         + 80*log(x  + 1) - 32)
3119
3120
3121erf(a + x)
3122
3123
3124 sin(2*x)
3125----------
3126  cos(x)
3127
3128
3129
3130end;
3131
3132Tested on x86_64-pc-windows CSL
3133Time (counter 1): 359 ms  plus GC time: 16 ms
3134
3135End of Lisp run after 0.35+0.06 seconds
3136real 0.60
3137user 0.03
3138sys 0.03
3139