1 /*************** -*- Mode: MACSYMA; Package: MAXIMA -*- ******************/
2 /***************************************************************************
4 *** Copyright (c) 1984 by William Schelter,University of Texas *****
5 *** All rights reserved *****
6 ***************************************************************************/
11 integrate(x^(5/4)/(x+1)^(5/2),x,0,inf);
13 gradef(q(x),sin(x^2));
16 'diff(r(x),x,1)*sin(r(x)^2)/q(r(x));
20 ?nformat(?complex(1,2));
22 ?nformat(?/(1,2)); /* ?/(1,2) equivalent to (/ 1 2) in Lisp */
25 ?typep(interval(1,2),?ri);
27 is(part(?complex(1,2),0)="+");
30 /* bug reported to mailing list 2013-05-22 */
33 a : make_array (fixnum, 3),
34 L : buildq ([a], lambda ([x], a[x])),
35 print (L, L(0))); /* print(L) --> calls NFORMAT and therefore tickles bug */
38 /* expressions like f(x)(y) */
40 (kill (f, x, y), f(x)(y));
43 (f(x)(y), [op (%%), args (%%)]);
46 (f(x)(y), [op (op (%%)), args (op (%%))]);
52 (kill (z), f(x)(y)(z));
55 (f(x)(y)(z), [op (%%), args (%%), op (op (%%)), args (op (%%)), op (op (op (%%))), args (op (op (%%)))]);
56 [f(x)(y), [z], f(x), [y], f, [x]];
58 ev (f(x)(y), f(u) := buildq ([u], lambda ([v], v*u)));
64 map (f(x), [1, 2, 3]);
65 [f(x)(1), f(x)(2), f(x)(3)];
67 (f(u) := subst (u, 'u, lambda ([v], v^u)),
69 [lambda ([v], v^x), y^x];
72 matchdeclare (xx, integerp),
73 tellsimp (f(xx), subst ('xx = xx, lambda ([a], a - xx))),
75 [lambda ([a], a - 1), y - 1];
77 (remrule (f, all), 0);
80 (matchdeclare ([xx, yy], integerp),
81 tellsimp (f(xx)(yy), yy*xx),
88 /* verify that subscripted functions are formatted without superfluous parentheses
89 * see SF bug #2998: "extra () in display2d:false output"
96 [string (li[2](x)), string (psi[3](y))];
97 ["li[2](x)", "psi[3](y)"];
99 /* further tests for #2998 combining subscripted functions with various user-defined operators */
101 block ([opsies : ["infixie", "prefixie", "postfixie", "naryie", "matchfixie", "nofixie"]],
102 apply (kill, opsies),
103 map (lambda ([f, a], apply (f, [a])), [infix, prefix, postfix, nary, lambda ([a], matchfix (a, a)), nofix], opsies),
104 kill (foo, bar, baz, a, b, c, x, y, z),
108 foo[x, y](a) infixie bar[z](b, c);
109 (foo[x, y](a)) infixie (bar[z](b, c));
111 string ((foo[x, y](a)) infixie (bar[z](b, c)));
112 "foo[x,y](a) infixie bar[z](b,c)";
114 bar[a, a](x, x) naryie baz[a](x, y) naryie prefixie foo[a, b](x, y);
115 (bar[a, a](x, x)) naryie (baz[a](x, y)) naryie (prefixie (foo[a, b](x, y)));
117 string ((bar[a, a](x, x)) naryie (baz[a](x, y)) naryie (prefixie (foo[a, b](x, y))));
118 "bar[a,a](x,x) naryie baz[a](x,y) naryie prefixie foo[a,b](x,y)";
120 matchfixie foo[1](z) matchfixie;
121 matchfixie (foo[1](z)) matchfixie;
123 string (matchfixie (foo[1](z)) matchfixie);
124 "matchfixiefoo[1](z)matchfixie";
126 /* ... and with built-in operators */
128 foo[x, y](a)^bar[z](b, c);
129 (foo[x, y](a))^(bar[z](b, c));
131 string ((foo[x, y](a))^(bar[z](b, c)));
132 "foo[x,y](a)^bar[z](b,c)";
134 bar[a, a](x, x) and baz[a](x, y) and not foo[a, b](x, y);
135 (bar[a, a](x, x)) and (baz[a](x, y)) and (not (foo[a, b](x, y)));
137 string ((bar[a, a](x, x)) and (baz[a](x, y)) and (not (foo[a, b](x, y))));
138 "bar[a,a](x,x) and baz[a](x,y) and not foo[a,b](x,y)";
143 string ([ (foo[1](z)) ]);
146 /* mailing list 2015-10-05: "Wrong result from integrate?" */
148 (kill(t, R), integrate(sqrt(sin(t)^2*R^2+(1-cos(t))^2*R^2),t,0,2*%pi));