Merge branch 'rtoy-mathjax-for-lapack'
[maxima.git] / tests / rtest6b.mac
blobb032afd2db8ba469ebabb5dc8376f9e8cbb3304d
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;
12 1/(x^2+2);
13 1/(x^2+2)$
14 substpart(3/2,%,2,1,2);
15 1/(x^(3/2)+2)$
16 27*y^3+54*x*y^2+36*x^2*y+y+8*x^3+x+1;
17 27*y^3+54*x*y^2+36*x^2*y+y+8*x^3+x+1$
18 substpart(factor(piece),%,[1,2,3,5]);
19 (3*y+2*x)^3+y+x+1$
20 1/x+y/x-1/z;
21 -1/z+y/x+1/x$
22 substpart(xthru(piece),%,[2,3]);
23 (y+1)/x-1/z$
24 substpart("+",%,1,0);
25 -1/z+y+x+1$
26 ratsimp((k^2*x^2-1)*(cos(x)+eps)/(3*k+n[1])/(5*k-n[2]));
27 ((k^2*x^2-1)*cos(x)+eps*k^2*x^2-eps)/(15*k^2+(5*n[1]-3*n[2])*k-n[1]*n[2])$
28 factor(%);
29 (k*x-1)*(k*x+1)*(cos(x)+eps)/((3*k+n[1])*(5*k-n[2]))$
30 substpart(ratsimp(piece),%,1,[1,2]);
31 (k^2*x^2-1)*(cos(x)+eps)/((3*k+n[1])*(5*k-n[2]))$
32 -substpart(-piece,%,1,1);
33 -((1-k^2*x^2)*(cos(x)+eps)/((3*k+n[1])*(5*k-n[2])))$
34 a+b/(x*(y+(a+b)*x)+1);
35 b/(x*(y+(b+a)*x)+1)+a$
36 substpart(multthru(piece),%,1,2,1);
37 b/(x*y+(b+a)*x^2+1)+a$
38 x . 'diff(f(x),x,2);
39 x . 'diff(f(x),x,2)$
40 substinpart(d^2,%,2);
41 x . d^2$
42 substinpart(f1,f[1](x+1),0);
43 f1(x+1)$
45 /* SF bug #2667: "tex1 of f(x)^n" */
47 simp:false $
48 false $
50 tex1 (sqrt(x)^n);
51 "\\sqrt{x}^{n}";
53 simp:true $
54 true $
56 tex1(sin(x)^2);
57 "\\sin ^2x";
59 tex1(f(x)^2);
60 "f\\left(x\\right)^2";
62 tex1(sin(x)^n);
63 "\\sin ^{n}x";
65 tex1(f(x)^n);
66 "f\\left(x\\right)^{n}";
68 tex1(sin(x)^-1);
69 "{{1}\\over{\\sin x}}";
71 tex1(f(x)^-1);
72 "{{1}\\over{f\\left(x\\right)}}";
74 tex1(sin(x)^-2);
75 "{{1}\\over{\\sin ^2x}}";
77 tex1(f(x)^-2);
78 "{{1}\\over{f\\left(x\\right)^2}}";
80 /* see: https://stackoverflow.com/questions/66056058/wxmaxima-texput-for-powers-of-expressions
81  */
83 logexpand: false; /* disable log simplifications */
84 false;
86 foo: map (tex1, [log(x), log(x+1), log(x)^n]);
87 ["\\log x","\\log \\left(x+1\\right)","\\left(\\log x\\right)^{n}"];
89 texput (log, "\\ln ");
90 "\\ln ";
92 bar: map (tex1, [log(x), log(x+1), log(x)^n]);
93 ["\\ln x","\\ln \\left(x+1\\right)","\\left(\\ln x\\right)^{n}"];
95 /* verify that log is just as it was before but with \ln instead of \log */
97 if bar = map (lambda ([s], ssubst ("ln", "log", s)), foo) then true else bar;
98 true;
100 /* there's no user-level interface for this, and :lisp isn't recognized in test scripts, so ... */
101 block([simp:false], ?\*tex\-mexpt\-trig\-like\-fns\*: ?cons(log, ?\*tex\-mexpt\-trig\-like\-fns\*), 0);
104 baz: map (tex1, [log(x), log(x+1), log(x)^n]);
105 ["\\ln x","\\ln \\left(x+1\\right)","\\ln ^{n}x"];
107 /* verify that now, log acts just like tan in tex output */
109 map (lambda ([s], ssubst ("ln", "tan", s)), map (tex1, [tan(x), tan(x+1), tan(x)^n]));
110 ''baz;
112 /* SF bug #4388: "tex() output under simp:false, incorrect placement of `+`" */
114 (kill (x, y, z, a, b, c), simp: false, 0);
117 tex1 (x^(+5));
118 "x^{+5}";
120 tex1 (sin(+x));
121 "\\sin \\left(+x\\right)";
123 tex1 ([+x, +y, +z]);
124 "\\left[ +x , +y , +z \\right] ";
126 tex1 (abs (+a));
127 "\\left| +a\\right| ";
129 tex1(a + + b);
130 "a+\\left(+b\\right)";
132 tex1 (+a/b);
133 "{{+a}\\over{b}}";
135 tex1(+(a/b));
136 "+{{a}\\over{b}}";
138 tex1((+a)/b);
139 "{{+a}\\over{b}}";
141 tex1((+a)/(+b));
142 "{{+a}\\over{+b}}";
144 tex1 (x^(-5));
145 "x^ {- 5 }";
147 tex1 (sin(-x));
148 "\\sin \\left(-x\\right)";
150 tex1 ([-x, -y, -z]);
151 "\\left[ -x , -y , -z \\right] ";
153 tex1 (abs (-a));
154 "\\left| -a\\right| ";
156 tex1(a - - b);
157 "a-\\left(-b\\right)";
159 tex1 (-a/b);
160 "{{-a}\\over{b}}";
162 tex1(-(a/b));
163 "-\\left({{a}\\over{b}}\\right)";
165 tex1((-a)/b);
166 "{{-a}\\over{b}}";
168 tex1((-a)/(-b));
169 "{{-a}\\over{-b}}";
171 (reset (simp), 0);
174 /* restore TeX properties */
176 (kill (log),
177  ?pop (?\*tex\-mexpt\-trig\-like\-fns\*),
178  0);
181 (reset (), 0);