1 /* Original version of this file copyright 1999 by Michael Wester,
2 * and retrieved from http://www.math.unm.edu/~wester/demos/IndefiniteIntegrals/problems.macsyma
5 * Released under the terms of the GNU General Public License, version 2,
6 * per message dated 2007-06-03 from Michael Wester to Robert Dodier
7 * (contained in the file wester-gpl-permission-message.txt).
9 * See: "A Critique of the Mathematical Abilities of CA Systems"
10 * by Michael Wester, pp 25--60 in
11 * "Computer Algebra Systems: A Practical Guide", edited by Michael J. Wester
12 * and published by John Wiley and Sons, Chichester, United Kingdom, 1999.
14 /* ----------[ M a c s y m a ]---------- */
15 /* ---------- Initialization ---------- */
18 /* ---------- Indefinite Integrals ---------- */
19 /* This integral only makes sense for x real => x |x|/2 */
24 /* Calculus on a piecewise defined function */
25 a(x):= if x < 0 then -x else x$
26 /* => if x < 0 then -x^2/2 else x^2/2 */
28 a(x):= -x*unit_step(-x) + x*unit_step(x)$
32 /* This would be very difficult to do by hand
33 => 2^(1/3)/6 [1/2 log([x + 2^(1/3)]^2/[x^2 - 2^(1/3) x + 2^(2/3)])
34 + sqrt(3) arctan({[sqrt(3) x]/[2^(4/3) - x] or
35 [2 x - 2^(1/3)]/[2^(1/3) sqrt(3)]})
36 [Gradshteyn and Ryzhik 2.126(1)] */
40 /* What a mess! Simplify it. */
42 /* This integral is easy if one realizes that 4^x = (2^x)^2
43 => arcsinh(2^x)/log(2) [Robert Israel in sci.math.symbolic] */
44 integrate(2^x/sqrt(1 + 4^x), x);
45 integrate(radcan(2^x/sqrt(1 + 4^x)), x);
46 /* => (-9 x^2 + 16 x - 41/5)/(2 x - 1)^(5/2)
47 [Gradshteyn and Ryzhik 2.244(8)] */
48 integrate((3*x - 5)^2/(2*x - 1)^(7/2), x);
50 /* => 1/[2 m sqrt(10)] log([-5 + e^(m x) sqrt(10)]/[-5 - e^(m x) sqrt(10)])
51 [Gradshteyn and Ryzhik 2.314] */
52 integrate(1/(2*exp(m*x) - 5*exp(-m*x)), x);
54 /* => -3/2 x + 1/4 sinh(2 x) + tanh x [Gradshteyn and Ryzhik 2.423(24)] */
55 integrate(sinh(x)^4/cosh(x)^2, x);
57 /* This example involves several symbolic parameters
58 => 1/sqrt(b^2 - a^2) log([sqrt(b^2 - a^2) tan(x/2) + a + b]/
59 [sqrt(b^2 - a^2) tan(x/2) - a - b]) (a^2 < b^2)
60 [Gradshteyn and Ryzhik 2.553(3)] */
62 integrate(1/(a + b*cos(x)), x);
63 trigsimp(ratsimp(diff(%, x)));
65 /* The integral of 1/(a + 3 cos x + 4 sin x) can have 4 different forms
66 depending on the value of a ! [Gradshteyn and Ryzhik 2.558(4)]
67 => (a = 3) 1/4 log[3 + 4 tan(x/2)] */
68 integrate(1/(3 + 3*cos(x) + 4*sin(x)), x);
69 /* => (a = 4) 1/3 log([tan(x/2) + 1]/[tan(x/2) + 7]) */
70 integrate(1/(4 + 3*cos(x) + 4*sin(x)), x);
71 logcontract(factor(%));
72 /* => (a = 5) -1/[2 + tan(x/2)] */
73 integrate(1/(5 + 3*cos(x) + 4*sin(x)), x);
74 /* => (a = 6) 2/sqrt(11) arctan([3 tan(x/2) + 4]/sqrt(11)) */
75 integrate(1/(6 + 3*cos(x) + 4*sin(x)), x);
76 /* => x log|x^2 - a^2| - 2 x + a log|(x + a)/(x - a)|
77 [Gradshteyn and Ryzhik 2.736(1)] */
78 integrate(log(abs(x^2 - a^2)), x);
79 /* => (a x)/2 + (pi x^2)/4 - 1/2 (x^2 + a^2) arctan(x/a)
80 [Gradshteyn and Ryzhik 2.822(4)] or
81 (a x)/2 + 1/2 (x^2 + a^2) arccot(x/a) [Gradshteyn and Ryzhik 2.853(2)]
83 integrate(x*acot(x/a), x);
85 /* => [sin(5 x) Ci(2 x)]/5 - [Si(7 x) + Si(3 x)]/10
86 [Gradshteyn and Ryzhik 5.31(1)] */
87 integrate(cos(5*x)*cos_int(2*x), x);
88 /* => 1/2 [f(x) - g(x)]/[f(x) + g(x)] [Gradshteyn and Ryzhik 2.02(25)] */
89 integrate(('diff(f(x), x)*g(x) - f(x)*'diff(g(x), x))/(f(x)^2 - g(x)^2), x);
90 logcontract(antidiff(part(%, 1), x, f(x)));