1 /*************** -*- Mode: MACSYMA; Package: MAXIMA -*- ******************/
2 /***************************************************************************
4 *** Copyright (c) 1984 by William Schelter,University of Texas *****
5 *** All rights reserved *****
6 ***************************************************************************/
11 partition(2*a*x*f(x),x);
15 2*(a*log(x)+2*a*log(y));
16 2*(2*a*log(y)+a*log(x))$
19 ratsimp(logcontract(log(sqrt(x+1)+sqrt(x))+log(sqrt(x+1)-sqrt(x))));
22 /* Two examples from Bug report ID: 947808 - logcontract and ratfac */
23 logexpand:false; /* To prevent simplification of the expected result */
25 logcontract(2*log(x+1)+1);
29 logcontract(1000*log(x+1)+log(x));
35 rootscontract(x^(1/2)*y^(3/2));
38 rootscontract(x^(1/2)*y^(1/4));
44 expand(rootscontract(x^(1/2)*y^(1/4)) - sqrt(x*sqrt(y)),0,0);
47 expand(rootscontract(x^(1/2)*y^(1/3)) - sqrt(x)*y^(1/3),0,0);
52 expand(rootscontract(x^(1/2)*y^(1/4)) - (x^2*y)^(1/4),0,0);
55 expand(rootscontract(x^(1/2)*y^(1/3)) -(x^3*y^2)^(1/6),0,0);
60 rootscontract(sqrt(sqrt(x+1)+sqrt(x))*sqrt(sqrt(x+1)-sqrt(x)));
65 rootscontract(sqrt(sqrt(5)+5)-5^(1/4)*sqrt(sqrt(5)+1));
70 diff(sin(x)+x^3+2*x^2,x);
72 diff(sin(x)*cos(x),x);
74 diff(sin(x)*cos(x),x,2);
79 %e^f(x)*'diff(f(x),x,2)+%e^f(x)*('diff(f(x),x,1))^2$
80 'integrate(f(x,y),y,g(x),h(x));
81 'integrate(f(x,y),y,g(x),h(x))$
83 'integrate('diff(f(x,y),x,1),y,g(x),h(x))
84 +f(x,h(x))*'diff(h(x),x,1)-f(x,g(x))*'diff(g(x),x,1)$
88 /* -----------------------------------------------------------------------------
89 * Examples for dependencies
90 * -------------------------------------------------------------------------- */
94 'diff(a,x,1) . a+a . 'diff(a,x,1)$
95 depends(f,[x,y],[x,y],t);
98 'diff(f,y,1)*'diff(y,t,1)+'diff(f,x,1)*'diff(x,t,1)$
104 /* More examples with subscribted variables */
106 depends(g,f,f,[x[1],x[2],x[3]],x,t);
107 [g(f),f(x[1],x[2],x[3]),x(t)]$
116 diff(f,x[1],1,x[2],1,x[3],1);
117 'diff(f,x[1],1,x[2],1,x[3],1)$
119 'diff(x[3],t,1)*'diff(f,x[3],1)+'diff(x[2],t,1)*'diff(f,x[2],1)
120 +'diff(x[1],t,1)*'diff(f,x[1],1)$
122 ('diff(x[3],t,1)*'diff(f,x[3],1)+'diff(x[2],t,1)*'diff(f,x[2],1)
123 +'diff(x[1],t,1)*'diff(f,x[1],1))
128 /* The subscript is not differentiated, it is a constant */
130 depends(f,x[a],x,t,t,a);
135 'diff(x[a],t,1)*'diff(f,x[a],1)$
137 'diff(x[a],t,1)*'diff(f,x[a],1)*'diff(t,a,1)$
141 /* Maxima has not a problem with circular defined dependencies */
143 depends(f,x,x,t,t,f);
148 'diff(f,x,1)*'diff(x,t,1)$
152 'diff(f,x,1)*'diff(t,f,1)$
155 /* -------------------------------------------------------------------------- */
157 gradef(f(x,y),x^2,g(x,y));
160 g(x,y)*'diff(y,x,1)+x^2$
161 gradef(j(n,z),'diff(j(n,z),n),j(n-1,z)-n/z*j(n,z));
163 ratsimp(diff(j(2,x),x,2));
164 (j(0,x)*x^2-3*j(1,x)*x+6*j(2,x))/x^2$
165 test(f):=block([u],u:integrate(f,x),ratsimp(f-diff(u,x)));
166 test(f):=block([u],u:integrate(f,x),ratsimp(f-diff(u,x)))$
173 integrate(sin(x)^3,x);
177 integrate(%e^x/(%e^x+2),x);
179 integrate(1/(x*log(x)),x);
181 integrate(sin(2*x+3),x);
184 /* Correct simplification after change to risch.lisp revision 1.17 */
186 integrate(%e^x*erf(x),x);
187 %e^x*erf(x)-%e^(1/4)*erf(x-1/2)$
189 integrate(x/(x^3+1),x);
190 log(x^2-x+1)/6+atan((2*x-1)/sqrt(3))/sqrt(3)-log(x+1)/3$
192 2/(3*((2*x-1)^2/3+1))+(2*x-1)/(6*(x^2-x+1))-1/(3*(x+1))$