1 /*************** -*- Mode: MACSYMA; Package: MAXIMA -*- ******************/
2 /***************************************************************************
4 *** Copyright (c) 1984 by William Schelter,University of Texas *****
5 *** All rights reserved *****
6 ***************************************************************************/
9 kill(functions,arrays,values);
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);
17 (sqrt(-4)+sqrt(2.25))^2;
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;
31 'diff(y^2+x*y+x^2,x,2,y,1);
32 'diff(y^2+x*y+x^2,x,2,y,1)$
46 2.5 > 1.772453850905516;
47 /* tops 20 :2.5 > 1.77245384$ */
50 zeroequiv(sin(2*x)-2*sin(x)*cos(x),x);
54 zeroequiv(log(a*b)-log(a)-log(b),a);
56 (1/(x+y)^4-3/(y+z)^3)^2;
57 (1/(y+x)^4-3/(z+y)^3)^2$
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$
67 x^7+7*x^6+21*x^5+35*x^4+35*x^3+21*x^2+7*x+1$
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);
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)$
77 x/(x^2+2*x+1)-1/(x^2+2*x+1)+1/(x-1)$
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)$
83 sin(1/(x+1)) = %e*x^2$
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))$
92 ev(x^(a+1/a),ratsimpexpons);
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)$
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)$
102 (%e^x-1)/(%e^(x/2)+1);
103 (%e^x-1)/(%e^(x/2)+1)$
108 combine(a/x+b/x+a/y+b/y);
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$
113 -(x-y)^2+x*(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)$
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$
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$
129 -x/(x^3+4*x^2+5*x+2)$
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);
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))$
141 (%e^x+1)*(%e^(2*x)-%e^x+1)$
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)$
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)$
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)
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)))$
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));
165 (x-a)*(x-a^2)*(x-a^3)*(x+a^3+a^2+a+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
176 (x+1)*(a*(z+w)^2+(v+u)^2)$
177 sqfr(4*x^4+4*x^3-3*x^2-4*x-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)$
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)$
194 (y^2-%i*x^2)*(y^2+%i*x^2)$
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))) = []);
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
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
221 (-64*y[5]^4)-104*y[4]^2*y[5]^2-45*y[4]^4];
229 /* bug reported in mailing list thread "when might resimplify be needed?"
235 /* [ 1980715 ] wrong radcan-simplification */
236 radcan(3^(1/6)*9^(1/3));
239 radcan(81^(1/5)*9^(1/3));
242 /* SF #2905 Assigning variable twice yields different results */
244 block ([var1, var5, var6, diff_expr3],
246 var5 : sqrt(var1)*z[D]*r^D,
247 var6 : -sqrt(var1)*r^D/D,
248 diff_expr3 : diff(var5,r),
250 [var1, var5, var6, diff_expr3, %%]);
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]];