1 /*******************************************************************************
2 * File : rtest_antid.mac
3 * License : GNU General Public License (GPL)
5 * Examples for testing the functions
8 * antidiff (fn, var, unk)
10 * See the Maxima reference manual for a documentation.
12 * This file is part of Maxima -- GPL CAS based on DOE-MACSYMA
13 ******************************************************************************/
21 /* Examples taken from the Maxima reference manual */
23 expr: exp (z(x)) * diff (z(x), x) * y(x);
24 %e^z(x)*y(x)*'diff(z(x),x,1);
26 antid (expr, x, z(x));
27 [%e^z(x)*y(x),-%e^z(x)*'diff(y(x),x,1)];
29 antidiff (expr, x, z(x));
30 %e^z(x)*y(x)-'integrate(%e^z(x)*'diff(y(x),x,1),x);
32 antid (expr, x, y(x));
33 [0,%e^z(x)*y(x)*'diff(z(x),x,1)];
35 antidiff (expr, x, y(x));
36 'integrate(%e^z(x)*y(x)*'diff(z(x),x,1),x);
38 /* Example taken from the demo file antid.dem
39 * Derivate two times a function and get back the antiderivate.
42 g : diff(%e^u(x)*sin(u(x)), x, 2);
43 %e^u(x)*sin(u(x))*'diff(u(x),x,2)+%e^u(x)*cos(u(x))*'diff(u(x),x,2)
44 +2*%e^u(x)*cos(u(x))*('diff(u(x),x,1))^2;
46 ratsimp(antidiff(antidiff(g, x, u(x)), x, u(x)));
49 /* Bug report ID: 2541376 - antidiff bug
51 * This example does not give the expected simple answer, because of
52 * factors exp(a*log(f(x)+1)), which do not simplify to (f(x)+1)^a.
53 * But the answer is correct and the algorithm no longer loops forever.
56 (assume(notequal(a,0)), done);
59 antidiff(diff(f(x) * (1 + f(x))^a,x), x, f(x));
60 -'integrate(((a+1)*f(x)*%e^(a*log(f(x)+1))+(-a-1)*f(x)*(f(x)+1)^a)
63 +a*(a*f(x)-1)*%e^(a*log(f(x)+1))/(a^2+a)
64 +(a*f(x)-1)*%e^(a*log(f(x)+1))/(a^2+a)+(f(x)+1)^a/a;