Rename *ll* and *ul* to ll and ul in intbyterm
[maxima.git] / doc / tutorial / ru / minimal-maxima.tex
blob61a2ef64bcdcf26093bb1b73219e7b7cb1c88098
1 % v. 1.6
2 % (c) 2005 Robert Dodier
3 % (c) 2007 áÌÅËÓÅÊ âÅÛÅÎÏ× (al@beshenov.ru), ÒÕÓÓËÉÊ ÐÅÒÅ×ÏÄ
5 \documentclass[11pt,oneside]{article}
6 %\documentclass[12pt]{article}
7 \usepackage[russian]{babel}
9 \usepackage{cmap}
10 \usepackage[koi8-r]{inputenc}
11 \usepackage[T2A]{fontenc}
13 \usepackage[colorlinks]{hyperref}
15 % ó ÐÏÌÑÍÉ ÐÏ ÕÍÏÌÞÁÎÉÀ ÛÉÒÉÎÙ ÔÅËÓÔÁ ÎÅ È×ÁÔÁÅÔ, ÞÔÏÂÙ ×ÍÅÓÔÉÔØ ËÏÄ
16 % ÐÒÉÍÅÒÏ× Ë ÐÏÓÌÅÄÎÅÍÕ ÒÁÚÄÅÌÕ. éÚ ÔÅÈ ÖÅ ÓÏÏÂÒÁÖÅÎÉÊ ÔÅËÓÔ ÎÁÂÒÁÎ
17 % × 11 ÐÕÎËÔÏ× (× ÏÒÉÇÉÎÁÌÅ --- 12).
18 \setlength{\textwidth}{18cm}
19 \setlength{\textheight}{23cm}
20 \setlength{\headheight}{0cm}
21 \setlength{\headsep}{0cm}
22 \setlength{\topskip}{0cm}
23 \setlength{\voffset}{-1in}
24 \setlength{\oddsidemargin}{-1in}
25 \setlength{\evensidemargin}{-1in}
26 \addtolength{\voffset}{1.5cm}
27 \addtolength{\oddsidemargin}{2cm}
28 \addtolength{\evensidemargin}{2cm}
30 \title{ëÏÒÏÔËÏ Ï Maxima}
31 \author{òÏÂÅÒÔ äÏÄÉÅÒ}
32 \date{}
34 \begin{document}
35 \maketitle
37 \begin{figure}[b]
38 {\flushleft\tiny
39 \rule{50pt}{0.5pt}
41 \copyright~2005 Robert Dodier.\\
42 \copyright~2007 áÌÅËÓÅÊ âÅÛÅÎÏ× (\href{mailto:al@beshenov.ru}{al@beshenov.ru}), ÒÕÓÓËÉÊ ÐÅÒÅ×ÏÄ.\\
43 äÏÍÁÛÎÑÑ ÓÔÒÁÎÉÃÁ Maxima: \url{http://maxima.sourceforge.net/ru/}.\\
45 \end{figure}
47 \section{þÔÏ ÔÁËÏÅ Maxima?}
49 \noindent Maxima~--- ÓÉÓÔÅÍÁ ÄÌÑ ÒÁÂÏÔÙ Ó ×ÙÒÁÖÅÎÉÑÍÉ, ÔÁËÉÍÉ ËÁË $x + y$, $\sin (a + b \pi)$ É
50 $u \cdot v - v \cdot u$.
52 Maxima ÎÅ ÏÓÏÂÏ ÚÁÂÏÔÉÔÓÑ Ï ÓÍÙÓÌÅ ×ÙÒÁÖÅÎÉÑ. ôÏÌØËÏ ÐÏÌØÚÏ×ÁÔÅÌØ ÒÅÛÁÅÔ, ËÁËÏÊ
53 ÓÍÙÓÌ ÎÅÓÅÔ ×ÙÒÁÖÅÎÉÅ.
55 éÎÏÇÄÁ ÔÒÅÂÕÅÔÓÑ ÚÁÄÁÔØ ÚÎÁÞÅÎÉÑ ÎÅÉÚ×ÅÓÔÎÙÍ É ×ÙÞÉÓÌÉÔØ ×ÙÒÁÖÅÎÉÅ~--- Maxima
56 Ó ÒÁÄÏÓÔØÀ ÓÄÅÌÁÅÔ ÜÔÏ. îÏ ÓÉÓÔÅÍÁ Ó ÔÏÊ ÖÅ ÒÁÄÏÓÔØÀ ÏÔÌÏÖÉÔ ÐÒÉÓ×ÁÉ×ÁÎÉÅ
57 ËÏÎËÒÅÔÎÙÈ ÚÎÁÞÅÎÉÊ, ÔÁË ÞÔÏ ×Ù ÍÏÖÅÔÅ ÐÒÏ×ÅÓÔÉ Ó ×ÙÒÁÖÅÎÉÅÍ ÎÅËÏÔÏÒÙÅ ÐÒÅÏÂÒÁÚÏ×ÁÎÉÑ,
58 ÐÏÓÌÅ ÞÅÇÏ ÕÖÅ ÏÐÒÅÄÅÌÉÔØ ÎÅÉÚ×ÅÓÔÎÙÅ (ÉÌÉ ÎÅ ÏÐÒÅÄÅÌÑÔØ ÉÈ ×Ï×ÓÅ).
60 òÁÓÓÍÏÔÒÉÍ ÎÅÓËÏÌØËÏ ÐÒÉÍÅÒÏ×.
62 \begin{enumerate}
64 \item îÕÖÎÏ ÎÁÊÔÉ ÏÂßÅÍ ÛÁÒÁ:
65 % V: 4/3 * %pi * r^3;
66 \begin{verbatim}
67 (%i1) V: 4/3 * %pi * r^3;
69 4 %pi r
70 (%o1) --------
72 \end{verbatim}
74 \item òÁÄÉÕÓ ÒÁ×ÅÎ 10:
75 % r: 10;
76 \begin{verbatim}
77 (%i2) r: 10;
78 (%o2) 10
79 \end{verbatim}
81 \item $V$~--- ÔÏ ÖÅ, ÞÔÏ É ÂÙÌÏ; Maxima ÎÅ ÐÏÍÅÎÑÅÔ $V$, ÅÓÌÉ ÜÔÏ ÎÅ ÕËÁÚÁÔØ:
82 % V;
83 \begin{verbatim}
84 (%i3) V;
86 4 %pi r
87 (%o3) --------
89 \end{verbatim}
91 \item <<Maxima, ÐÅÒÅÓÞÉÔÁÊ, ÐÏÖÁÌÕÊÓÔÁ, $V$>>:
92 % ''V;
93 \begin{verbatim}
94 (%i4) ''V;
95 4000 %pi
96 (%o4) --------
98 \end{verbatim}
100 \item ÷ÍÅÓÔÏ ×ÙÒÁÖÅÎÉÑ ÈÏÔÅÌÏÓØ ÂÙ ×ÉÄÅÔØ ÞÉÓÌÅÎÎÏÅ ÚÎÁÞÅÎÉÅ:
101 % ''V, numer;
102 \begin{verbatim}
103 (%i5) ''V, numer;
104 (%o5) 4188.79020478639
105 \end{verbatim}
107 \end{enumerate}
109 \section{÷ÙÒÁÖÅÎÉÑ}
111 \noindent÷Ó£ × Maxima Ñ×ÌÑÅÔÓÑ ×ÙÒÁÖÅÎÉÑÍÉ, × ÔÏÍ ÞÉÓÌÅ ÍÁÔÅÍÁÔÉÞÅÓËÉÅ ×ÙÒÁÖÅÎÉÑ, ÏÂßÅËÔÙ
112 É ÐÒÏÇÒÁÍÍÎÙÅ ÂÌÏËÉ. ÷ÙÒÁÖÅÎÉÅ~--- ÁÔÏÍ ÌÉÂÏ ÏÐÅÒÁÔÏÒ Ó ÁÒÇÕÍÅÎÔÁÍÉ.
114 áÔÏÍ~--- ÓÉÍ×ÏÌ (ÉÍÑ), ÓÔÒÏËÁ × ËÁ×ÙÞËÁÈ, ÌÉÂÏ ÞÉÓÌÏ (ÃÅÌÏÅ ÉÌÉ Ó ÐÌÁ×ÁÀÝÅÊ ÔÏÞËÏÊ).
116 ÷ÓÅ ×ÙÒÁÖÅÎÉÑ ÎÅ-ÁÔÏÍÙ ÐÒÅÄÓÔÁ×ÌÑÀÔÓÑ × ×ÉÄÅ $\mathit{op}(a_1, \ldots, a_n)$, ÇÄÅ
117 $\mathit{op}$~--- ÉÍÑ ÏÐÅÒÁÔÏÒÁ, Á $a_1, \ldots, a_n$~--- ÅÇÏ ÁÒÇÕÍÅÎÔÙ.
118 ÷ÙÒÁÖÅÎÉÑ ÍÏÇÕÔ ÏÔÏÂÒÁÖÁÔØÓÑ ÐÏ-ÒÁÚÎÏÍÕ, ÎÏ ×ÎÕÔÒÅÎÎÅÅ ÐÒÅÄÓÔÁ×ÌÅÎÉÅ ×ÓÅÇÄÁ ÏÄÉÎÁËÏ×Ï.
119 áÒÇÕÍÅÎÔÙ ×ÙÒÁÖÅÎÉÑ ÍÏÇÕÔ ÂÙÔØ ÁÔÏÍÁÍÉ ÌÉÂÏ ×ÙÒÁÖÅÎÉÑÍÉ ÎÅ-ÁÔÏÍÁÍÉ.
121 íÁÔÅÍÁÔÉÞÅÓËÉÅ ×ÙÒÁÖÅÎÉÑ ×ËÌÀÞÁÀÔ ÍÁÔÅÍÁÔÉÞÅÓËÉÅ ÏÐÅÒÁÔÏÒÙ, ÔÁËÉÅ ËÁË
123 + \; - \; * \; / \; < \; = \; >
125 \noindentÌÉÂÏ ×ÙÞÉÓÌÅÎÉÅ ÆÕÎËÃÉÉ ×ÒÏÄÅ
126 $\mathbf{sin}(x), \mathbf{bessel\_j}(n, x)$. ÷ ÔÁËÉÈ ÓÌÕÞÁÑÈ ÏÐÅÒÁÔÏÒÏÍ Ñ×ÌÑÅÔÓÑ ÆÕÎËÃÉÑ.
128 ïÂßÅËÔÙ × Maxima~--- ÔÏÖÅ ×ÙÒÁÖÅÎÉÑ.
129 óÐÉÓÏË $[a_1, \ldots, a_n]$~--- ×ÙÒÁÖÅÎÉÅ $\mathbf{list}(a_1, \ldots, a_n)$.
130 íÁÔÒÉÃÁ~--- ×ÙÒÁÖÅÎÉÅ
132 \mathbf{matrix}(\mathbf{list}(a_{1,1}, \ldots, a_{1,n}), \ldots, \mathbf{list}(a_{m,1}, \ldots, a_{m,n}))
135 ðÒÏÇÒÁÍÍÎÙÍÉ ÂÌÏËÁÍÉ Ñ×ÌÑÀÔÓÑ ×ÙÒÁÖÅÎÉÑ.
136 âÌÏË ËÏÄÁ $\mathbf{block} (a_1, \ldots, a_n)$~--- ×ÙÒÁÖÅÎÉÅ Ó ÏÐÅÒÁÔÏÒÏÍ $\mathbf{block}$
137 É ÁÒÇÕÍÅÎÔÁÍÉ $a_1, \ldots, a_n$. õÓÌÏ×ÎÁÑ ËÏÎÓÔÒÕËÃÉÑ \mbox{$\mathbf{if\ } a \mathbf{\ then\ } b \mathbf{\ elseif\ } c \mathbf{\ then\ } d$}~--- ×ÙÒÁÖÅÎÉÅ $\mathbf{if}(a, b, c, d)$.
138 ãÉËÌ $\mathbf{for\ } a \mathbf{\ in\ } L \mathbf{\ do\ } S$~--- ×ÙÒÁÖÅÎÉÅ, ÓÏÏÔ×ÅÔÓÔ×ÕÀÝÅÅ
139 $\mathbf{do}(a, L, S)$.
141 æÕÎËÃÉÑ Maxima $\mathbf{op}$ ×ÏÚ×ÒÁÝÁÅÔ ÏÐÅÒÁÔÏÒ ×ÙÒÁÖÅÎÉÑ-ÎÅ-ÁÔÏÍÁ.
142 æÕÎËÃÉÑ $\mathbf{args}$ ×ÒÚ×ÒÁÝÁÅÔ ÁÒÇÕÍÅÎÔÙ ×ÙÒÁÖÅÎÉÑ-ÎÅ-ÁÔÏÍÁ.
143 æÕÎËÃÉÑ $\mathbf{atom}$ ÕËÁÚÙ×ÁÅÔ, Ñ×ÌÑÅÔÓÑ ÌÉ ×ÙÒÁÖÅÎÉÅ ÁÔÏÍÏÍ.
145 òÁÓÓÍÏÔÒÉÍ ÄÒÕÇÉÅ ÐÒÉÍÅÒÙ.
147 \begin{enumerate}
149 \item áÔÏÍÙ~--- ÓÉÍ×ÏÌÙ, ÓÔÒÏËÉ É ÞÉÓÌÁ. ÷ÏÔ ÓÐÉÓÏË Ó ÜÌÅÍÅÎÔÁÍÉ-ÁÔÏÍÁÍÉ:
150 % [a, foo, foo_bar, "Hello, world!", 42, 17.29];
152 \begin{verbatim}
153 (%i2) [a, foo, foo_bar, "Hello, world!", 42, 17.29];
154 (%o2) [a, foo, foo_bar, Hello, world!, 42, 17.29]
155 \end{verbatim}
157 \item íÁÔÅÍÁÔÉÞÅÓËÉÅ ×ÙÒÁÖÅÎÉÑ:
158 % [a + b + c, a * b * c, foo = bar, a*b < c*d];
160 \begin{verbatim}
161 (%i1) [a + b + c, a * b * c, foo = bar, a*b < c*d];
162 (%o1) [c + b + a, a b c, foo = bar, a b < c d]
163 \end{verbatim}
165 \item óÐÉÓËÉ É ÍÁÔÒÉÃÙ.
166 üÌÅÍÅÎÔÁÍÉ ÓÐÉÓËÁ ÉÌÉ ÍÁÔÒÉÃÙ ÍÏÇÕÔ ÂÙÔØ ÌÀÂÙÅ ×ÙÒÁÖÅÎÉÑ, × ÔÏÍ ÞÉÓÌÅ ÓÐÉÓËÉ ÉÌÉ
167 ÍÁÔÒÉÃÙ:
168 % L: [a, b, c, %pi, %e, 1729, 1/(a*d - b*c)];
169 % L2: [a, b, [c, %pi, [%e, 1729], 1/(a*d - b*c)]];
170 % L [7];
171 % L2 [3];
172 % M: matrix ([%pi, 17], [29, %e]);
173 % M2: matrix ([[%pi, 17], a*d - b*c], [matrix ([1, a], [b, 7]), %e]);
174 % M [2][1];
175 % M2 [2][1];
177 \begin{verbatim}
178 (%i1) L: [a, b, c, %pi, %e, 1729, 1/(a*d - b*c)];
180 (%o1) [a, b, c, %pi, %e, 1729, ---------]
181 a d - b c
182 \end{verbatim}
183 % (éÎÁÞÅ ÄÒÏÂØ ÂÕÄÅÔ ÒÁÚÏÒ×ÁÎÁ ÎÁ Ä×Å ÓÔÒÁÎÉÃÙ)
184 \begin{verbatim}
185 (%i2) L2: [a, b, [c, %pi, [%e, 1729], 1/(a*d - b*c)]];
187 (%o2) [a, b, [c, %pi, [%e, 1729], ---------]]
188 a d - b c
189 (%i3) L [7];
191 (%o3) ---------
192 a d - b c
193 (%i4) L2 [3];
195 (%o4) [c, %pi, [%e, 1729], ---------]
196 a d - b c
197 (%i5) M: matrix ([%pi, 17], [29, %e]);
198 [ %pi 17 ]
199 (%o5) [ ]
200 [ 29 %e ]
201 (%i6) M2: matrix ([[%pi, 17], a*d - b*c], [matrix ([1, a], [b, 7]), %e]);
202 [ [%pi, 17] a d - b c ]
204 (%o6) [ [ 1 a ] ]
205 [ [ ] %e ]
206 [ [ b 7 ] ]
207 (%i7) M [2][1];
208 (%o7) 29
209 (%i8) M2 [2][1];
210 [ 1 a ]
211 (%o8) [ ]
212 [ b 7 ]
213 \end{verbatim}
215 \item ðÒÏÇÒÁÍÍÎÙÅ ÂÌÏËÉ~--- ×ÙÒÁÖÅÎÉÑ.
216 $x : y$ ÏÚÎÁÞÁÅÔ ÐÒÉÓ×ÁÉ×ÁÎÉÅ $y$ Ë $x$; ÚÎÁÞÅÎÉÅ ×ÙÒÁÖÅÎÉÑ ÐÒÉÓ×ÁÉ×ÁÎÉÑ~--- $y$.
217 $\mathbf{block}$ ÏÂßÅÄÉÎÑÅÔ ÎÅÓËÏÌØËÏ ×ÙÒÁÖÅÎÉÊ É ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏ ÉÈ ×ÙÞÉÓÌÑÅÔ;
218 ÚÎÁÞÅÎÉÅ ÂÌÏËÁ ÓÏÏÔ×ÅÔÓÔ×ÕÅÔ ÚÎÁÞÅÎÉÀ ÅÇÏ ÐÏÓÌÅÄÎÅÇÏ ×ÙÒÁÖÅÎÉÑ.
219 % (a: 42) - (b: 17);
220 % [a, b];
221 % block ([a], a: 42, a^2 - 1600) + block ([b], b: 5, %pi^b);
222 % (if a > 1 then %pi else %e) + (if b < 0 then 1/2 else 1/7);
224 \begin{verbatim}
225 (%i1) (a: 42) - (b: 17);
226 (%o1) 25
227 (%i2) [a, b];
228 (%o2) [42, 17]
229 (%i3) block ([a], a: 42, a^2 - 1600) + block ([b], b: 5, %pi^b);
231 (%o3) %pi + 164
232 (%i4) (if a > 1 then %pi else %e) + (if b < 0 then 1/2 else 1/7);
234 (%o4) %pi + -
236 \end{verbatim}
238 \item $\mathbf{op}$ ×ÏÚ×ÒÁÝÁÅÔ ÏÐÅÒÁÔÏÒ, $\mathbf{args}$ ×ÏÚ×ÒÁÝÁÅÔ ÁÒÇÕÍÅÎÔÙ,
239 $\mathbf{atom}$ ÏÐÒÅÄÅÌÑÅÔ, Ñ×ÌÑÅÔÓÑ ÌÉ ×ÙÒÁÖÅÎÉÅ ÁÔÏÍÏÍ:
240 % op (p + q);
241 % op (p + q > p*q);
242 % op (sin (p + q));
243 % op (foo (p, q));
244 % op (foo (p, q) := p - q);
245 % args (p + q);
246 % args (p + q > p*q);
247 % args (sin (p + q));
248 % args (foo (p, q));
249 % args (foo (p, q) := p - q);
250 % atom (p);
251 % atom (p + q);
252 % atom (sin (p + q));
254 \begin{verbatim}
255 (%i1) op (p + q);
256 (%o1) +
257 (%i2) op (p + q > p*q);
258 (%o2) >
259 (%i3) op (sin (p + q));
260 (%o3) sin
261 (%i4) op (foo (p, q));
262 (%o4) foo
263 (%i5) op (foo (p, q) := p - q);
264 (%o5) :=
265 (%i6) args (p + q);
266 (%o6) [q, p]
267 (%i7) args (p + q > p*q);
268 (%o7) [q + p, p q]
269 (%i8) args (sin (p + q));
270 (%o8) [q + p]
271 (%i9) args (foo (p, q));
272 (%o9) [p, - q]
273 (%i10) args (foo (p, q) := p - q);
274 (%o10) [foo(p, q), p - q]
275 (%i11) atom (p);
276 (%o11) true
277 (%i12) atom (p + q);
278 (%o12) false
279 (%i13) atom (sin (p + q));
280 (%o13) false
281 \end{verbatim}
283 \item ïÐÅÒÁÔÏÒÙ É ÁÒÇÕÍÅÎÔÙ ÐÒÏÇÒÁÍÍÎÙÈ ÂÌÏËÏ×.
284 ïÄÉÎÁÒÎÁÑ ËÁ×ÙÞËÁ ÕËÁÚÙ×ÁÅÔ Maxima ÓÏÚÄÁÔØ ×ÙÒÁÖÅÎÉÅ, ÎÏ ÏÔÌÏÖÉÔØ ÅÇÏ ×ÙÞÉÓÌÅÎÉÅ.
285 íÙ ÅÝÅ ÒÁÓÓÍÏÔÒÉÍ ÜÔÏ ÐÏÚÖÅ.
286 % op ('(block ([a], a: 42, a^2 - 1600)));
287 % op ('(if p > q then p else q));
288 % op ('(for x in L do print (x)));
289 % args ('(block ([a], a: 42, a^2 - 1600)));
290 % args ('(if p > q then p else q));
291 % args ('(for x in L do print (x)));
293 \begin{verbatim}
294 (%i1) op ('(block ([a], a: 42, a^2 - 1600)));
295 (%o1) block
296 (%i2) op ('(if p > q then p else q));
297 (%o2) if
298 (%i3) op ('(for x in L do print (x)));
299 (%o3) mdoin
300 (%i4) args ('(block ([a], a: 42, a^2 - 1600)));
302 (%o4) [[a], a : 42, a - 1600]
303 (%i5) args ('(if p > q then p else q));
304 (%o5) [p > q, p, true, q]
305 (%i6) args ('(for x in L do print (x)));
306 (%o6) [x, L, false, false, false, false, print(x)]
307 \end{verbatim}
309 \end{enumerate}
311 \section{÷ÙÞÉÓÌÅÎÉÅ}
313 \noindentúÎÁÞÅÎÉÅ ÓÉÍ×ÏÌÁ~--- ×ÙÒÁÖÅÎÉÅ, Ó×ÑÚÁÎÎÏÅ Ó ÜÔÉÍ ÓÉÍ×ÏÌÏÍ.
314 ëÁÖÄÙÊ ÓÉÍ×ÏÌ ÉÍÅÅÔ ÚÎÁÞÅÎÉÅ; ÅÓÌÉ ÚÎÁÞÅÎÉÅ ÎÅ ÚÁÄÁ×ÁÌÏÓØ, ÓÉÍ×ÏÌ ×ÙÞÉÓÌÑÅÔÓÑ
315 ÓÁÍ × ÓÅÂÑ. îÁÐÒÉÍÅÒ, $x$ ÉÍÅÅÔ ÚÎÁÞÅÎÉÅ $x$, ÅÓÌÉ ÓÉÍ×ÏÌÕ ÎÅ ÐÒÉÓ×ÁÉ×ÁÌÏÓØ
316 ÚÎÁÞÅÎÉÅ.
318 þÉÓÌÁ É ÓÔÒÏËÉ ÓÏ×ÐÁÄÁÀÔ ÓÏ Ó×ÏÉÍÉ ÚÎÁÞÅÎÉÑÍÉ.
320 ÷ÙÒÁÖÅÎÉÅ-ÎÅ-ÁÔÏÍ ×ÙÞÉÓÌÑÅÔÓÑ ÐÒÉÂÌÉÚÉÔÅÌØÎÏ ÔÁËÉÍ ÏÂÒÁÚÏÍ:
322 \begin{enumerate}
323 \item ÷ÙÞÉÓÌÑÅÔÓÑ ËÁÖÄÙÊ ÁÒÇÕÍÅÎÔ ÏÐÅÒÁÔÏÒÁ.
324 \item åÓÌÉ ÏÐÅÒÁÔÏÒ Ó×ÑÚÁÎ Ó ×ÙÚÏ×ÏÍ ÆÕÎËÃÉÉ, ÔÏ ÚÎÁÞÅÎÉÅ, ×ÏÚ×ÒÁÝÅÎÎÏÅ ÆÕÎËÃÉÅÊ,
325 Ñ×ÌÑÅÔÓÑ ÚÎÁÞÅÎÉÅÍ ×ÙÒÁÖÅÎÉÑ.
326 \end{enumerate}
328 ÷ÙÞÉÓÌÅÎÉÅ ÍÏÖÅÔ ÐÒÏÈÏÄÉÔØ ÐÏ-ÒÁÚÎÏÍÕ. îÅËÏÔÏÒÙÅ ÉÚÍÅÎÅÎÉÑ ÕÍÅÎØÛÁÀÔ ÏÂßÅÍ
329 ×ÙÞÉÓÌÅÎÉÊ:
331 \begin{enumerate}
332 \item îÅËÏÔÏÒÙÅ ÆÕÎËÃÉÉ ÎÅ ×ÙÞÉÓÌÑÀÔ Ó×ÏÉ ÁÒÇÕÍÅÎÔÙ ÉÌÉ ÞÁÓÔØ ÉÚ ÎÉÈ, ÌÉÂÏ
333 ÍÅÎÑÀÔ ÈÏÄ ×ÙÞÉÓÌÅÎÉÑ ÁÒÇÕÍÅÎÔÏ×.
334 % Examples: $\mathbf{kill}$, $\mathbf{save}$, $\mathbf{sum}$, $\mathbf{:=}$ (function definition).
335 \item ïÄÉÎÏÞÎÁÑ ËÁ×ÙÞËÁ $'$ ÐÒÅÄÏÔ×ÒÁÝÁÅÔ ×ÙÞÉÓÌÅÎÉÅ:
336 \begin{enumerate}
337 \item[---] $'a$ ×ÙÞÉÓÌÑÅÔÓÑ ËÁË $a$. ÷ÓÅ ÄÒÕÇÉÅ ÚÎÁÞÅÎÉÑ $a$ ÉÇÎÏÒÉÒÕÀÔÓÑ.
338 \item[---] $'f(a_1, \ldots, a_n)$ ×ÙÞÉÓÌÑÅÔÓÑ ×
339 $f(\mathbf{ev}(a_1), \ldots, \mathbf{ev}(a_n))$. ôÁËÉÍ ÏÂÒÁÚÏÍ, ×ÙÞÉÓÌÑÀÔÓÑ ÁÒÇÕÍÅÎÔÙ,
340 ÎÏ $f$ ÎÅ ×ÙÚÙ×ÁÅÔÓÑ.
341 \item[---] $'(\ldots)$ ÐÒÅÄÏÔ×ÒÁÝÁÅÔ ×ÙÞÉÓÌÅÎÉÅ ÌÀÂÙÈ ×ÙÒÁÖÅÎÉÊ ×ÎÕÔÒÉ $(\ldots)$.
342 \end{enumerate}
343 \end{enumerate}
345 îÅËÏÔÏÒÙÅ ÉÚÍÅÎÅÎÉÑ Õ×ÅÌÉÞÉ×ÁÀÔ ÏÂßÅÍ ×ÙÞÉÓÌÅÎÉÊ:
347 \begin{enumerate}
348 \item ä×Å ÏÄÉÎÏÞÎÙÅ ËÁ×ÙÞËÉ $''a$ ×ÙÚÙ×ÁÀÔ ÄÏÐÏÌÎÉÔÅÌØÎÏÅ ×ÙÞÉÓÌÅÎÉÅ × ÍÏÍÅÎÔ ÏÂÒÁÂÏÔËÉ $a$.
349 \item $\mathbf{ev}(a)$ ×ÙÚÙ×ÁÅÔ ÄÏÐÏÌÎÉÔÅÌØÎÏÅ ×ÙÞÉÓÌÅÎÉÅ $a$ ÐÒÉ ËÁÖÄÏÍ ×ÙÞÉÓÌÅÎÉÉ
350 $\mathbf{ev}(a)$.
351 \item úÁÐÉÓØ $\mathbf{apply}(f, [a_1, \ldots, a_n])$ ×ÙÚÙ×ÁÅÔ ×ÙÞÉÓÌÅÎÉÅ
352 ÁÒÇÕÍÅÎÔÏ× $a_1, \ldots, a_n$, ÄÁÖÅ ÅÓÌÉ $f$ ÓÔÁ×ÉÔ ÐÅÒÅÄ ÎÉÍÉ ÏÄÉÎÏÞÎÙÅ
353 ËÁ×ÙÞËÉ.
354 \item $\mathbf{define}$ ÓÏÏÔ×ÅÔÓÔ×ÕÅÔ ÏÐÒÅÄÅÌÅÎÉÀ ÆÕÎËÃÉÉ ×ÒÏÄÅ $\mathbf{:=}$,
355 ÎÏ ×ÙÞÉÓÌÑÅÔ ÔÅÌÏ ÆÕÎËÃÉÉ, × ÔÏ ×ÒÅÍÑ ËÁË $\mathbf{:=}$ ÏÔËÌÁÄÙ×ÁÅÔ
356 ×ÙÞÉÓÌÅÎÉÅ.
357 \end{enumerate}
359 òÁÓÓÍÏÔÒÉÍ, ËÁË ×ÙÞÉÓÌÑÀÔÓÑ ÎÅËÏÔÏÒÙÅ ×ÙÒÁÖÅÎÉÑ.
361 \begin{enumerate}
363 \item óÉÍ×ÏÌ ×ÙÞÉÓÌÑÅÔÓÑ ÓÁÍ × ÓÅÂÑ, ÅÓÌÉ ÅÍÕ ÎÅ ÐÒÉÓ×ÁÉ×ÁÌÏÓØ ÚÎÁÞÅÎÉÅ:
364 % block (a: 1, b: 2, e: 5);
365 % [a, b, c, d, e];
367 \begin{verbatim}
368 (%i1) block (a: 1, b: 2, e: 5);
369 (%o1) 5
370 (%i2) [a, b, c, d, e];
371 (%o2) [1, 2, c, d, 5]
372 \end{verbatim}
374 \item áÒÇÕÍÅÎÔÙ ÏÐÅÒÁÔÏÒÏ× ×ÙÞÉÓÌÑÀÔÓÑ ÏÂÙÞÎÙÍ ÐÕÔÅÍ (ÅÓÌÉ ×ÙÞÉÓÌÅÎÉÅ ÎÅ ÏÔÌÏÖÅÎÏ
375 ÔÅÍ ÉÌÉ ÉÎÙÍ ÏÂÒÁÚÏÍ):
376 % block (x: %pi, y: %e);
377 % sin (x + y);
378 % x > y;
379 % x!;
381 \begin{verbatim}
382 (%i1) block (x: %pi, y: %e);
383 (%o1) %e
384 (%i2) sin (x + y);
385 (%o2) - sin(%e)
386 (%i3) x > y;
387 (%o3) %pi > %e
388 (%i4) x!;
389 (%o4) %pi!
390 \end{verbatim}
392 \item åÓÌÉ ÏÐÅÒÁÔÏÒ Ó×ÑÚÁÎ Ó ×ÙÚÏ×ÏÍ ÆÕÎËÃÉÉ, ÚÎÁÞÅÎÉÅ, ×ÏÚ×ÒÁÝÅÎÎÏÅ ÆÕÎËÃÉÅÊ,
393 Ñ×ÌÑÅÔÓÑ ÚÎÁÞÅÎÉÅÍ ×ÙÒÁÖÅÎÉÑ (ÅÓÌÉ ×ÙÞÉÓÌÅÎÉÅ ÎÅ ÏÔÌÏÖÅÎÏ); ÉÎÁÞÅ ×ÙÞÉÓÌÅÎÉÅ ÄÁÅÔ
394 ÄÒÕÇÏÅ ×ÙÒÁÖÅÎÉÅ Ó ÔÅÍ ÖÅ ÏÐÅÒÁÔÏÒÏÍ:
395 % foo (p, q) := p - q;
396 % p: %phi;
397 % foo (p, q);
398 % bar (p, q);
400 \begin{verbatim}
401 (%i1) foo (p, q) := p - q;
402 (%o1) foo(p, q) := p - q
403 (%i2) p: %phi;
404 (%o2) %phi
405 (%i3) foo (p, q);
406 (%o3) %phi - q
407 (%i4) bar (p, q);
408 (%o4) bar(%phi, q)
409 \end{verbatim}
411 \item îÅËÏÔÏÒÙÅ ÆÕÎËÃÉÉ ÏÔËÌÁÄÙ×ÁÀÔ ×ÙÞÉÓÌÅÎÉÅ ÁÒÇÕÍÅÎÔÏ×, ÎÁÐÒÉÍÅÒ,
412 $\mathbf{save}$, $\mathbf{:=}$, $\mathbf{kill}$:
413 % block (a: 1, b: %pi, c: x + y);
414 % [a, b, c];
415 % save ("tmp.save", a, b, c);
416 % f (a) := a^b;
417 % f (7);
418 % kill (a, b, c);
419 % [a, b, c];
421 \begin{verbatim}
422 (%i1) block (a: 1, b: %pi, c: x + y);
423 (%o1) y + x
424 (%i2) [a, b, c];
425 (%o2) [1, %pi, y + x]
426 (%i3) save ("tmp.save", a, b, c);
427 (%o3) tmp.save
428 (%i4) f (a) := a^b;
430 (%o4) f(a) := a
431 (%i5) f (7);
433 (%o5) 7
434 (%i6) kill (a, b, c);
435 (%o6) done
436 (%i7) [a, b, c];
437 (%o7) [a, b, c]
438 \end{verbatim}
440 \item ïÄÉÎÏÞÎÁÑ ËÁ×ÙÞËÁ ÐÒÅÄÏÔ×ÒÁÝÁÅÔ ×ÙÞÉÓÌÅÎÉÅ, ÄÁÖÅ ÅÓÌÉ ÏÎÏ ÄÏÌÖÎÏ ÐÒÏÉÚ×ÏÄÉÔØÓÑ:
441 % foo (x, y) := y - x;
442 % block (a: %e, b: 17);
443 % foo (a, b);
444 % foo ('a, 'b);
445 % 'foo (a, b);
446 % '(foo (a, b));
448 \begin{verbatim}
449 (%i1) foo (x, y) := y - x;
450 (%o1) foo(x, y) := y - x
451 (%i2) block (a: %e, b: 17);
452 (%o2) 17
453 (%i3) foo (a, b);
454 (%o3) 17 - %e
455 (%i4) foo ('a, 'b);
456 (%o4) b - a
457 (%i5) 'foo (a, b);
458 (%o5) foo(%e, 17)
459 (%i6) '(foo (a, b));
460 (%o6) foo(a, b)
461 \end{verbatim}
463 \item ä×Å ÏÄÉÎÏÞÎÙÅ ËÁ×ÙÞËÉ ×ÙÚÙ×ÁÀÔ ÄÏÐÏÌÎÉÔÅÌØÎÏÅ ×ÙÞÉÓÌÅÎÉÅ ×Ï ×ÒÅÍÑ ÏÂÒÁÂÏÔËÉ
464 ×ÙÒÁÖÅÎÉÑ:
465 % diff (sin (x), x);
466 % foo (x) := diff (sin (x), x);
467 % foo (x) := ''(diff (sin (x), x));
469 \begin{verbatim}
470 (%i1) diff (sin (x), x);
471 (%o1) cos(x)
472 (%i2) foo (x) := diff (sin (x), x);
473 (%o2) foo(x) := diff(sin(x), x)
474 (%i3) foo (x) := ''(diff (sin (x), x));
475 (%o3) foo(x) := cos(x)
476 \end{verbatim}
478 \item $\mathbf{ev}$ ×ÓÑËÉÊ ÒÁÚ ×ÙÚÙ×ÁÅÔ ÄÏÐÏÌÎÉÔÅÌØÎÏÅ ×ÙÞÉÓÌÅÎÉÅ (ÓÒÁ×ÎÉÔÅ
479 ÜÔÏ Ó ÐÏ×ÅÄÅÎÉÅÍ ÄÌÑ Ä×ÕÈ ËÁ×ÙÞÅË):
480 % block (xx: yy, yy: zz);
481 % [xx, yy];
482 % foo (x) := ''x;
483 % foo (xx);
484 % bar (x) := ev (x);
485 % bar (xx);
487 \begin{verbatim}
488 (%i1) block (xx: yy, yy: zz);
489 (%o1) zz
490 (%i2) [xx, yy];
491 (%o2) [yy, zz]
492 (%i3) foo (x) := ''x;
493 (%o3) foo(x) := x
494 (%i4) foo (xx);
495 (%o4) yy
496 (%i5) bar (x) := ev (x);
497 (%o5) bar(x) := ev(x)
498 (%i6) bar (xx);
499 (%o6) zz
500 \end{verbatim}
502 \item $\mathbf{apply}$ ×ÙÚÙ×ÁÅÔ ×ÙÞÉÓÌÅÎÉÅ ÁÒÇÕÍÅÎÔÏ×, ÄÁÖÅ ÅÓÌÉ ÐÅÒÅÄ ÎÉÍÉ ÓÔÏÑÔ ËÁ×ÙÞËÉ:
503 % block (a: aa, b: bb, c: cc);
504 % block (aa: 11, bb: 22, cc: 33);
505 % [a, b, c, aa, bb, cc];
506 % apply (kill, [a, b, c]);
507 % [a, b, c, aa, bb, cc];
508 % kill (a, b, c);
509 % [a, b, c, aa, bb, cc];
511 \begin{verbatim}
512 (%i1) block (a: aa, b: bb, c: cc);
513 (%o1) cc
514 (%i2) block (aa: 11, bb: 22, cc: 33);
515 (%o2) 33
516 (%i3) [a, b, c, aa, bb, cc];
517 (%o3) [aa, bb, cc, 11, 22, 33]
518 (%i4) apply (kill, [a, b, c]);
519 (%o4) done
520 (%i5) [a, b, c, aa, bb, cc];
521 (%o5) [aa, bb, cc, aa, bb, cc]
522 (%i6) kill (a, b, c);
523 (%o6) done
524 (%i7) [a, b, c, aa, bb, cc];
525 (%o7) [a, b, c, aa, bb, cc]
526 \end{verbatim}
528 \item $\mathbf{define}$ ×ÙÞÉÓÌÑÅÔ ÔÅÌÏ ÏÐÒÅÄÅÌÅÎÉÑ ÆÕÎËÃÉÉ:
529 % integrate (sin (a*x), x, 0, %pi);
530 % foo (x) := integrate (sin (a*x), x, 0, %pi);
531 % define (foo (x), integrate (sin (a*x), x, 0, %pi));
533 \begin{verbatim}
534 (%i1) integrate (sin (a*x), x, 0, %pi);
535 1 cos(%pi a)
536 (%o1) - - ----------
538 (%i2) foo (x) := integrate (sin (a*x), x, 0, %pi);
539 (%o2) foo(x) := integrate(sin(a x), x, 0, %pi)
540 (%i3) define (foo (x), integrate (sin (a*x), x, 0, %pi));
541 1 cos(%pi a)
542 (%o3) foo(x) := - - ----------
544 \end{verbatim}
546 \end{enumerate}
548 \section{õÐÒÏÝÅÎÉÅ}
550 \noindentðÏÓÌÅ ×ÙÞÉÓÌÅÎÉÑ ×ÙÒÁÖÅÎÉÑ, Maxima ÐÙÔÁÅÔÓÑ ÎÁÊÔÉ ÜË×É×ÁÌÅÎÔÎÏÅ ÅÍÕ <<ÂÏÌÅÅ ÐÒÏÓÔÏÅ>>,
551 ÄÌÑ ÞÅÇÏ ÐÒÉÍÅÎÑÅÔÓÑ ÒÑÄ ÐÒÁ×ÉÌ, Ó×ÑÚÁÎÎÙÈ Ó ÕÓÌÏ×ÎÙÍ ÐÏÎÑÔÉÅÍ ÐÒÏÓÔÏÔÙ.
552 ôÁË, $1 + 1$ ÕÐÒÏÝÁÅÔÓÑ ÄÏ $2$, $x + x$~--- ÄÏ $2 x$, Á
553 $\mathbf{sin}(\mathbf{\%pi})$~--- ÄÏ $0$.
555 ïÄÎÁËÏ ÍÎÏÇÉÅ ÉÚ×ÅÓÔÎÙÅ ÔÏÖÄÅÓÔ×Á ÎÅ ÐÒÉÍÅÎÑÀÔÓÑ Á×ÔÏÍÁÔÉÞÅÓËÉ. îÁÐÒÉÍÅÒ, ÎÅ
556 ÉÓÐÏÌØÚÕÀÔÓÑ ÆÏÒÍÕÌÙ Ä×ÏÊÎÏÇÏ ÕÇÌÁ ÄÌÑ ÔÒÉÇÏÎÏÍÅÔÒÉÞÅÓËÉÈ ÆÕÎËÃÉÊ É ÎÅ ÐÒÏÉÚ×ÏÄÉÔÓÑ
557 ÐÒÉ×ÅÄÅÎÉÅ ÄÒÏÂÅÊ ×ÉÄÁ $a/b + c/b \rightarrow (a + c)/b$. äÌÑ ÐÒÉÍÅÎÅÎÉÑ ÔÏÖÄÅÓÔ×
558 ÓÕÝÅÓÔ×ÕÀÔ ÏÔÄÅÌØÎÙÅ ÆÕÎËÃÉÉ.
560 õÐÒÏÝÅÎÉÅ ×ÓÅÇÄÁ ÐÒÉÍÅÎÑÅÔÓÑ, ÅÓÌÉ ÎÅ ÂÙÌÏ Ñ×ÎÏ ÏÔÌÏÖÅÎÏ, ÄÁÖÅ × ÔÏÍ ÓÌÕÞÁÅ, ËÏÇÄÁ
561 ×ÙÒÁÖÅÎÉÅ ÎÅ ×ÙÞÉÓÌÑÅÔÓÑ.
563 $\mathbf{tellsimpafter}$ ××ÏÄÉÔ ÐÏÌØÚÏ×ÁÔÅÌØÓËÉÅ ÐÒÁ×ÉÌÁ ÕÐÒÏÝÅÎÉÑ.
565 òÁÓÓÍÏÔÒÉÍ ÎÅÓËÏÌØËÏ ÐÒÉÍÅÒÏ×.
567 \begin{enumerate}
569 \item úÎÁË ËÁ×ÙÞËÉ ÏÔËÌÁÄÙ×ÁÅÔ ×ÙÞÉÓÌÅÎÉÅ, ÎÏ ÎÅ ÕÐÒÏÝÅÎÉÅ;
570 åÓÌÉ ÄÌÑ ÇÌÏÂÁÌØÎÏÇÏ ÆÌÁÇÁ $\mathbf{simp}$ ÕÓÔÁÎÏ×ÌÅÎÏ $\mathbf{false}$,
571 ÔÏ ÕÐÒÏÝÅÎÉÅ ÎÅ ÐÒÏÉÚ×ÏÄÉÔÓÑ, ÎÏ ÐÒÏÉÚ×ÏÄÉÔÓÑ ×ÙÞÉÓÌÅÎÉÅ:
573 % '[1 + 1, x + x, x * x, sin (%pi)];
574 % simp: false$
575 % block ([x: 1], x + x);
576 % simp: true$
578 \begin{verbatim}
579 (%i1) '[1 + 1, x + x, x * x, sin (%pi)];
581 (%o1) [2, 2 x, x , 0]
582 (%i2) simp: false$
583 (%i3) block ([x: 1], x + x);
584 (%o3) 1 + 1
585 \end{verbatim}
587 \item îÅËÏÔÏÒÙÅ ÔÏÖÄÅÓÔ×Á ÎÅ ÐÒÉÍÅÎÑÀÔÓÑ Á×ÔÏÍÁÔÉÞÅÓËÉ.
588 $\mathbf{expand}$, $\mathbf{ratsimp}$, $\mathbf{trigexpand}$, $\mathbf{demoivre}$~---
589 ÐÒÉÍÅÒÙ ÆÕÎËÃÉÊ, ÐÒÉÍÅÎÑÀÝÉÈ ÔÏÖÄÅÓÔ×Á:
591 % (a + b)^2;
592 % expand (%);
593 % a/b + c/b;
594 % ratsimp (%);
595 % sin (2*x);
596 % trigexpand (%);
597 % a * exp (b * %i);
598 % demoivre (%);
600 \begin{verbatim}
601 (%i1) (a + b)^2;
603 (%o1) (b + a)
604 (%i2) expand (%);
606 (%o2) b + 2 a b + a
607 (%i3) a/b + c/b;
609 (%o3) - + -
611 (%i4) ratsimp (%);
612 c + a
613 (%o4) -----
615 (%i5) sin (2*x);
616 (%o5) sin(2 x)
617 (%i6) trigexpand (%);
618 (%o6) 2 cos(x) sin(x)
619 (%i7) a * exp (b * %i);
620 %i b
621 (%o7) a %e
622 (%i8) demoivre (%);
623 (%o8) a (%i sin(b) + cos(b))
624 \end{verbatim}
626 \end{enumerate}
628 \section{apply, map É lambda}
630 \begin{enumerate}
632 \item $\mathbf{apply}$ ÓÏÚÄÁÅÔ É ×ÙÞÉÓÌÑÅÔ ×ÙÒÁÖÅÎÉÅ. áÒÇÕÍÅÎÔÙ ×ÙÒÁÖÅÎÉÑ
633 ×ÓÅÇÄÁ ×ÙÞÉÓÌÑÀÔÓÑ (ÄÁÖÅ, ÅÓÌÉ ÂÙ ÏÎÉ ÎÅ ×ÙÞÉÓÌÑÌÉÓØ ÐÒÉ ÄÒÕÇÉÈ ÏÂÓÔÏÑÔÅÌØÓÔ×ÁÈ):
635 % apply (sin, [x * %pi]);
636 % L: [a, b, c, x, y, z];
637 % apply ("+", L);
639 \begin{verbatim}
640 (%i1) apply (sin, [x * %pi]);
641 (%o1) sin(%pi x)
642 (%i2) L: [a, b, c, x, y, z];
643 (%o2) [a, b, c, x, y, z]
644 (%i3) apply ("+", L);
645 (%o3) z + y + x + c + b + a
646 \end{verbatim}
648 \item $\mathbf{map}$ ÓÏÚÄÁÅÔ É ×ÙÞÉÓÌÑÅÔ ×ÙÒÁÖÅÎÉÅ ÄÌÑ ËÁÖÄÏÇÏ ÜÌÅÍÅÎÔÁ ÓÐÉÓËÁ
649 ÁÒÇÕÍÅÎÔÏ×. áÒÇÕÍÅÎÔÙ ×ÙÒÁÖÅÎÉÑ ×ÓÅÇÄÁ ×ÙÞÉÓÌÑÀÔÓÑ (ÄÁÖÅ, ÅÓÌÉ ÂÙ ÏÎÉ ÎÅ ×ÙÞÉÓÌÑÌÉÓØ
650 ÐÒÉ ÄÒÕÇÉÈ ÏÂÓÔÏÑÔÅÌØÓÔ×ÁÈ). ÷ ËÁÞÅÓÔ×Å ÒÅÚÕÌØÔÁÔÁ ×ÏÚ×ÒÁÝÁÅÔÓÑ ÓÐÉÓÏË:
652 % map (foo, [x, y, z]);
653 % map ("+", [1, 2, 3], [a, b, c]);
654 % map (atom, [a, b, c, a + b, a + b + c]);
656 \begin{verbatim}
657 (%i1) map (foo, [x, y, z]);
658 (%o1) [foo(x), foo(y), foo(z)]
659 (%i2) map ("+", [1, 2, 3], [a, b, c]);
660 (%o2) [a + 1, b + 2, c + 3]
661 (%i3) map (atom, [a, b, c, a + b, a + b + c]);
662 (%o3) [true, true, true, false, false]
663 \end{verbatim}
665 \item $\mathbf{lambda}$ ÓÏÚÄÁÅÔ ÌÑÍÂÄÁ-×ÙÒÁÖÅÎÉÅ (ÂÅÚÙÍÑÎÎÕÀ ÆÕÎËÃÉÀ). ìÑÍÂÄÁ-×ÙÒÁÖÅÎÉÅ
666 ÍÏÖÅÔ ÉÓÐÏÌØÚÏ×ÁÔØÓÑ × ÎÅËÏÔÏÒÙÈ ÓÌÕÞÁÑÈ ËÁË ÏÂÙÞÎÁÑ ÆÕÎËÃÉÑ. $\mathbf{lambda}$
667 ÎÅ ×ÙÞÉÓÌÑÅÔ ÔÅÌÏ ÆÕÎËÃÉÉ:
669 % f: lambda ([x, y], (x + y)*(x - y));
670 % f (a, b);
671 % apply (f, [p, q]);
672 % map (f, [1, 2, 3], [a, b, c]);
673 %% apply (lambda ([x, y], (x + y)*(x - y)), [p, q]);
674 %% map (lambda ([x, y], (x + y)*(x - y)), [1, 2, 3], [a, b, c]);
676 \begin{verbatim}
677 (%i1) f: lambda ([x, y], (x + y)*(x - y));
678 (%o1) lambda([x, y], (x + y) (x - y))
679 (%i2) f (a, b);
680 (%o2) (a - b) (b + a)
681 (%i3) apply (f, [p, q]);
682 (%o3) (p - q) (q + p)
683 (%i4) map (f, [1, 2, 3], [a, b, c]);
684 (%o4) [(1 - a) (a + 1), (2 - b) (b + 2), (3 - c) (c + 3)]
685 \end{verbatim}
687 \end{enumerate}
689 \section{÷ÓÔÒÏÅÎÎÙÅ ÔÉÐÙ ÏÂßÅËÔÏ×}
691 \noindentïÂßÅËÔ ÐÒÅÄÓÔÁ×ÌÑÅÔÓÑ × ×ÉÄÅ ×ÙÒÁÖÅÎÉÑ. ëÁË É ÄÒÕÇÉÅ ×ÙÒÁÖÅÎÉÑ, ÏÂßÅËÔ ÓÏÄÅÒÖÉÔ ÏÐÅÒÁÔÏÒ
692 É ÅÇÏ ÁÒÇÕÍÅÎÔÙ.
694 ïÓÎÏ×ÎÙÅ ×ÓÔÒÏÅÎÎÙÅ ÔÉÐÙ ÏÂßÅËÔÏ×~--- ÓÐÉÓËÉ, ÍÁÔÒÉÃÙ É ÍÎÏÖÅÓÔ×Á.
696 \subsection{óÐÉÓËÉ}
698 \begin{enumerate}
700 \item óÐÉÓÏË ÚÁÄÁÅÔÓÑ × ×ÉÄÅ $[a, b, c]$.
702 \item ÷ ÓÐÉÓËÅ $L$ $L[i]$~--- $i$-Ê ÜÌÅÍÅÎÔ. $L[1]$~--- ÐÅÒ×ÙÊ ÜÌÅÍÅÎÔ.
704 \item $\mathbf{map}(\mathit{f}, L)$ ÐÒÉÍÅÎÑÅÔ $\mathit{f}$ Ë ËÁÖÄÏÍÕ ÜÌÅÍÅÎÔÕ $L$.
706 \item $\mathbf{apply}(\mathbf{"+"}, L)$~--- ÓÕÍÍÁ ×ÓÅÈ ÜÌÅÍÅÎÔÏ× $L$.
708 \item $\mathbf{for\ } x \mathbf{\ in \ } L \mathbf{\ do \ } \mathit{expr}$ ×ÙÞÉÓÌÑÅÔ
709 $\mathit{expr}$ ÄÌÑ ËÁÖÄÏÇÏ ÜÌÅÍÅÎÔÁ $L$.
711 \item $\mathbf{length}(L)$~--- ÞÉÓÌÏ ÜÌÅÍÅÎÔÏ× $L$.
713 \end{enumerate}
715 \subsection{íÁÔÒÉÃÙ}
717 \begin{enumerate}
719 \item íÁÔÒÉÃÁ ÚÁÄÁÅÔÓÑ × ×ÉÄÅ $\mathbf{matrix}(L_1, \ldots, L_n)$, ÇÄÅ
720 $L_1, \ldots, L_n$~--- ÓÐÉÓËÉ ÜÌÅÍÅÎÔÏ× ÓÔÒÏË.
722 \item åÓÌÉ $M$~--- ÍÁÔÒÉÃÁ, ÔÏ $M[i, j]$ ÉÌÉ $M[i][j]$~--- ÅÅ $(i, j)$-Ê ÜÌÅÍÅÎÔ.
723 $M[1,1]$~--- ÜÌÅÍÅÎÔ × ×ÅÒÈÎÅÍ ÌÅ×ÏÍ ÕÇÌÕ.
725 \item ïÐÅÒÁÔÏÒ $\mathbf{.}$ ÐÒÅÄÓÔÁ×ÌÑÅÔ ÎÅËÏÍÍÕÔÁÔÉ×ÎÏÅ ÕÍÎÏÖÅÎÉÅ. $M . L$, $L . M$ É
726 $M . N$~--- ÎÅËÏÍÍÕÔÁÔÉ×ÎÙÅ ÐÒÏÉÚ×ÅÄÅÎÉÑ, ÇÄÅ $L$~--- ÓÐÉÓÏË, Á $M$ É $N$~--- ÍÁÔÒÉÃÙ.
728 % \item $M\mathbf{\hat{ }\hat{ }}n$ is the noncommutative exponent, i.e., $M . M . \ldots . M$.
730 \item $\mathbf{transpose}(M)$~--- ÔÒÁÎÓÐÏÎÉÒÏ×ÁÎÎÁÑ ÍÁÔÒÉÃÁ $M^T$.
732 \item $\mathbf{eigenvalues}(M)$ ×ÏÚ×ÒÁÝÁÅÔ ÓÏÂÓÔ×ÅÎÎÙÅ ÚÎÁÞÅÎÉÑ $M$.
734 \item $\mathbf{eigenvectors}(M)$ ×ÏÚ×ÒÁÝÁÅÔ ÓÏÂÓÔ×ÅÎÎÙÅ ×ÅËÔÏÒÙ $M$.
736 \item $\mathbf{length}(M)$ ×ÏÚ×ÒÁÝÁÅÔ ÞÉÓÌÏ ÓÔÒÏË $M$.
738 \item $\mathbf{length}(\mathbf{transpose}(M))$ ×ÏÚ×ÒÁÝÁÅÔ ÞÉÓÌÏ ÓÔÏÌÂÃÏ× $M$.
740 \end{enumerate}
742 \subsection{íÎÏÖÅÓÔ×Á}
744 \begin{enumerate}
746 \item Maxima ÒÁÂÏÔÁÅÔ Ó Ñ×ÎÏ ÚÁÄÁÎÎÙÍÉ ËÏÎÅÞÎÙÍÉ ÍÎÏÖÅÓÔ×ÁÍÉ. íÎÏÖÅÓÔ×Á~--- ÎÅ ÔÏ
747 ÖÅ ÓÁÍÏÅ, ÞÔÏ É ÓÐÉÓËÉ, É ÐÒÅÏÂÒÁÚÏ×ÁÎÉÅ ÍÎÏÖÅÓÔ×Á × ÓÐÉÓÏË É ÎÁÏÂÏÒÏÔ ÄÏÌÖÎÏ
748 ÐÒÏÉÚ×ÏÄÉÔØÓÑ × Ñ×ÎÏÍ ×ÉÄÅ.
750 \item íÎÏÖÅÓÔ×Ï ÚÁÄÁÅÔÓÑ × ×ÉÄÅ
751 $\mathbf{set}(a, b, c, \ldots)$, ÇÄÅ $a, b, c, \ldots$~--- ÅÇÏ ÜÌÅÍÅÎÔÙ.
753 \item $\mathbf{union} (A, B)$~--- ÏÂßÅÄÉÎÅÎÉÅ ÍÎÏÖÅÓÔ× $A$ É $B$.
755 \item $\mathbf{intersection} (A, B)$~--- ÐÅÒÅÓÅÞÅÎÉÅ ÍÎÏÖÅÓÔ× $A$ É $B$.
757 \item $\mathbf{cardinality} (A)$~--- ÞÉÓÌÏ ÜÌÅÍÅÎÔÏ× ÍÎÏÖÅÓÔ×Á $A$.
759 \end{enumerate}
761 \section{ôÉÐÉÞÎÙÅ ÚÁÄÁÞÉ}
763 \subsection{ïÐÒÅÄÅÌÅÎÉÅ ÆÕÎËÃÉÉ}
765 \begin{enumerate}
767 \item æÕÎËÃÉÑ ÏÐÒÅÄÅÌÑÅÔÓÑ ÏÐÅÒÁÔÏÒÏÍ $\mathbf{:=}$, ÐÒÉ ÜÔÏÍ ×ÙÞÉÓÌÅÎÉÅ ÔÅÌÁ ÆÕÎËÃÉÉ
768 ÏÔËÌÁÄÙ×ÁÅÔÓÑ.
770 \noindent÷ ÐÒÉÍÅÒÅ ÎÉÖÅ $\mathbf{diff}$ ÐÅÒÅÓÞÉÔÙ×ÁÅÔÓÑ ÐÒÉ ËÁÖÄÏÍ ×ÙÚÏ×Å ÆÕÎËÃÉÉ.
771 áÒÇÕÍÅÎÔ ÐÏÄÓÔÁ×ÌÑÅÔÓÑ ×ÍÅÓÔÏ $x$, É ×ÙÞÉÓÌÑÅÔÓÑ ÒÅÚÕÌØÔÉÒÕÀÝÅÅ ×ÙÒÁÖÅÎÉÅ.
772 ëÏÇÄÁ ÁÒÇÕÍÅÎÔ ÐÒÅÄÓÔÁ×ÌÑÅÔ ÓÏÂÏÊ ÎÅÞÔÏ ÏÔÌÉÞÎÏÅ ÏÔ ÓÉÍ×ÏÌÁ, ÐÒÏÉÓÈÏÄÉÔ ÏÛÉÂËÁ:
773 ÄÌÑ $\mathbf{foo} (1)$ Maxima ÐÙÔÁÅÔÓÑ ×ÙÞÉÓÌÉÔØ $\mathbf{diff} (\mathbf{sin}(1)^2, 1)$.
774 % foo (x) := diff (sin(x)^2, x);
775 % foo (u);
776 % foo (1);
778 \begin{verbatim}
779 (%i1) foo (x) := diff (sin(x)^2, x);
781 (%o1) foo(x) := diff(sin (x), x)
782 (%i2) foo (u);
783 (%o2) 2 cos(u) sin(u)
784 (%i3) foo (1);
785 Non-variable 2nd argument to diff:
787 #0: foo(x=1)
788 -- an error.
789 \end{verbatim}
791 \item $\mathbf{define}$ ÏÐÒÅÄÅÌÑÅÔ ÆÕÎËÃÉÀ É ×ÙÞÉÓÌÑÅÔ ÅÅ ÔÅÌÏ.
793 \noindent÷ ÓÌÅÄÕÀÝÅÍ ÐÒÉÍÅÒÅ $\mathbf{diff}$ ×ÙÞÉÓÌÑÅÔÓÑ ÅÄÉÎÏÖÄÙ (ÐÒÉ ÏÐÒÅÄÅÌÅÎÉÉ), ÐÏÜÔÏÍÕ
794 $\mathbf{foo} (1)$ ÎÅ ×ÙÚÙ×ÁÅÔ ÏÛÉÂËÉ:
795 % define (foo (x), diff (sin(x)^2, x));
796 % foo (u);
797 % foo (1);
799 \begin{verbatim}
800 (%i1) define (foo (x), diff (sin(x)^2, x));
801 (%o1) foo(x) := 2 cos(x) sin(x)
802 (%i2) foo (u);
803 (%o2) 2 cos(u) sin(u)
804 (%i3) foo (1);
805 (%o3) 2 cos(1) sin(1)
806 \end{verbatim}
808 \end{enumerate}
810 \subsection{òÅÛÅÎÉÅ ÕÒÁ×ÎÅÎÉÊ}
811 % eq_1: a * x + b * y + z = %pi;
812 % eq_2: z - 5*y + x = 0;
813 % s: solve ([eq_1, eq_2], [x, z]);
814 % length (s);
815 % [subst (s[1], eq_1), subst (s[1], eq_2)];
816 % ratsimp (%);
818 \begin{verbatim}
819 (%i1) eq_1: a * x + b * y + z = %pi;
820 (%o1) z + b y + a x = %pi
821 (%i2) eq_2: z - 5*y + x = 0;
822 (%o2) z - 5 y + x = 0
823 (%i3) s: solve ([eq_1, eq_2], [x, z]);
824 (b + 5) y - %pi (b + 5 a) y - %pi
825 (%o3) [[x = - ---------------, z = -----------------]]
826 a - 1 a - 1
827 (%i4) length (s);
828 (%o4) 1
829 (%i5) [subst (s[1], eq_1), subst (s[1], eq_2)];
830 (b + 5 a) y - %pi a ((b + 5) y - %pi)
831 (%o5) [----------------- - ------------------- + b y = %pi,
832 a - 1 a - 1
833 (b + 5 a) y - %pi (b + 5) y - %pi
834 ----------------- - --------------- - 5 y = 0]
835 a - 1 a - 1
836 (%i6) ratsimp (%);
837 (%o6) [%pi = %pi, 0 = 0]
838 \end{verbatim}
840 \subsection{éÎÔÅÇÒÉÒÏ×ÁÎÉÅ É ÄÉÆÆÅÒÅÎÃÉÒÏ×ÁÎÉÅ}
842 $\mathbf{integrate}$ ×ÙÞÉÓÌÑÅÔ ÏÐÒÅÄÅÌÅÎÎÙÅ É ÎÅÏÐÒÅÄÅÌÅÎÎÙÅ ÉÎÔÅÇÒÁÌÙ:
843 % integrate (1/(1 + x), x, 0, 1);
844 % integrate (exp(-u) * sin(u), u, 0, inf);
845 % assume (a > 0);
846 % integrate (1/(1 + x), x, 0, a);
847 % integrate (exp(-a*u) * sin(a*u), u, 0, inf);
848 % integrate (exp (sin (t)), t, 0, %pi);
849 % 'integrate (exp(-u) * sin(u), u, 0, inf);
851 \begin{verbatim}
852 (%i1) integrate (1/(1 + x), x, 0, 1);
853 (%o1) log(2)
854 (%i2) integrate (exp(-u) * sin(u), u, 0, inf);
856 (%o2) -
858 (%i3) assume (a > 0);
859 (%o3) [a > 0]
860 (%i4) integrate (1/(1 + x), x, 0, a);
861 (%o4) log(a + 1)
862 (%i5) integrate (exp(-a*u) * sin(a*u), u, 0, inf);
864 (%o5) ---
866 (%i6) integrate (exp (sin (t)), t, 0, %pi);
869 [ sin(t)
870 (%o6) I %e dt
874 (%i7) 'integrate (exp(-u) * sin(u), u, 0, inf);
877 [ - u
878 (%o7) I %e sin(u) du
882 \end{verbatim}
884 $\mathbf{diff}$ ×ÙÞÉÓÌÑÅÔ ÐÒÏÉÚ×ÏÄÎÙÅ É ÄÉÆÆÅÒÅÎÃÉÁÌÙ:
885 % diff (sin (y*x));
886 % diff (sin (y*x), x);
887 % diff (sin (y*x), y);
888 % diff (sin (y*x), x, 2);
889 % 'diff (sin (y*x), x, 2);
891 \begin{verbatim}
892 (%i1) diff (sin (y*x));
893 (%o1) x cos(x y) del(y) + y cos(x y) del(x)
894 (%i2) diff (sin (y*x), x);
895 (%o2) y cos(x y)
896 (%i3) diff (sin (y*x), y);
897 (%o3) x cos(x y)
898 (%i4) diff (sin (y*x), x, 2);
900 (%o4) - y sin(x y)
901 (%i5) 'diff (sin (y*x), x, 2);
904 (%o5) --- (sin(x y))
907 \end{verbatim}
909 \subsection{ðÏÓÔÒÏÅÎÉÅ ÇÒÁÆÉËÏ×}
911 $\mathbf{plot2d}$ ÓÔÒÏÉÔ Ä×ÕÍÅÒÎÙÅ ÇÒÁÆÉËÉ:
912 % plot2d (exp(-u) * sin(u), [u, 0, 2*%pi]);
913 % plot2d ([exp(-u), exp(-u) * sin(u)], [u, 0, 2*%pi]);
914 % xx: makelist (i/2.5, i, 1, 10);
915 % yy: map (lambda ([x], exp(-x) * sin(x)), xx);
916 % plot2d ([discrete, xx, yy]);
917 % plot2d ([discrete, xx, yy], [gnuplot_curve_styles, ["with points"]]);
919 \begin{verbatim}
920 (%i1) plot2d (exp(-u) * sin(u), [u, 0, 2*%pi]);
921 (%o1)
922 (%i2) plot2d ([exp(-u), exp(-u) * sin(u)], [u, 0, 2*%pi]);
923 (%o2)
924 (%i3) xx: makelist (i/2.5, i, 1, 10);
925 (%o3) [0.4, 0.8, 1.2, 1.6, 2.0, 2.4, 2.8, 3.2, 3.6, 4.0]
926 (%i4) yy: map (lambda ([x], exp(-x) * sin(x)), xx);
927 (%o4) [0.261034921143457, 0.322328869227062, .2807247779692679,
928 .2018104299334517, .1230600248057767, .0612766372619573,
929 .0203706503896865, - .0023794587414574, - .0120913057698414,
930 - 0.013861321214153]
931 (%i5) plot2d ([discrete, xx, yy]);
932 (%o5)
933 (%i6) plot2d ([discrete, xx, yy], [gnuplot_curve_styles, ["with points"]]);
934 (%o6)
935 \end{verbatim}
937 óÍ. ÔÁËÖÅ $\mathbf{plot3d}$.
939 \subsection{óÏÈÒÁÎÅÎÉÅ É ÚÁÇÒÕÚËÁ ÆÁÊÌÏ×}
941 $\mathbf{save}$ ÚÁÐÉÓÙ×ÁÅÔ ×ÙÒÁÖÅÎÉÑ × ÆÁÊÌ:
942 % a: foo - bar;
943 % b: foo^2 * bar;
944 % save ("my.session", a, b);
945 % save ("my.session", all);
947 \begin{verbatim}
948 (%i1) a: foo - bar;
949 (%o1) foo - bar
950 (%i2) b: foo^2 * bar;
952 (%o2) bar foo
953 (%i3) save ("my.session", a, b);
954 (%o3) my.session
955 (%i4) save ("my.session", all);
956 (%o4) my.session
957 \end{verbatim}
959 $\mathbf{load}$ ÞÉÔÁÅÔ ×ÙÒÁÖÅÎÉÑ ÉÚ ÆÁÊÌÁ.
960 % load ("my.session");
961 % a;
962 % b;
964 \begin{verbatim}
965 (%i1) load ("my.session");
966 (%o4) my.session
967 (%i5) a;
968 (%o5) foo - bar
969 (%i6) b;
971 (%o6) bar foo
972 \end{verbatim}
974 óÍ. ÔÁËÖÅ $\mathbf{stringout}$ É $\mathbf{batch}$.
976 \section{ðÒÏÇÒÁÍÍÉÒÏ×ÁÎÉÅ ÐÏÄ Maxima}
978 % dynamic scope
979 % argument-quoting and argument-evaluating functions
980 % directory organization: src, tests, share, doc
982 óÕÝÅÓÔ×ÕÅÔ ÏÄÎÏ ÐÒÏÓÔÒÁÎÓÔ×Ï ÉÍÅÎ, ÓÏÄÅÒÖÁÝÅÅ ×ÓÅ ÓÉÍ×ÏÌÙ Maxima. äÒÕÇÏÅ
983 ÐÒÏÓÔÒÁÎÓÔ×Ï ÉÍÅÎ ÓÏÚÄÁÔØ ÎÅÌØÚÑ.
985 ÷ÓÅ ÐÅÒÅÍÅÎÎÙÅ ÇÌÏÂÁÌØÎÙ, ÅÓÌÉ ÎÅ ÏÐÒÅÄÅÌÅÎÙ ÌÏËÁÌØÎÏ~--- × ÆÕÎËÃÉÑÈ, ÌÑÍÂÄÁ-×ÙÒÁÖÅÎÉÑÈ
986 É ÂÌÏËÁÈ.
988 úÎÁÞÅÎÉÅÍ ÐÅÒÅÍÅÎÎÏÊ ÓÞÉÔÁÅÔÓÑ ÔÏ, ÞÔÏ ÂÙÌÏ ÐÒÉÓ×ÏÅÎÏ × ÐÏÓÌÅÄÎÉÊ ÒÁÚ, × Ñ×ÎÏÍ ×ÉÄÅ,
989 ÌÉÂÏ ÞÅÒÅÚ ÐÒÉÓ×ÁÉ×ÁÎÉÅ ÚÎÁÞÅÎÉÑ ÌÏËÁÌØÎÏÊ ÐÅÒÅÍÅÎÎÏÊ × ÂÌÏËÅ, ÆÕÎËÃÉÉ ÉÌÉ ÌÑÍÂÄÁ-×ÙÒÁÖÅÎÉÉ.
990 üÔÁ ËÏÎÃÅÐÃÉÑ ÉÚ×ÅÓÔÎÁ ËÁË {\it ÄÉÎÁÍÉÞÅÓËÁÑ ÏÂÌÁÓÔØ ×ÉÄÉÍÏÓÔÉ}.
992 åÓÌÉ ÐÅÒÅÍÅÎÎÁÑ Ñ×ÌÑÅÔÓÑ ÌÏËÁÌØÎÏÊ ×ÎÕÔÒÉ ÆÕÎËÃÉÉ, ÌÑÍÂÄÁ-×ÙÒÁÖÅÎÉÑ ÉÌÉ ÂÌÏËÁ, ÅÅ
993 ÚÎÁÞÅÎÉÅ ÌÏËÁÌØÎÏ, ÎÏ ÏÓÔÁÌØÎÙÅ Ó×ÏÊÓÔ×Á (ÚÁÄÁÎÎÙÅ $\mathbf{declare}$) ÇÌÏÂÁÌØÎÙ.
994 æÕÎËÃÉÑ $\mathbf{local}$ ÄÅÌÁÅÔ ÐÅÒÅÍÅÎÎÕÀ ÌÏËÁÌØÎÏÊ × ÏÔÎÏÛÅÎÉÉ ×ÓÅÈ Ó×ÏÊÓÔ×.
996 ðÏ ÕÍÏÌÞÁÎÉÀ, ÏÐÒÅÄÅÌÅÎÉÅ ÆÕÎËÃÉÉ ÇÌÏÂÁÌØÎÏ, ÄÁÖÅ ÅÓÌÉ ÏÎÏ ÓÏÄÅÒÖÉÔÓÑ ×ÎÕÔÒÉ ÆÕÎËÃÉÉ,
997 ÌÑÍÂÄÁ-×ÙÒÁÖÅÎÉÑ ÉÌÉ ÂÌÏËÁ.
998 $\mathbf{local}(f), f(x) \mathbf{\ :=\ } \ldots$ ÓÏÚÄÁÅÔ ÌÏËÁÌØÎÏÅ ÏÐÒÅÄÅÌÅÎÉÅ ÆÕÎËÃÉÉ.
1000 $\mathbf{trace}(\mathit{foo})$ ÕËÁÚÙ×ÁÅÔ Maxima ÐÅÞÁÔÁÔØ ÓÏÏÂÝÅÎÉÅ ÐÒÉ ×ÈÏÄÅ × ÆÕÎËÃÉÀ
1001 $\mathit{foo}$ É ×ÙÈÏÄÅ ÉÚ ÎÅÅ.
1003 òÁÓÓÍÏÔÒÉÍ ÎÅËÏÔÏÒÙÅ ÐÒÉÍÅÒÙ ÐÒÏÇÒÁÍÍÉÒÏ×ÁÎÉÑ ÐÏÄ Maxima.
1005 \begin{enumerate}
1007 \item ÷ÓÅ ÐÅÒÅÍÅÎÎÙÅ ÇÌÏÂÁÌØÎÙ, ÅÓÌÉ ÎÅ ÏÐÒÅÄÅÌÅÎÙ ÌÏËÁÌØÎÏ~--- × ÆÕÎËÃÉÑÈ,
1008 ÌÑÍÂÄÁ-×ÙÒÁÖÅÎÉÑÈ É ÂÌÏËÁÈ:
1010 % (x: 42, y: 1729, z: foo*bar);
1011 % f (x, y) := x*y*z;
1012 % f (aa, bb);
1013 % lambda ([x, z], (x - z)/y);
1014 % apply (%, [uu, vv]);
1015 % block ([y, z], y: 65536, [x, y, z]);
1017 \begin{verbatim}
1018 (%i1) (x: 42, y: 1729, z: foo*bar);
1019 (%o1) bar foo
1020 (%i2) f (x, y) := x*y*z;
1021 (%o2) f(x, y) := x y z
1022 (%i3) f (aa, bb);
1023 (%o3) aa bar bb foo
1024 (%i4) lambda ([x, z], (x - z)/y);
1025 x - z
1026 (%o4) lambda([x, z], -----)
1028 (%i5) apply (%, [uu, vv]);
1029 uu - vv
1030 (%o5) -------
1031 1729
1032 (%i6) block ([y, z], y: 65536, [x, y, z]);
1033 (%o6) [42, 65536, z]
1034 \end{verbatim}
1036 \item úÎÁÞÅÎÉÅÍ ÐÅÒÅÍÅÎÎÏÊ ÓÞÉÔÁÅÔÓÑ ÔÏ, ÞÔÏ ÂÙÌÏ ÐÒÉÓ×ÏÅÎÏ × ÐÏÓÌÅÄÎÉÊ ÒÁÚ, × Ñ×ÎÏÍ ×ÉÄÅ,
1037 ÌÉÂÏ ÞÅÒÅÚ ÐÒÉÓ×ÁÉ×ÁÎÉÅ ÚÎÁÞÅÎÉÑ ÌÏËÁÌØÎÏÊ ÐÅÒÅÍÅÎÎÏÊ:
1039 % foo (y) := x - y;
1040 % x: 1729;
1041 % foo (%pi);
1042 % bar (x) := foo (%e);
1043 % bar (42);
1045 \begin{verbatim}
1046 (%i1) foo (y) := x - y;
1047 (%o1) foo(y) := x - y
1048 (%i2) x: 1729;
1049 (%o2) 1729
1050 (%i3) foo (%pi);
1051 (%o3) 1729 - %pi
1052 (%i4) bar (x) := foo (%e);
1053 (%o4) bar(x) := foo(%e)
1054 (%i5) bar (42);
1055 (%o5) 42 - %e
1056 \end{verbatim}
1058 \end{enumerate}
1060 \section{Lisp É Maxima}
1062 % symbols, $ and ?
1063 % defining an argument-evaluating function in lisp
1064 % defining an argument-quoting function in lisp
1065 % calling a function defined in maxima from lisp
1066 % useful lisp fcns: meval, simplifya, displa
1068 \noindentúÁÐÉÓØ {\bf :lisp} $\mathit{expr}$ ×ÙÞÉÓÌÑÅÔ $\mathit{expr}$ × ÉÎÔÅÒÐÒÅÔÁÔÏÒÅ Lisp.
1069 üÔÁ ÚÁÐÉÓØ ÒÁÓÐÏÚÎÁÅÔÓÑ × ÓÔÒÏËÅ ××ÏÄÁ É ÆÁÊÌÁÈ, ÏÂÒÁÂÁÔÙ×ÁÅÍÙÈ $\mathbf{batch}$,
1070 ÎÏ ÎÅ $\mathbf{load}$.
1072 óÉÍ×ÏÌ $\mathbf{foo}$ × Maxima ÓÏÏÔ×ÅÔÓÔ×ÕÅÔ ÓÉÍ×ÏÌÕ \$foo × Lisp,
1073 Á ÓÉÍ×ÏÌ Lisp foo ÓÏÏÔ×ÅÔÓ×ÕÅÔ ÓÉÍ×ÏÌÕ Maxima $\mathbf{?foo}$.
1075 {\bf :lisp} $\mathrm{(}\mathbf{defun\ } \mathrm{\$foo\ (a)\ (\ldots))}$
1076 ÚÁÄÁÅÔ ÆÕÎËÃÉÀ Lisp $\mathrm{foo}$, ×ÙÞÉÓÌÑÀÝÕÀ Ó×ÏÉ ÁÒÇÕÍÅÎÔÙ.
1077 éÚ Maxima ÆÕÎËÃÉÑ ×ÙÚÙ×ÁÅÔÓÑ ÚÁÐÉÓØÀ $\mathbf{foo}(a)$.
1079 {\bf :lisp} $\mathrm{(}\mathbf{defmspec\ } \mathrm{\$foo\ (e)\ (\ldots))}$
1080 ÚÁÄÁÅÔ ÆÕÎËÃÉÀ Lisp $\mathbf{foo}$, ÏÔËÌÁÄÙ×ÁÀÝÕÀ ×ÙÞÉÓÌÅÎÉÅ ÁÒÇÕÍÅÎÔÏ×.
1081 éÚ Maxima ÆÕÎËÃÉÑ ×ÙÚÙ×ÁÅÔÓÑ ÚÁÐÉÓØÀ $\mathbf{foo}(a)$.
1082 áÒÇÕÍÅÎÔÁÍÉ $\mathrm{\$foo}$ Ñ×ÌÑÀÔÓÑ $(\mathbf{cdr\ } e)$, Á
1083 $(\mathbf{caar\ } e)$ ×ÓÅÇÄÁ ÓÏ×ÐÁÄÁÅÔ Ó $\mathrm{\$foo}$.
1085 úÁÐÉÓØ $(\mathbf{mfuncall\ '\$}\mathrm{foo\ }a_1 \ldots a_n)$
1086 ×ÙÚÙ×ÁÅÔ ÉÚ Lisp ÆÕÎËÃÉÀ $\mathbf{foo}$, ÏÐÒÅÄÅÌÅÎÎÕÀ × Maxima.
1088 ïÂÒÁÔÉÍÓÑ Ë Lisp ÉÚ Maxima É ÎÁÏÂÏÒÏÔ.
1090 \begin{enumerate}
1092 \item úÁÐÉÓØ {\bf :lisp} $\mathit{expr}$ ×ÙÞÉÓÌÑÅÔ $\mathit{expr}$ × ÉÎÔÅÒÐÒÅÔÁÔÏÒÅ Lisp:
1094 % (aa + bb)^2;
1095 % :lisp $%
1096 \begin{verbatim}
1097 (%i1) (aa + bb)^2;
1099 (%o1) (bb + aa)
1100 (%i2) :lisp $%
1101 ((MEXPT SIMP) ((MPLUS SIMP) $AA $BB) 2)
1102 \end{verbatim}
1104 \item {\bf :lisp} $\mathrm{(}\mathbf{defun\ } \mathrm{\$foo\ (a)\ (\ldots))}$
1105 ÚÁÄÁÅÔ ÆÕÎËÃÉÀ Lisp $\mathrm{foo}$, ×ÙÞÉÓÌÑÀÝÕÀ Ó×ÏÉ ÁÒÇÕÍÅÎÔÙ:
1107 % :lisp (defun $foo (a b) `((mplus) ((mtimes) ,a ,b) $%pi))
1108 % (p: x + y, q: x - y);
1109 % foo (p, q);
1110 \begin{verbatim}
1111 (%i1) :lisp (defun $foo (a b) `((mplus) ((mtimes) ,a ,b) $%pi))
1112 $FOO
1113 (%i1) (p: x + y, q: x - y);
1114 (%o1) x - y
1115 (%i2) foo (p, q);
1116 (%o2) (x - y) (y + x) + %pi
1117 \end{verbatim}
1119 \item {\bf :lisp} $\mathrm{(}\mathbf{defmspec\ } \mathrm{\$foo\ (e)\ (\ldots))}$
1120 ÚÁÄÁÅÔ ÆÕÎËÃÉÀ Lisp $\mathbf{foo}$, ÏÔËÌÁÄÙ×ÁÀÝÕÀ ×ÙÞÉÓÌÅÎÉÅ ÁÒÇÕÍÅÎÔÏ×:
1122 % :lisp (defmspec $bar (e) (let ((a (cdr e))) `((mplus) ((mtimes) ,@a) $%pi)))
1123 % bar (p, q);
1124 % bar (''p, ''q);
1125 \begin{verbatim}
1126 (%i1) :lisp (defmspec $bar (e) (let ((a (cdr e))) `((mplus) ((mtimes) ,@a) $%pi)))
1127 #<CLOSURE LAMBDA (E) (LET ((A (CDR E))) `((MPLUS) ((MTIMES) ,@A) $%PI))>
1128 (%i1) bar (p, q);
1129 (%o1) p q + %pi
1130 (%i2) bar (''p, ''q);
1131 (%o2) p q + %pi
1132 \end{verbatim}
1134 \item úÁÐÉÓØ $(\mathbf{mfuncall\ '\$}\mathrm{foo\ }a_1 \ldots a_n)$
1135 ×ÙÚÙ×ÁÅÔ ÉÚ Lisp ÆÕÎËÃÉÀ $\mathbf{foo}$, ÏÐÒÅÄÅÌÅÎÎÕÀ × Maxima:
1137 % blurf (x) := x^2;
1138 % :lisp (displa (mfuncall '$blurf '((mplus) $grotz $mumble)))
1139 \begin{verbatim}
1140 (%i1) blurf (x) := x^2;
1142 (%o1) blurf(x) := x
1143 (%i2) :lisp (displa (mfuncall '$blurf '((mplus) $grotz $mumble)))
1145 (mumble + grotz)
1147 \end{verbatim}
1149 \end{enumerate}
1151 \end{document}