Windows installer: update wxMaxima.
[maxima/cygwin.git] / tests / rtest9a.mac
blobf1423c0e04210ff0d8a1247c6160b2c0688c5c5e
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 deftaylor(f(x),x^2+sum(x^i/(2^i*i!^2),i,4,inf));
12 [f]$
13 taylor(%e^sqrt(f(x)),x,0,4);
14 1+x+x^2/2+3073*x^3/18432+12817*x^4/307200$
16 ev(x+sin(3*x)/sin(x),trigexpand,expand);
17 -sin(x)^2+3*cos(x)^2+x$
18 trigexpand(sin(10*x+y));
19 cos(10*x)*sin(y)+sin(10*x)*cos(y)$
20 -sin(x)^2+3*cos(x)^2+x;
21 -sin(x)^2+3*cos(x)^2+x$
22 expand(trigreduce(%));
23 2*cos(2*x)+x+1$
24 declare(j,integer,e,even,o,odd);
25 done$
26 sin(x+(e+1/2)*%pi),expand;
27 cos(x)$
28 sin(x+(o+1/2)*%pi),expand;
29 -cos(x)$
30 (linel:500,diff(exp(x^2+y)/(x+y),x,2));
31 4*x^2*%e^(y+x^2)/(y+x)+2*%e^(y+x^2)/(y+x)-4*x*%e^(y+x^2)/(y+x)^2 +2*%e^(y+x^2)/(y+x)^3$
33 sconcat(optimize(%));
34 "block([%1,%2,%3,%4],%1:y+x,%2:x^2,%3:%e^(y+%2),%4:1/%1,4*%2*%4*%3+2*%4*%3-(4*x*%3)/%1^2+(2*%3)/%1^3)"$
36 linel:79;
37 79$
38 laplace(%e^(2*t+a)*sin(t)*t,t,s);
39 %e^a*(2*s-4)/(s^2-4*s+5)^2$
40 'integrate(sinh(a*x)*f(t-x),x,0,t)+b*f(t) = t^2;
41 'integrate(f(t-x)*sinh(a*x),x,0,t)+b*f(t) = t^2$
43 expand(laplace(%,t,s),0,0);
44 ''(expand(b*laplace(f(t),t,s)+a*laplace(f(t),t,s)/(s^2-a^2) = 2/s^3,0,0))$
46 linsolve([%],['laplace(f(t),t,s)]);
47 ['laplace(f(t),t,s) = (2*s^2-2*a^2)/(b*s^5+(a-a^2*b)*s^3)]$
49 (exp : %,0);
52 assume(a>0,b>0,a*b>1);
53 [a>0,b>0,a*b>1];
54 ilt(ev(exp[1]),s,t);
55 f(t)=-2*cosh(sqrt(a*b*(a*b-1))*t/b)/(a^3*b^2-2*a^2*b+a)+a*t^2/(a*b-1)+2/(a^3*b^2-2*a^2*b+a)$
56 forget(a>0,b>0,a*b>1);
57 [a>0,b>0,a*b>1];
59 /* bug reported to mailing list 2015-02-16: expand phenomenon */
61 block ([f1, f2], f1:y=(x+1)*(x+3), f2:expand(f1), string (expand(f1)=expand(f2)));
62 "(y = x^2+4*x+3) = (y = x^2+4*x+3)";
64 string ((a = b) = (c = d));
65 "(a = b) = (c = d)";
67 /* following is supposed to test pretty printing code path
68  * not sure if embedded newline will be recognized appropriately on Windows
69  */
70 block ([s, stuff],
71   with_default_2d_display( 
72     s : make_string_output_stream (),
73     with_stdout (s, print ((a = b) = (c = d))),
74     stuff : get_output_stream_string (s),
75     close (s),
76     stuff));
77 "(a = b) = (c = d) 
80 infix ("foo");
81 "foo";
83 string ((a foo b) foo (c foo d));
84 "(a foo b) foo (c foo d)";
86 /* following is supposed to test pretty printing code path
87  * not sure if embedded newline will be recognized appropriately on Windows
88  */
89 block ([s, stuff],
90   with_default_2d_display( 
91     s : make_string_output_stream (),
92     with_stdout (s, print ((a foo b) foo (c foo d))),
93     stuff : get_output_stream_string (s),
94     close (s),
95     stuff));
96 "(a foo b) foo (c foo d) 
99 kill ("foo");
100 done;
102 /* mailing list 2015-09-08 and SF bug #3019: "transfer function" */
104 (verify_display_2d (expr, expected_output) :=
105   block ([S, output],
106     with_default_2d_display
107      (S : make_string_output_stream (),
108       with_stdout (S, print (expr)),
109       output : get_output_stream_string (S),
110       close (S),
111       if is (output = expected_output) then true else [expected_output, output])),
112  verify_display_1d (expr, expected_output) :=
113    block ([output : string (expr)], if is (output = expected_output) then true else [expected_output, output]),
114  0);
117 block ([powerdisp : false],
118   verify_display_2d ((x+1)/(x+2),
119 "x + 1
120 ----- 
121 x + 2
122 "));
123 true;
125 block ([powerdisp : true],
126   verify_display_2d ((x+1)/(x+2),
127 "1 + x
128 ----- 
129 2 + x
130 "));
131 true;
133 block ([powerdisp : false], verify_display_1d ((x+1)/(x+2), "(x+1)/(x+2)"));
134 true;
136 block ([powerdisp : true], verify_display_1d ((x+1)/(x+2), "(1+x)/(2+x)"));
137 true;
139 (H : ( n2 * s^2 + n1 * s + n0 ) / ( d2 * s^2 + d1 * s + d0 ), 0);
142 block ([powerdisp : false], verify_display_2d (H,
143 "    2
144 n2 s  + n1 s + n0
145 ----------------- 
146     2
147 d2 s  + d1 s + d0
148 "));
149 true;
151 block ([powerdisp : true], verify_display_2d (H,
152 "                2
153 n0 + n1 s + n2 s
154 ----------------- 
155                 2
156 d0 + d1 s + d2 s
157 "));
158 true;
160 block ([powerdisp : false], verify_display_1d (H, "(n2*s^2+n1*s+n0)/(d2*s^2+d1*s+d0)"));
161 true;
163 block ([powerdisp : true], verify_display_1d (H, "(n0+n1*s+n2*s^2)/(d0+d1*s+d2*s^2)"));
164 true;
167 /* mailing list 2015-09-08: "Maxima 5.37.1 changes in behaviour when simp:false" */
169 simp:false;
170 false;
172 (p:1+x,
173  [?second (p), ?third (p)]);
174 [1, x];
176 string(p);
177 "1+x";
179 tex(p, false);
180 "$$1+x$$
183 simp : true;
184 true;
186 (p:1+x,
187  [?second (p), ?third (p)]);
188 [1, x];
190 string(p);
191 "x+1";
193 tex(p, false);
194 "$$x+1$$
197 block ([powerdisp : false], verify_display_2d (diff (x^n, x),
198 "   n - 1
199 n x      
200 "));
201 true;
203 block ([powerdisp : true], verify_display_2d (diff (x^n, x),
204 "   (- 1) + n
205 n x          
206 "));
207 true;
209 block ([powerdisp : false], verify_display_1d (diff (x^n, x), "n*x^(n-1)"));
210 true;
212 block ([powerdisp : true], verify_display_1d (diff (x^n, x), "n*x^((-1)+n)"));
213 true;
215 /* mailing list 2015-09-04: "Inconsistent ordering: (x+1)^2 becomes (1+x)^2, but x+1 stays x+1" */
217 block ([powerdisp : false], verify_display_2d ((x+1)^2,
218 "       2
219 (x + 1)  
220 "));
221 true;
223 block ([powerdisp : true], verify_display_2d ((x+1)^2,
224 "       2
225 (1 + x)  
226 "));
227 true;
229 block ([powerdisp : false], verify_display_1d ((x+1)^2, "(x+1)^2"));
230 true;
231 block ([powerdisp : true], verify_display_1d ((x+1)^2, "(1+x)^2"));
232 true;
234 block ([powerdisp : false], verify_display_2d ((x^3+x^2+x+1)^2,
235 "  3    2         2
236 (x  + x  + x + 1)  
237 "));
238 true;
240 block ([powerdisp : true], verify_display_2d ((x^3+x^2+x+1)^2,
241 "          2    3 2
242 (1 + x + x  + x )  
243 "));
244 true;
246 block ([powerdisp : false], verify_display_1d ((x^3+x^2+x+1)^2, "(x^3+x^2+x+1)^2"));
247 true;
248 block ([powerdisp : true], verify_display_1d ((x^3+x^2+x+1)^2, "(1+x+x^2+x^3)^2"));
249 true;
251 block ([powerdisp : false], verify_display_2d (x+1,
252 "x + 1 
253 "));
254 true;
256 block ([powerdisp : true], verify_display_2d (x+1,
257 "1 + x 
258 "));
259 true;
261 block ([powerdisp : false], verify_display_1d (x+1, "x+1"));
262 true;
263 block ([powerdisp : true], verify_display_1d (x+1, "1+x"));
264 true;
266 block ([powerdisp : false], verify_display_2d (x^3+x^2+x+1,
267 " 3    2
268 x  + x  + x + 1 
269 "));
270 true;
272 block ([powerdisp : true], verify_display_2d (x^3+x^2+x+1,
273 "         2    3
274 1 + x + x  + x  
275 "));
276 true;
278 block ([powerdisp : false], verify_display_1d (x^3+x^2+x+1, "x^3+x^2+x+1"));
279 true;
280 block ([powerdisp : true], verify_display_1d (x^3+x^2+x+1, "1+x+x^2+x^3"));
281 true;
283 block ([powerdisp : false], verify_display_2d (2^(x+1),
284 " x + 1
285 2      
286 "));
287 true;
289 block ([powerdisp : true], verify_display_2d (2^(x+1),
290 " 1 + x
291 2      
292 "));
293 true;
295 block ([powerdisp : false], verify_display_1d (2^(x+1), "2^(x+1)"));
296 true;
297 block ([powerdisp : true], verify_display_1d (2^(x+1), "2^(1+x)"));
298 true;
300 block ([powerdisp : false], verify_display_2d (2^(x^3+x^2+x+1),
301 "  3    2
302  x  + x  + x + 1
303 2                
304 "));
305 true;
307 block ([powerdisp : true], verify_display_2d (2^(x^3+x^2+x+1),
308 "          2    3
309  1 + x + x  + x
310 2                
311 "));
312 true;
314 block ([powerdisp : false], verify_display_1d (2^(x^3+x^2+x+1), "2^(x^3+x^2+x+1)"));
315 true;
316 block ([powerdisp : true], verify_display_1d (2^(x^3+x^2+x+1), "2^(1+x+x^2+x^3)"));
317 true;
319 /* SF bug #3046 "Changes of behaviour with simp:false" */
321 block ([simp:false], string((3/6)*x));
322 "(3/6)*x";
324 string (lambda ([], (2/2)*u));
325 "lambda([],(2/2)*u)";