1/*************** -*- Mode: MACSYMA; Package: MAXIMA -*-  ******************/
2/***************************************************************************
3***                                                                    *****
4***     Copyright (c) 1984 by William Schelter,University of Texas     *****
5***     All rights reserved                                            *****
6***************************************************************************/
7
8
9kill(all);
10done$
11partition(2*a*x*f(x),x);
12[2*a,x*f(x)]$
13partition(a+b,x);
14[b+a,0]$
152*(a*log(x)+2*a*log(y));
162*(2*a*log(y)+a*log(x))$
17logcontract(%);
18a*log(x^2*y^4)$
19ratsimp(logcontract(log(sqrt(x+1)+sqrt(x))+log(sqrt(x+1)-sqrt(x))));
200$
21
22/* Two examples from Bug report ID: 947808 - logcontract and ratfac */
23logexpand:false; /* To prevent simplification of the expected result */
24false;
25logcontract(2*log(x+1)+1);
26log((x+1)^2)+1;
27logexpand:true;
28true;
29logcontract(1000*log(x+1)+log(x));
30log(x*(x+1)^1000)$
31
32rootsconmode:false;
33false$
34
35rootscontract(x^(1/2)*y^(3/2));
36sqrt(x*y^3)$
37
38rootscontract(x^(1/2)*y^(1/4));
39sqrt(x)*y^(1/4)$
40
41rootsconmode:true;
42true$
43
44expand(rootscontract(x^(1/2)*y^(1/4)) - sqrt(x*sqrt(y)),0,0);
450$
46
47expand(rootscontract(x^(1/2)*y^(1/3)) - sqrt(x)*y^(1/3),0,0);
480$
49
50rootsconmode:all;
51all$
52expand(rootscontract(x^(1/2)*y^(1/4)) - (x^2*y)^(1/4),0,0);
530$
54
55expand(rootscontract(x^(1/2)*y^(1/3)) -(x^3*y^2)^(1/6),0,0);
560$
57
58rootsconmode:false;
59false$
60rootscontract(sqrt(sqrt(x+1)+sqrt(x))*sqrt(sqrt(x+1)-sqrt(x)));
611$
62rootsconmode:true;
63true$
64
65rootscontract(sqrt(sqrt(5)+5)-5^(1/4)*sqrt(sqrt(5)+1));
660$
67
68kill(f,g,h,x,y);
69done$
70diff(sin(x)+x^3+2*x^2,x);
71cos(x)+3*x^2+4*x$
72diff(sin(x)*cos(x),x);
73cos(x)^2-sin(x)^2$
74diff(sin(x)*cos(x),x,2);
75-4*cos(x)*sin(x)$
76derivabbrev:true;
77true$
78diff(exp(f(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))$
82diff(%,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)$
85kill(a,x,f,y,t);
86done$
87
88/* -----------------------------------------------------------------------------
89 * Examples for dependencies
90 * -------------------------------------------------------------------------- */
91depends(a,x);
92[a(x)]$
93diff(a . a,x);
94'diff(a,x,1) . a+a . 'diff(a,x,1)$
95depends(f,[x,y],[x,y],t);
96[f(x,y),x(t),y(t)]$
97diff(f,t);
98'diff(f,y,1)*'diff(y,t,1)+'diff(f,x,1)*'diff(x,t,1)$
99depends(y,x);
100[y(x)]$
101kill(f,g,j);
102done$
103
104/* More examples with subscribted variables */
105
106depends(g,f,f,[x[1],x[2],x[3]],x,t);
107[g(f),f(x[1],x[2],x[3]),x(t)]$
108diff(g,f);
109'diff(g,f,1)$
110diff(f,x[1]);
111'diff(f,x[1],1)$
112diff(f,x[1],2);
113'diff(f,x[1],2)$
114diff(x[1],t);
115'diff(x[1],t,1)$
116diff(f,x[1],1,x[2],1,x[3],1);
117'diff(f,x[1],1,x[2],1,x[3],1)$
118diff(f,t);
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)$
121diff(g,t);
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))
124 *'diff(g,f,1)$
125kill(g,f,x);
126done;
127
128/* The subscript is not differentiated, it is a constant */
129
130depends(f,x[a],x,t,t,a);
131[f(x[a]),x(t),t(a)]$
132diff(f,x[a]);
133'diff(f,x[a],1)$
134diff(f,t);
135'diff(x[a],t,1)*'diff(f,x[a],1)$
136diff(f,a);
137'diff(x[a],t,1)*'diff(f,x[a],1)*'diff(t,a,1)$
138kill(f,x,t);
139done;
140
141/* Maxima has not a problem with circular defined dependencies */
142
143depends(f,x,x,t,t,f);
144[f(x),x(t),t(f)]$
145diff(f,x);
146'diff(f,x,1)$
147diff(f,t);
148'diff(f,x,1)*'diff(x,t,1)$
149diff(t,f);
150'diff(t,f,1)$
151diff(t,x);
152'diff(f,x,1)*'diff(t,f,1)$
153kill(f,x,t);
154done;
155
156/* Bug #2356: diff(...,%pi) doesn't give an error */
157
158errcatch (diff (%pi, %pi));
159[]$
160
161errcatch (diff (x, rat (2/3)));
162[]$
163
164/* -------------------------------------------------------------------------- */
165
166gradef(f(x,y),x^2,g(x,y));
167f(x,y)$
168diff(f(x,y),x);
169g(x,y)*'diff(y,x,1)+x^2$
170gradef(j(n,z),'diff(j(n,z),n),j(n-1,z)-n/z*j(n,z));
171j(n,z)$
172ratsimp(diff(j(2,x),x,2));
173(j(0,x)*x^2-3*j(1,x)*x+6*j(2,x))/x^2$
174test(f):=block([u],u:integrate(f,x),ratsimp(f-diff(u,x)));
175test(f):=block([u],u:integrate(f,x),ratsimp(f-diff(u,x)))$
176test(sin(x));
1770$
178test(1/(1+x));
1790$
180test(1/(1+x^2));
1810$
182integrate(sin(x)^3,x);
183cos(x)^3/3-cos(x)$
184kill(q);
185done$
186integrate(%e^x/(%e^x+2),x);
187log(%e^x+2)$
188integrate(1/(x*log(x)),x);
189log(log(x))$
190integrate(sin(2*x+3),x);
191-cos(2*x+3)/2$
192
193/* Correct simplification after change to risch.lisp revision 1.17 */
194
195integrate(%e^x*erf(x),x);
196%e^x*erf(x)-%e^(1/4)*erf(x-1/2)$
197
198integrate(x/(x^3+1),x);
199log(x^2-x+1)/6+atan((2*x-1)/sqrt(3))/sqrt(3)-log(x+1)/3$
200diff(%,x);
2012/(3*((2*x-1)^2/3+1))+(2*x-1)/(6*(x^2-x+1))-1/(3*(x+1))$
202ratsimp(%);
203x/(x^3+1)$
204
205/* verify that file_search finds a file specified by a path relative to top-level directory
206 * bug reported to mailing list 2015-11-08: "testsuite failure with ecl"
207 */
208
209is  (file_search ("tests/test_readbase_lisp.lisp") = false);
210false;
211
212is (file_search ("tests/rtest1.mac") = false);
213false;
214
215/* verify that loading share packages via defsystem and retrieving documentation
216 * (both make use of *LOAD-PATHNAME*) do not cause errors
217 */
218
219describe ("sin");
220true;
221
222(load ("load-graphs"), 0);
2230;
224
225/* MYTOPIC.info is the output of makeinfo template-standalone.texi in share/ */
226(load ("MYTOPIC-index"), 0);
2270;
228
229/* frotz is described in MYTOPIC.info */
230describe ("frotz");
231true;
232
233