Update AUTHORS file using admin/list_authors.pl.
[maxima/cygwin.git] / tests / rtest4.mac
blob8445fc0447a2e63e74a111d40ddeb94ddddc813e
1 /*************** -*- Mode: MACSYMA; Package: MAXIMA -*-  ******************/
2 /***************************************************************************
3 ***                                                                    *****
4 ***     Copyright (c) 1984 by William Schelter,University of Texas     *****
5 ***     All rights reserved                                            *****
6 ***************************************************************************/
9 kill(functions,arrays,values);
10 done$
11 ev(sin(x),exponentialize);
12 -%i*(%e^(%i*x)-%e^-(%i*x))/2$
13 taylor(sin(x)/x,x,0,4);
14 ''(taylor(1-x^2/6+x^4/120,x,0,4))$
15 ev(cos(x)^2-sin(x)^2,sin(x)^2 = 1-cos(x)^2);
16 2*cos(x)^2-1$
17 (sqrt(-4)+sqrt(2.25))^2;
18 (2*%i+1.5)^2$
19 expand(%);
20 6.0*%i-1.75$
21 expand(sqrt(2*%i));
22 (-1)^(1/4)*sqrt(2)$
23 kill(all);
24 done$
25 sin(x)+cos(y)+(w+1)^2+'diff(sin(w),w);
26 cos(y)+sin(x)+'diff(sin(w),w,1)+(w+1)^2$
27 ev(%,sin,expand,diff,x = 2,y = 1);
28 cos(w)+w^2+2*w+cos(1)+sin(2)+1;
29 ev(x+y,x:a+y,y:2);
30 y+a+2$
31 'diff(y^2+x*y+x^2,x,2,y,1);
32 'diff(y^2+x*y+x^2,x,2,y,1)$
33 ev(%,diff);
35 exp:2*x-3*y = 3;
36 2*x-3*y = 3$
37 -3*x+2*y = -4;
38 2*y-3*x = -4$
39 solve([exp,%]);
40 [[y = -1/5,x = 6/5]]$
41 ev(exp,%);
42 3 = 3$
43 x+1/x > gamma(1/2);
44 x+1/x > sqrt(%pi)$
45 ev(%,numer,x = 1/2);
46 2.5 > 1.772453850905516;
47 /* tops 20 :2.5 > 1.77245384$ */
48 ev(%,pred);
49 true$
50 zeroequiv(sin(2*x)-2*sin(x)*cos(x),x);
51 true$
52 zeroequiv(%e^x+x,x);
53 false$
54 zeroequiv(log(a*b)-log(a)-log(b),a);
55 dontknow$
56 (1/(x+y)^4-3/(y+z)^3)^2;
57 (1/(y+x)^4-3/(z+y)^3)^2$
58 expand(%,2,0);
59 -6/((y+x)^4*(z+y)^3)+9/(z+y)^6+1/(y+x)^8$
60 expand(a . (b+c . (d+e)+f));
61 a . f+a . c . e+a . c . d+a . b$
62 expand((x+1)^3);
63 x^3+3*x^2+3*x+1$
64 exp:(x+1)^7;
65 (x+1)^7$
66 expand(%);
67 x^7+7*x^6+21*x^5+35*x^4+35*x^3+21*x^2+7*x+1$
68 expand(exp,7,7);
69 x^7+7*x^6+21*x^5+35*x^4+35*x^3+21*x^2+7*x+1$
70 ev(a*(b+c)+a*(b+c)^2,expop:1);
71 a*(c+b)^2+a*c+a*b$
72 ratexpand((2*x-3*y)^3);
73 -27*y^3+54*x*y^2-36*x^2*y+8*x^3$
74 exp:(x-1)/(x+1)^2+1/(x-1);
75 (x-1)/(x+1)^2+1/(x-1)$
76 expand(%);
77 x/(x^2+2*x+1)-1/(x^2+2*x+1)+1/(x-1)$
78 ratexpand(exp);
79 2*x^2/(x^3+x^2-x-1)+2/(x^3+x^2-x-1)$
80 sin(x/(x^2+x)) = %e^((log(x)+1)^2-log(x)^2);
81 sin(x/(x^2+x)) = %e^((log(x)+1)^2-log(x)^2)$
82 ratsimp(%);
83 sin(1/(x+1)) = %e*x^2$
84 b*(a/b-x)+b*x+a;
85 b*x+b*(a/b-x)+a$
86 ratsimp(%);
87 2*a$
88 ((x-1)^(3/2)-(x+1)*sqrt(x-1))/sqrt(x-1)/sqrt(x+1);
89 ((x-1)^(3/2)-sqrt(x-1)*(x+1))/(sqrt(x-1)*sqrt(x+1))$
90 ratsimp(%);
91 -2/sqrt(x+1)$
92 ev(x^(a+1/a),ratsimpexpons);
93 x^((a^2+1)/a)$
94 (log(x^2+x)-log(x))^a/log(x+1)^(a/2);
95 (log(x^2+x)-log(x))^a/log(x+1)^(a/2)$
96 radcan(%);
97 log(x+1)^(a/2)$
98 log(a^(2*x)+2*a^x+1)/log(a^x+1);
99 log(a^(2*x)+2*a^x+1)/log(a^x+1)$
100 radcan(%);
102 (%e^x-1)/(%e^(x/2)+1);
103 (%e^x-1)/(%e^(x/2)+1)$
104 radcan(%);
105 %e^(x/2)-1$
106 kill(all);
107 done$
108 combine(a/x+b/x+a/y+b/y);
109 (b+a)/y+(b+a)/x$
110 x/(x-y)^2-1/(x-y)-f(x)/(x-y)^3;
111 -1/(x-y)+x/(x-y)^2-f(x)/(x-y)^3$
112 multthru((x-y)^3,%);
113 -(x-y)^2+x*(x-y)-f(x)$
114 ratexpand(%);
115 -y^2+x*y-f(x)$
116 ((a+b)^10*s^2+2*a*b*s+(a*b)^2)/(a*b*s^2);
117 ((b+a)^10*s^2+2*a*b*s+a^2*b^2)/(a*b*s^2)$
118 multthru(%);
119 2/s+a*b/s^2+(b+a)^10/(a*b)$
120 multthru(a . (b+c . (d+e)+f));
121 a . f+a . c . (e+d)+a . b$
122 ((x+2)^20-2*y)/(x+y)^20+(x+y)^-19-x/(x+y)^20;
123 1/(y+x)^19+((x+2)^20-2*y)/(y+x)^20-x/(y+x)^20$
124 xthru(%);
125 ((x+2)^20-y)/(y+x)^20$
126 2/(x+2)-2/(x+1)+1/(x+1)^2;
127 2/(x+2)-2/(x+1)+1/(x+1)^2$
128 ratsimp(%);
129 -x/(x^3+4*x^2+5*x+2)$
130 partfrac(%,x);
131 2/(x+2)-2/(x+1)+1/(x+1)^2$
132 sort(args(factor(2^63-1)));
133 ''(sort([7^2,73,127,337,92737,649657]))$
134 factor(z^2*(x+2*y)-4*x-8*y);
135 (2*y+x)*(z-2)*(z+2)$
136 x^2*y^2+2*x*y^2+y^2-x^2-2*x-1;
137 x^2*y^2+2*x*y^2+y^2-x^2-2*x-1$
138 block([dontfactor:[x]],factor(%/36/(y^2+2*y+1)));
139 (x^2+2*x+1)*(y-1)/(36*(y+1))$
140 factor(%e^(3*x)+1);
141 (%e^x+1)*(%e^(2*x)-%e^x+1)$
142 factor(x^4+1,a^2-2);
143 (x^2-a*x+1)*(x^2+a*x+1)$
144 factor(x^3+x^2*y^2-x*z^2-y^2*z^2);
145 -((y^2+x)*(z-x)*(z+x))$
146 (x+2)/(x+3)/(x+b)/(x+c)^2;
147 (x+2)/((x+3)*(x+b)*(x+c)^2)$
148 ratsimp(%);
149 (x+2)/(x^4+(2*c+b+3)*x^3+(c^2+(2*b+6)*c+3*b)*x^2+((b+3)*c^2+6*b*c)*x+3*b*c^2)$
150 partfrac(%,x);
151 -((c^2-4*c-b+6)/((c^4+(-2*b-6)*c^3+(b^2+12*b+9)*c^2+(-6*b^2-18*b)*c+9*b^2)
152                *(x+c)))
153  -((c-2)/((c^2+(-b-3)*c+3*b)*(x+c)^2))
154  +(b-2)/(((b-3)*c^2+(6*b-2*b^2)*c+b^3-3*b^2)*(x+b))
155  -(1/(((b-3)*c^2+(18-6*b)*c+9*b-27)*(x+3)))$
156 map('factor,%);
157 -((c^2-4*c-b+6)/((c-3)^2*(c-b)^2*(x+c)))-((c-2)/((c-3)*(c-b)*(x+c)^2))
158                                       +(b-2)/((b-3)*(c-b)^2*(x+b))
159                                       -(1/((b-3)*(c-3)^2*(x+3)))$
160 exp:ratsimp((x^5-1)/(x-1));
161 x^4+x^3+x^2+x+1$
162 subst(a,x,%);
163 a^4+a^3+a^2+a+1$
164 factor(exp,%);
165 (x-a)*(x-a^2)*(x-a^3)*(x+a^3+a^2+a+1)$
166 factor(x^12+1);
167 (x^4+1)*(x^8-x^4+1)$
168 factor(x^99+1);
169 (x+1)*(x^2-x+1)*(x^6-x^3+1)*(x^10-x^9+x^8-x^7+x^6-x^5+x^4-x^3+x^2-x+1)
170      *(x^20+x^19-x^17-x^16+x^14+x^13-x^11-x^10-x^9+x^7+x^6-x^4-x^3+x+1)
171      *(x^60+x^57-x^51-x^48+x^42+x^39-x^33-x^30-x^27+x^21+x^18-x^12-x^9+x^3+1)$
172 ev((x+1)*((u+v)^2+a*(w+z)^2),expand);
173 a*x*z^2+a*z^2+2*a*w*x*z+2*a*w*z+a*w^2*x+v^2*x+2*u*v*x+u^2*x+a*w^2+v^2+2*u*v
174        +u^2$
175 factorsum(%);
176 (x+1)*(a*(z+w)^2+(v+u)^2)$
177 sqfr(4*x^4+4*x^3-3*x^2-4*x-1);
178 (2*x+1)^2*(x^2-1)$
179 gfactor(x^4-1);
180 (x-1)*(x+1)*(x-%i)*(x+%i)$
181 factor(y^20-7*y^19+11*y^18-8*y^17+59*y^16-461*y^15+1694*y^14+198*y^13-3541*
182  y^12+2818*y^11-33327*y^10-11272*y^9-56656*y^8-12672*y^7+433664*y^6+472064*y^5
183  +241664*y^4+131072*y^3+720896*y^2+1835008*y+1048576);
184 (y^8-y^7-11*y^6-19*y^5+101*y^4+76*y^3-176*y^2+64*y+256)
185       *(y^12-6*y^11+16*y^10-39*y^9-19*y^8-75*y^7-315*y^6+300*y^5-304*y^4
186             +2496*y^3+4096*y^2+6144*y+4096)$
187               
188 /* sf bug 1650226 */
189 factor(156*x^7+4808*x^6-182041*x^5-1266489*x^4+43104271*x^3+29839285*x^2-2542327662*x+7826952672);
190 (x-16)*(x+14)*(x+49)*(2*x-11)*(2*x+21)*(3*x-49)*(13*x-63)$
192 /* sf bug 681191 */
193 gfactor(x^4+y^4);
194 (y^2-%i*x^2)*(y^2+%i*x^2)$
196 /* sf bug 696804 */
197 factor(expand((35*x*y^2+19*x^2+25) * (35*x*y^2+25*x^2+19)));
198 (35*x*y^2+19*x^2+25) * (35*x*y^2+25*x^2+19)$
200 /* bug reported on mailing list circa 2007-11-27; bignum in exponent */
202 is (errcatch (rat (x^(2^128))) = []);
203 false;
205 /* [ 1943756 ] ezgcd() never returns. */
206 ezgcd(n^2+(-2*d+c+b+2)*n+d^2+(-c-b-2)*d+c+b+1, -n^2+(2*d-c-b-2)*n-d^2+(c+b+2)*d+(-b-1)*c-b-1);
207 [1,n^2+(-2*d+c+b+2)*n+d^2+(-c-b-2)*d+c+b+1,
208        -n^2+(2*d-c-b-2)*n-d^2+(c+b+2)*d+(-b-1)*c-b-1];
210 /* mailing list 2015-12-10: "problem with poly_pseudo_divide" */
212 (kill (p, q, a, b, c),
213  p : 50688*y[4]^2*y[5]^10+198144*y[4]^4*y[5]^8+292680*y[4]^6*y[5]^6
214          +193464*y[4]^8*y[5]^4+48240*y[4]^10*y[5]^2,
215  q : (-768*y[5]^7)-2016*y[4]^2*y[5]^5-1788*y[4]^4*y[5]^3
216      -540*y[4]^6*y[5],
217  [a, b, c] : ezgcd(p, q));
218 [12*y[5]^3+12*y[4]^2*y[5],
219  4224*y[4]^2*y[5]^7+12288*y[4]^4*y[5]^5+12102*y[4]^6*y[5]^3
220  +4020*y[4]^8*y[5],
221  (-64*y[5]^4)-104*y[4]^2*y[5]^2-45*y[4]^4];
223 is (equal (p, a*b));
224 true;
226 is (equal (q, a*c));
227 true;
229 /* bug reported in mailing list thread "when might resimplify be needed?"
230  * on 2019-03-16
231  */
232 3*(2/3^(3/2))^(2/3);
233 2^(2/3);
235 /* [ 1980715 ] wrong radcan-simplification */
236 radcan(3^(1/6)*9^(1/3));
237 3^(5/6);
239 radcan(81^(1/5)*9^(1/3));
240 3*3^(7/15);
242 /* SF #2905 Assigning variable twice yields different results */
244 block ([var1, var5, var6, diff_expr3],
245   var1 : D^5*Some,
246   var5 : sqrt(var1)*z[D]*r^D,
247   var6 : -sqrt(var1)*r^D/D,
248   diff_expr3 : diff(var5,r),
249   var6*diff_expr3,
250   [var1, var5, var6, diff_expr3, %%]);
251 [D^5*Some,
252  r^D*sqrt(Some*D^5)*z[D],
253  -sqrt(Some*D^5)*r^D/D,
254  D*r^(D - 1)*sqrt(Some*D^5)*z[D],
255  -r^(2*D - 1)*Some*D^5*z[D]];