1 /*************** -*- Mode: MACSYMA; Package: MAXIMA -*- ******************/
2 /***************************************************************************
4 *** Copyright (c) 1984 by William Schelter,University of Texas *****
5 *** All rights reserved *****
6 ***************************************************************************/
9 /* -*- Mode: MACSYMA -*- */
10 /* batch("me:test6a.mac");
11 It asked is a pos answred yes
12 and is i+1 zero or nonzero and I answered nonzero
13 so should add assume (a>0,not(equal(i+1,0))) */
17 (%pi*x^3*erf(x)+(sqrt(%pi)*x^2+sqrt(%pi))*%e^-x^2)/(3*%pi);
18 ev(diff(%,x),ratsimp);
22 'integrate(%e^(sqrt(a)*sqrt(y)),y,0,4);
23 'integrate(%e^(sqrt(a)*sqrt(y)),y,0,4);
24 changevar(%,y-z^2/a,z,y);
25 /* on lispm -2*('integrate(z*%e^abs(z),z,-2*sqrt(a),0))/a; */
26 - 'integrate(2*z*%e^abs(z)/a,z,-2*sqrt(a),0);
33 'integrate(f(x),x,a,b)+x;
34 'integrate(f(x),x,a,b)+x;
47 27*y^3+54*x*y^2+36*x^2*y+y+8*x^3+x+1;
48 27*y^3+54*x*y^2+36*x^2*y+y+8*x^3+x+1;
57 'limit(f(x)^g(x+1),x,0,minus);
58 'limit(f(x)^g(x+1),x,0,minus);
61 'limit(f(x)^g(x+1),x,0,minus);
62 'limit(f(x)^g(x+1),x,0,minus);
63 is(inpart(%,0) = nounify(limit));
68 b^4+4*a*b^3+6*a^2*b^2+4*a^3*b+a^4;
72 b^2*y^2+2*a*b*y^2+a^2*y^2+2*b^2*x*y+4*a*b*x*y+2*a^2*x*y+b^2*x^2+2*a*b*x^2+a^2*x^2;
74 (b^4+4*a*b^3+6*a^2*b^2+4*a^3*b+a^4)/(b^2*y^2+2*a*b*y^2+a^2*y^2+2*b^2*x*y+4*a*b*x*y+2*a^2*x*y+b^2*x^2+2*a*b*x^2+a^2*x^2);
78 (b^4+4*a*b^3+6*a^2*b^2+4*a^3*b+a^4)/(b^2*y^2+2*a*b*y^2+a^2*y^2+?mbox(2*b^2*x*y)+4*a*b*x*y+2*a^2*x*y+b^2*x^2+2*a*b*x^2+a^2*x^2);
94 subst(a,x+y,x+(x+y)^2+y);
100 subst(x = 0,diff(sin(x),x));
102 errcatch(ev(diff(sin(x),x),x = 0));
104 (assume(not(equal(i,-1))),0);
106 ev(integrate(x^i,x),i = -1);
108 errcatch(subst(-1,i,integrate(x^i,x)));
114 ratsubst(a,x*y^2,x^4*y^8+x^4*y^3);
116 1+cos(x)+cos(x)^2+cos(x)^3+cos(x)^4;
117 cos(x)^4+cos(x)^3+cos(x)^2+cos(x)+1;
118 ratsubst(1-sin(x)^2,cos(x)^2,%);
119 sin(x)^4-3*sin(x)^2+cos(x)*(2-sin(x)^2)+3;
120 ratsubst(1-cos(x)^2,sin(x)^2,sin(x)^4);
121 cos(x)^4-2*cos(x)^2+1;
123 /* SF bug #2907: ratsubst(z, sin(x + 1), 0) crashes when radsubstflag = true */
125 ratsubst (z, sin(x + 1), 0), radsubstflag=true;
128 ratsubst (z, sin(2*x), 0), radsubstflag=true;
131 ratsubst (z, log(x + 1), 0), radsubstflag=true;
134 ratsubst (u, sqrt(x), x), radsubstflag=true;
137 /* additional ratsubst/radsubstflag cases -- dunno how meaningful these are, oh well */
139 ratsubst (z, sin(x + 1), 1 + sin(x + 1)^2), radsubstflag=false;
142 ratsubst (z, sin(x + 1), 1 + sin(x + 1)^2), radsubstflag=true;
145 ratsubst (z, sqrt(x + 1), 1 + (x + 1)^2), radsubstflag=false;
148 ratsubst (z, sqrt(x + 1), 1 + (x + 1)^2), radsubstflag=true;
151 ratsubst (z, sqrt(x + 1), 1 + (x + 1)^(3/2)), radsubstflag=false;
154 ratsubst (z, sqrt(x + 1), 1 + (x + 1)^(3/2)), radsubstflag=true;
157 /* SF bug #3658: "" */
159 ratsubst (1.1, x, 0.001*cos(x));
165 /* SF bug #3376: fullratsubst doesn't catch infinite recursions
166 In this example, fullratsubst1 should loop exactly lrats_max_iter=30 times,
167 adding a power of b each time.
169 fullratsubst(b*a^2,a^2,a^3), lrats_max_iter=30;
172 /* SF bug #3706: lratsusbst causes bind stack overflow on large lists */
173 block([l:makelist(concat('x,i)=concat('x,i+1),i,0,5000)], lratsubst(l,x0)) $
176 /* SF bug #3154 lratsubst NOT as described in Help file */
177 lratsubst([[a=b,b=c]],a) $
180 /* first argument to lratsbust should throw an error */
181 errcatch(lratsubst([[a=b,b=c],[b=c]],a)) $
184 lratsubst1 ([phi_2 = 1.1], 0.001*cos(phi_2)), numer;
187 /* original example from #3658;
188 * note that this assumes load(lrats) already.
189 * result is not checked, just whether or not it runs without error.
191 block ([mat21,theta_1,mat22,phi_2,theta_2,mat23,t,t1,t2,fl,theta1,theta2,phi2,tt],
192 [mat21:matrix([cos(theta_1/2),
193 %i*sin(theta_1/2)],[%i*sin(theta_1/2),
195 mat22:matrix([cos(theta_2/2)
197 %i*sin(theta_2/2)*exp(%i*phi_2/2)],
198 [%i*sin(theta_2/2)*exp(-%i*phi_2/2),cos(theta_2/2)
201 t:expand(mat23[2,2]*mat23[1,1]),
202 t1:expand(demoivre(t)),
203 t2:trigsimp(trigreduce(2*t1-1))],
205 for theta1:0 thru %pi step 1.1 do
206 for theta2:0 thru %pi step 1.1 do
207 for phi2:0 thru 2*%pi step 1.1
208 do (tt:float(ev(lratsubst([theta_1=theta1,theta_2=theta2,phi_2=phi2],
209 abs(t2-(cos(theta_1)*cos(theta_2) - sin(theta_1)*sin(theta_2)*cos(phi_2)))),
211 if tt>1e-5 then(fl:false,disp(tt))),
216 /* SF bug #2012: "Lisp stack overflow with dpart." */
221 /* SF bug #3390: "?great mishandles box" */
223 ?great(box(x+t),-box(x+t));
226 ?great(-box(x+t),box(x+t));