1 /*************** -*- Mode: MACSYMA; Package: MAXIMA -*- ******************/
2 /***************************************************************************
4 *** Copyright (c) 1984 by William Schelter,University of Texas *****
5 *** All rights reserved *****
6 ***************************************************************************/
9 (kill(all),matchdeclare(a,true));
11 (\^rule1_retval : tellsimp(sin(a)^2,1-cos(a)^2), 0);
17 nonzeroandfreeof(x,e):=is(e # 0 and freeof(x,e));
18 nonzeroandfreeof(x,e):=is(e # 0 and freeof(x,e))$
19 matchdeclare(a,nonzeroandfreeof(x),b,freeof(x));
21 defmatch(linear,a*x+b,x);
23 linear(3*z+(y+1)*z+y^2,z);
24 [b = y^2,a = y+4,x = z]$
25 matchdeclare([a,f],true);
27 constinterval(l,h):=constantp(h-l);
28 constinterval(l,h):=constantp(h-l)$
29 matchdeclare(b,constinterval(a));
33 block(remove(integrate,outative),defmatch(checklimits,'integrate(f,x,a,b)),
34 declare(integrate,outative));
36 'integrate(sin(t),t,x+%pi,x+2*%pi);
37 'integrate(sin(t),t,x+%pi,x+2*%pi)$
39 [b = x+2*%pi,a = x+%pi,x = t,f = sin(t)]$
40 'integrate(sin(t),t,0,x);
41 'integrate(sin(t),t,0,t)$
44 (kill(all),matchdeclare(x,freeof(%i)));
48 (sinrule_retval : tellsimp(sin(%i*x),%i*sinh(x)), 0);
50 trigexpand(sin(x+%i*y));
51 sin(x)*cos(%i*y)+%i*cos(x)*sinh(y)$
56 ev((\^rule2_retval : tellsimp(0^0,1), 0),simp:false);
60 remrule ("^", first (\^rule2_retval));
62 (\^rule3_retval : tellsimp(sin(x)^2,1-cos(x)^2), 0);
74 (\^rule4_retval : tellsimp(sin(a)^2,1-cos(a)^2), 0);
80 (kill(all),nonzeroandfreeof(x,e):=is(e # 0 and freeof(x,e)));
81 nonzeroandfreeof(x,e):=is(e # 0 and freeof(x,e))$
82 matchdeclare(a,nonzeroandfreeof(x),b,freeof(x));
84 defmatch(linear,a*x+b,x);
86 linear(3*z+(y+1)*z+y^2,z);
87 [b = y^2,a = y+4,x = z]$
88 matchdeclare([a,f],true);
90 constinterval(l,h):=constantp(h-l);
91 constinterval(l,h):=constantp(h-l)$
92 matchdeclare(b,constinterval(a));
96 block(remove(integrate,outative),defmatch(checklimits,'integrate(f,x,a,b)),
97 declare(integrate,outative));
99 'integrate(sin(t),t,x+%pi,x+2*%pi);
100 'integrate(sin(t),t,x+%pi,x+2*%pi)$
102 [b = x+2*%pi,a = x+%pi,x = t,f = sin(t)]$
103 'integrate(sin(t),t,0,x);
104 'integrate(sin(t),t,0,t)$
109 (kill(all),matchdeclare([a,a1,a2],true));
111 oneless(x,y):=is(x = y-1);
112 oneless(x,y):=is(x = y-1)$
113 let(a1*a2!,a1!,oneless,a2,a1);
114 ?mtext(a1*a2!,?\ \-\-\>\ ,a1!,?\ where\ ,oneless(a2,a1))$
115 ev(let(a1!/a1,(a1-1)!),letrat);
116 ?mtext(a1!/a1,?\ \-\-\>\ ,(a1-1)!)$
117 ev(letsimp(n*m!*(n-1)!/m),letrat);
119 let(sin(a)^2,1-cos(a)^2);
120 ?mtext(sin(a)^2,?\ \-\-\>\ ,1-cos(a)^2)$
124 cos(x)^4-2*cos(x)^2+1$
125 matchdeclare([a,a1,a2],true);
127 oneless(x,y):=is(x = y-1);
128 oneless(x,y):=is(x = y-1)$
129 let(a1*a2!,a1!,oneless,a2,a1);
130 ?mtext(a1*a2!,?\ \-\-\>\ ,a1!,?\ where\ ,oneless(a2,a1))$
131 ev(let(a1!/a1,(a1-1)!),letrat);
132 ?mtext(a1!/a1,?\ \-\-\>\ ,(a1-1)!)$
133 ev(letsimp(n*m!*(n-1)!/m),letrat);
135 let(sin(a)^2,1-cos(a)^2);
136 ?mtext(sin(a)^2,?\ \-\-\>\ ,1-cos(a)^2)$
140 cos(x)^4-2*cos(x)^2+1$
145 (2*a^2-b)*cos(x+2*y)-(a*b+5)*sin(u-4*x);
146 (2*a^2-b)*cos(2*y+x)+(a*b+5)*sin(4*x-u)$
147 exp1:outofpois(poisexpt(%,2));
148 1/2*(2*a^2-b)^2*cos(4*y+2*x)-(2*a^2-b)*(-a*b-5)*sin(2*y+5*x-u)
149 +(2*a^2-b)*(-a*b-5)*sin(2*y-3*x+u)
150 -1/2*(-a*b-5)^2*cos(8*x-2*u)+1/2*(-a*b-5)^2
155 ratsimp(outofpois(poisint(exp1,y)));
156 ''(ratsimp(((-1)*(2*a^2-b)*(-5-a*b)*cos(u-3*x+2*y))/2+((2*a^2-b)*(-5-a*b)*cos(-u+5*x+2*y))/2+((2*a^2-b)^2*sin(2*x+4*y))/8))$
158 ratsimp(outofpois(poissimp(%)));
159 ''(ratsimp(1/8*(2*a^2-b)^2*sin(4*y+2*x)+1/2*(2*a^2-b)*(-a*b-5)*cos(2*y+5*x-u)
160 -1/2*(2*a^2-b)*(-a*b-5)*cos(2*y-3*x+u)))$
162 poissimp(sin(x)^5+cos(x)^5);
163 1/16*sin(5*x)+1/16*cos(5*x)-5/16*sin(3*x)+5/16*cos(3*x)+5/8*sin(x)+5/8*cos(x)$
168 /* test for bug [ 1648352 ] rules and pattern bug */
171 matchdeclare (aa, true, gg, lambda([yy], evenp(yy) and (yy > 1))),
172 let (foo(aa)^gg, (1 - bar(aa)^2)^(gg/2)),
183 bar(x)^4 - 2*bar(x)^2 + 1;
185 /* letsimp confused by debug stuff in expression car
186 * mailing list 2012-12-23: "let(simp) behaves different when loaded from batch file"
189 test() := block([expr],
191 expr : diff(f(x), x),
192 F(xx) := at(expr, [x = xx]),
193 let(at(diff(f(x),x),[x=0]),5),