File: test_indefinite_integrals.mac

package info (click to toggle)
maxima 5.21.1-2squeeze
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 94,928 kB
  • ctags: 43,849
  • sloc: lisp: 298,974; fortran: 14,666; perl: 14,325; tcl: 10,494; sh: 4,052; makefile: 2,975; ansic: 471; awk: 24; sed: 7
file content (92 lines) | stat: -rw-r--r-- 3,818 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/* Original version of this file copyright 1999 by Michael Wester,
 * and retrieved from http://www.math.unm.edu/~wester/demos/IndefiniteIntegrals/problems.macsyma
 * circa 2006-10-23.
 *
 * Released under the terms of the GNU General Public License, version 2,
 * per message dated 2007-06-03 from Michael Wester to Robert Dodier
 * (contained in the file wester-gpl-permission-message.txt).
 *
 * See: "A Critique of the Mathematical Abilities of CA Systems"
 * by Michael Wester, pp 25--60 in
 * "Computer Algebra Systems: A Practical Guide", edited by Michael J. Wester
 * and published by John Wiley and Sons, Chichester, United Kingdom, 1999.
 */
/* ----------[ M a c s y m a ]---------- */
/* ---------- Initialization ---------- */
showtime: all$
prederror: false$
/* ---------- Indefinite Integrals ---------- */
/* This integral only makes sense for x real => x |x|/2 */
integrate(abs(x), x);
declare(z, complex)$
integrate(abs(z), z);
remove(z, complex)$
/* Calculus on a piecewise defined function */
a(x):= if x < 0 then -x else x$
/* => if x < 0 then -x^2/2 else x^2/2 */
integrate(a(x), x);
a(x):= -x*unit_step(-x) + x*unit_step(x)$
integrate(a(x), x);
ratsimp(%);
remfunction(a)$
/* This would be very difficult to do by hand
   => 2^(1/3)/6 [1/2 log([x + 2^(1/3)]^2/[x^2 - 2^(1/3) x + 2^(2/3)])
                 + sqrt(3) arctan({[sqrt(3) x]/[2^(4/3) - x]   or
                                   [2 x - 2^(1/3)]/[2^(1/3) sqrt(3)]})
      [Gradshteyn and Ryzhik 2.126(1)] */
1/(x^3 + 2);
integrate(%, x);
diff(%, x);
/* What a mess!  Simplify it. */
ratsimp(%);
/* This integral is easy if one realizes that 4^x = (2^x)^2
   => arcsinh(2^x)/log(2)   [Robert Israel in sci.math.symbolic] */
integrate(2^x/sqrt(1 + 4^x), x);
integrate(radcan(2^x/sqrt(1 + 4^x)), x);
/* => (-9 x^2 + 16 x - 41/5)/(2 x - 1)^(5/2)
      [Gradshteyn and Ryzhik 2.244(8)] */
integrate((3*x - 5)^2/(2*x - 1)^(7/2), x);
factor(%);
/* => 1/[2 m sqrt(10)] log([-5 + e^(m x) sqrt(10)]/[-5 - e^(m x) sqrt(10)])
      [Gradshteyn and Ryzhik 2.314] */
integrate(1/(2*exp(m*x) - 5*exp(-m*x)), x);
logcontract(%);
/* => -3/2 x + 1/4 sinh(2 x) + tanh x   [Gradshteyn and Ryzhik 2.423(24)] */
integrate(sinh(x)^4/cosh(x)^2, x);
partfrac(%, %e^x);
/* This example involves several symbolic parameters
   => 1/sqrt(b^2 - a^2) log([sqrt(b^2 - a^2) tan(x/2) + a + b]/
                            [sqrt(b^2 - a^2) tan(x/2) - a - b])   (a^2 < b^2)
      [Gradshteyn and Ryzhik 2.553(3)] */
assume(b^2 > a^2)$
integrate(1/(a + b*cos(x)), x);
trigsimp(ratsimp(diff(%, x)));
forget(b^2 > a^2)$
/* The integral of 1/(a + 3 cos x + 4 sin x) can have 4 different forms
   depending on the value of a !   [Gradshteyn and Ryzhik 2.558(4)]
   => (a = 3) 1/4 log[3 + 4 tan(x/2)] */
integrate(1/(3 + 3*cos(x) + 4*sin(x)), x);
/* => (a = 4) 1/3 log([tan(x/2) + 1]/[tan(x/2) + 7]) */
integrate(1/(4 + 3*cos(x) + 4*sin(x)), x);
logcontract(factor(%));
/* => (a = 5) -1/[2 + tan(x/2)] */
integrate(1/(5 + 3*cos(x) + 4*sin(x)), x);
/* => (a = 6) 2/sqrt(11) arctan([3 tan(x/2) + 4]/sqrt(11)) */
integrate(1/(6 + 3*cos(x) + 4*sin(x)), x);
/* => x log|x^2 - a^2| - 2 x + a log|(x + a)/(x - a)|
      [Gradshteyn and Ryzhik 2.736(1)] */
integrate(log(abs(x^2 - a^2)), x);
/* => (a x)/2 + (pi x^2)/4 - 1/2 (x^2 + a^2) arctan(x/a)
         [Gradshteyn and Ryzhik 2.822(4)]   or
      (a x)/2 + 1/2 (x^2 + a^2) arccot(x/a)   [Gradshteyn and Ryzhik 2.853(2)]
*/
integrate(x*acot(x/a), x);
factor(%);
/* => [sin(5 x) Ci(2 x)]/5 - [Si(7 x) + Si(3 x)]/10
      [Gradshteyn and Ryzhik 5.31(1)] */
integrate(cos(5*x)*cos_int(2*x), x);
/* => 1/2 [f(x) - g(x)]/[f(x) + g(x)]   [Gradshteyn and Ryzhik 2.02(25)] */
integrate(('diff(f(x), x)*g(x) - f(x)*'diff(g(x), x))/(f(x)^2 - g(x)^2), x);
logcontract(antidiff(part(%, 1), x, f(x)));
/* ---------- Quit ---------- */
quit();