Windows installer: update wxMaxima.
[maxima/cygwin.git] / tests / rtest7.mac
blob9500a98712028156feee3f5383358949568dd491
1 /*************** -*- Mode: MACSYMA; Package: MAXIMA -*-  ******************/
2 /***************************************************************************
3 ***                                                                    *****
4 ***     Copyright (c) 1984 by William Schelter,University of Texas     *****
5 ***     All rights reserved                                            *****
6 ***************************************************************************/
9 kill(all);
10 done$
11 linechar:%t;
12 %t$
13 atvalue(f(x,y),[x = 0,y = 1],a^2);
14 a^2$
15 atvalue('diff(f(x,y),x),x = 0,y+1);
16 \@2+1$
17 printprops(all,atvalue);
18 done$
19 diff(4*f(x,y)^2-u(x,y)^2,x);
20 8*f(x,y)*'diff(f(x,y),x,1)-2*u(x,y)*'diff(u(x,y),x,1)$
21 at(%,[x = 0,y = 1]);
22 16*a^2-2*u(0,1)*(''(at('diff(u(x,y),x,1),[x = 0,y = 1])))$
23 atvalue(f(x,y),[x = 0,y = 1],a^2);
24 a^2$
25 atvalue('diff(f(x,y),x),x = 0,y+1);
26 \@2+1$
27 printprops(all,atvalue);
28 done$
29 diff(4*f(x,y)^2-u(x,y)^2,x);
30 8*f(x,y)*'diff(f(x,y),x,1)-2*u(x,y)*'diff(u(x,y),x,1)$
31 at(%,[x = 0,y = 1]);
32 16*a^2-2*u(0,1)*(''(at('diff(u(x,y),x,1),[x = 0,y = 1])))$
33 listofvars(f(x[1]+y)/g^(2+a));
34 [g,a,x[1],y]$
35 coeff(2*a*tan(x)+tan(x)+b = 5*tan(x)+3,tan(x));
36 2*a+1 = 5$
37 coeff(y+x*%e^x+1,x,0);
38 y+1$
39 a*x+b*x+5;
40 b*x+a*x+5$
41 ratcoef(%,a+b);
43 islinear(exp,var):=block([c],c:bothcoef(rat(exp,var),var),
44          is(freeof(var,c) and c[1] # 0));
45 islinear(exp,var):=block([c],c:bothcoef(rat(exp,var),var),
46          is(freeof(var,c) and c[1] # 0))$
47 islinear((r^2-(x-r)^2)/x,x);
48 true$
49 (a+b)^4*(1+x*(2*x+(c+d)^2));
50 (b+a)^4*(x*(2*x+(d+c)^2)+1)$
51 (linenum:0,isolate(%,x));
52 %t2*(x*(2*x+%t1)+1)$
53 ratexpand(%);
54 2*%t2*x^2+%t1*%t2*x+%t2$
55 ev(%);
56 2*(b+a)^4*x^2+(b+a)^4*(d+c)^2*x+(b+a)^4$
57 %t1;
58 (d+c)^2;
59 %t2;
60 (b+a)^4;
61 (a+b)*(x+a+b)^2*%e^(x^2+a*x+b);
62 (b+a)*(x+b+a)^2*%e^(x^2+a*x+b)$
63 block([linenum:2],ev(isolate(%,x),exptisolate:true));
64 %t3*%t4*(x+%t3)^2*%e^(x^2+a*x)$
65 %t3;
66 b+a;
67 %t4;
68 %e^b;
69 exp1:integrate(1/(x^3+2),x);
70   -log(x^2-2^(1/3)*x+2^(2/3))/(6*2^(2/3))+atan((2*x-2^(1/3))/(2^(1/3)*sqrt(3)))
71                                         /(2^(2/3)*sqrt(3))
72                                        +log(x+2^(1/3))/(3*2^(2/3))$
73 /* got this at one point but it differentiates ok
74   -2^(1/3)*log(2^(2/3)*x^2-2*x+2*2^(1/3))/12+2^(1/3)*atan((2*2^(2/3)*x-2)/(2*sqrt(3)))/(2*sqrt(3))+2^(1/3)*log(x+2^(1/3))/6; */
75 radcan(diff(%,x));
76 1/(x^3+2);
77 block([linenum:4],pickapart(exp1,1));
78 %t7+%t6+%t5$
79 gamma(7/2);
80 15*sqrt(%pi)/8$
81 numfactor(%);
82 15/8$
83 'diff(y,x,2)+'diff(y,z,3)*2+'diff(y,x,1)*x^2;
84 2*'diff(y,z,3)+'diff(y,x,2)+x^2*'diff(y,x,1)$
85 derivdegree(%,y,x);
87 (%i*v+u)/(f+%i*e)+%e^(%i*alpha);
88 (%i*v+u)/(f+%i*e)+%e^(%i*alpha)$
89 realpart(%);
90 (e*v+f*u)/(f^2+e^2)+cos(alpha)$
91 rectform(sin(2*%i+x));
92 cosh(2)*sin(x)+%i*sinh(2)*cos(x)$
93 polarform(%);
94 sqrt(cosh(2)^2*sin(x)^2+sinh(2)^2*cos(x)^2)
95  *%e^(%i*atan2(sinh(2)*cos(x),cosh(2)*sin(x)))$
96 rectform(log(3+4*%i));
97 log(5)+%i*atan(4/3)$
98 polarform(%);
99 sqrt(log(5)^2+atan(4/3)^2)*%e^(%i*atan(atan(4/3)/log(5)))$
101 %emode:false;
102 false;
103 ev(rectform((2+3.5*%i)^0.25),numer);
104 0.3682587918166914*%i+1.368266274774369;
105 polarform(%);
106 1.416956998795383*%e^(0.2629125531370934*%i);
107 /* %emode:false is needed to keep above answer from being converted out of polar form 
108    before being compared to result of polarform() */
109 %emode:true;
110 true;
112 delete(sin(x),x+sin(x)+y);
113 y+x$
115 /* SF bug 2014436 */
116 at(f(x),[]);
117 f(x)$
119 /* simplification of 'at' */
121 kill (f, g, h, u, v, w, x, y, z, a, b, c);
122 done;
124 at (f (x, y, z), x = a);
125 f (a, y, z);
127 '(at (f (x, y, z), x = a));
128 at (f (x, y, z), x = a);
130 '('at (f (x, y, z), x = a));
131 'at (f (x, y, z), [x = a]);
133 at (f (x, y), z = b);
134 f (x, y);
136 '(at (f (x, y), z = b));
137 at (f (x, y), z = b);
139 '('at (f (x, y), z = b));
140 f (x, y);
142 at ('f (x, y), [x = a, y = b]);
143 'f (a, b);
145 '(at ('f (x, y), [x = a, y = b]));
146 at ('f (x, y), [x = a, y = b]);
148 '('at ('f (x, y), [x = a, y = b]));
149 'at ('f (x, y), [x = a, y = b]);
151 at (diff (f (x, y), x, 1, y, 1), [x = a, y = b]);
152 'at ('diff (f (x, y), x, 1, y, 1), [x = a, y = b]);
154 at (diff (f (x, y), x, 1, y, 1), x = a);
155 'at ('diff (f (x, y), x, 1, y, 1), [x = a]);
157 at (at (diff (f (x, y), x, 1, y, 1), [x = a, y = b]), a = c);
158 'at ('diff (f (x, y), x, 1, y, 1), [x = c, y = b]);
160 at (at (diff (f (x, y), x, 1, y, 1), [x = a, y = b]), c = z);
161 'at ('diff (f (x, y), x, 1, y, 1), [x = a, y = b]);
163 depends (x, [y, z]);
164 [x(y, z)];
166 at (diff (x, y), [u = 1, v = 2, w = 3, z = 4]);
167 'at ('diff (x, y, 1), [z = 4]);
169 at (sum (f(a), a, 1, b), [a = x]);
170 'sum (f(a), a, 1, b);
172 at (sum (f(a), a, 1, b), [b = x]);
173 'sum (f(a), a, 1, x);
175 '('at ('sum (f(a), a, 1, b), [b = x]));
176 'at ('sum (f(a), a, 1, b), [b = x]);
178 at ('integrate (f(x), x), x = y);
179 'at ('integrate (f(x), x), [x = y]);
181 at ('integrate (f(x), x, a, b), x = y);
182 'integrate (f(x), x, a, b);
184 at ('laplace (f(t), t, s), [t = a, s = b]);
185 'laplace (f(t), t, b);
187 a : at (taylor (f(x), x, 0, 3), [x = 7/5]);
188 (343*('at('diff(f(x),x,3),x = 0)))/750+(49*('at('diff(f(x),x,2),x = 0)))/50
189                                       +(7*('at('diff(f(x),x,1),x = 0)))/5+f(0)$
191 b : subst (f = cos, a);
192 (343*('at('diff(cos(x),x,3),x = 0)))/750
193  +(49*('at('diff(cos(x),x,2),x = 0)))/50+(7*('at('diff(cos(x),x,1),x = 0)))/5
194  +1$
196 ev (b, nouns);
197 1/50;
199 (taylor (cos(x), x, 0, 3), ev (%%, x=7/5));
200 ''(rat(1/50)); /* not a vanilla 1/50 ... */
202 kill(all);
203 done;
205 at('at('diff(f(x,a),x,1),x=y),a=z);
206 'at('diff(f(x,z),x,1),x=y);
208 at('at('diff(f(x,a),x,1),x=y),y=z);
209 'at('diff(f(x,a),x,1),x=z);
211 at(diff(f(x),x),s=0);
212 'diff(f(x),x,1);
214 at('diff(f(x,n),x,m),n=2);
215 'diff(f(x,2),x,m);
217 at('diff(f(x,n),x,m),m=2);
218 'diff(f(x,n),x,2);
220 /* from mailing list 2015-12-08: "Evaluate derivative in Maxima" */
222 (kill(all),
223  f1(x):=diff(f(x),x,1),
224  f2(x):=diff(f(x),x,2),
225  x0(s):=mu+s*at(f1(x),x=mu)/(1/sigma^2-s*at(f2(x),x=mu)),
226  g(s,x):=s*f(x)-1/2*((x-mu)/sigma)^2,
227  g2(s,x):=diff(g(s,x),x,2),
228  g0(s):=at(g(s,x),x=x0(s)),
229  g20(s):=at(g2(s,x),x=x0(s)),
230  h(s):=1/sigma*exp(g0(s))*sqrt(1/abs(g20(s))),
231  at(diff(h(s),s,1),s=0));
232 (sigma*abs(sigma)*('at('diff(f(x),x,2),x = mu)))/2+(f(mu)*abs(sigma))/sigma$
234 (h(s):=s*(at(f1(x),x=mu)),
235  at(diff(h(s),s),s=0));
236 'at('diff(f(x),x,1), x=mu);
238 /* SF bug #1085: "Function \"at\" is overly cautious" */
240 at('integrate(f(t),t,0,x),x=0);
243 at('integrate(f(t),t,x,y),[x=a, y=b]);
244 'integrate(f(t),t,a,b);
246 /* SF bug #2302: "'at' applied to definite integral" */
248 at(integrate(f(t),t,0,x),x=0);
251 /* SF bug #3607: "  printprops displays matchdeclare properties incorrectly when value is a lambda" */
253 apply (kill, propvars (matchdeclare));
254 done;
256 matchdeclare (aa, all, bb, integerp, cc, lambda([x], floatnump(x) and x > 0));
257 done;
259 printprops (all, matchdeclare);
260 [all(aa), integerp(bb), lambda([x], floatnump(x) and (x > 0))(cc)];