2 % (c) 2005 Robert Dodier
3 % (c) 2007 áÌÅËÓÅÊ âÅÛÅÎÏ× (al@beshenov.ru), ÒÕÓÓËÉÊ ÐÅÒÅ×ÏÄ
5 \documentclass[11pt,oneside
]{article
}
6 %\documentclass[12pt]{article}
7 \usepackage[russian
]{babel
}
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{òÏÂÅÒÔ äÏÄÉÅÒ
}
41 \copyright~
2005 Robert Dodier.\\
42 \copyright~
2007 áÌÅËÓÅÊ âÅÛÅÎÏ× (
\href{mailto:al@beshenov.ru
}{al@beshenov.ru
}), ÒÕÓÓËÉÊ ÐÅÒÅ×ÏÄ.\\
43 äÏÍÁÛÎÑÑ ÓÔÒÁÎÉÃÁ Maxima:
\url{http://maxima.sourceforge.net/ru/
}.\\
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 òÁÓÓÍÏÔÒÉÍ ÎÅÓËÏÌØËÏ ÐÒÉÍÅÒÏ×.
64 \item îÕÖÎÏ ÎÁÊÔÉ ÏÂßÅÍ ÛÁÒÁ:
67 (
%i1) V: 4/3 * %pi * r^3;
74 \item òÁÄÉÕÓ ÒÁ×ÅÎ
10:
81 \item $V$~--- ÔÏ ÖÅ, ÞÔÏ É ÂÙÌÏ; Maxima ÎÅ ÐÏÍÅÎÑÅÔ $V$, ÅÓÌÉ ÜÔÏ ÎÅ ÕËÁÚÁÔØ:
91 \item <<Maxima, ÐÅÒÅÓÞÉÔÁÊ, ÐÏÖÁÌÕÊÓÔÁ, $V$>>:
100 \item ÷ÍÅÓÔÏ ×ÙÒÁÖÅÎÉÑ ÈÏÔÅÌÏÓØ ÂÙ ×ÉÄÅÔØ ÞÉÓÌÅÎÎÏÅ ÚÎÁÞÅÎÉÅ:
104 (
%o5) 4188.79020478639
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 òÁÓÓÍÏÔÒÉÍ ÄÒÕÇÉÅ ÐÒÉÍÅÒÙ.
149 \item áÔÏÍÙ~--- ÓÉÍ×ÏÌÙ, ÓÔÒÏËÉ É ÞÉÓÌÁ. ÷ÏÔ ÓÐÉÓÏË Ó ÜÌÅÍÅÎÔÁÍÉ-ÁÔÏÍÁÍÉ:
150 % [a, foo, foo_bar, "Hello, world!", 42, 17.29];
153 (
%i2) [a, foo, foo_bar, "Hello, world!", 42, 17.29];
154 (
%o2) [a, foo, foo_bar, Hello, world!, 42, 17.29]
157 \item íÁÔÅÍÁÔÉÞÅÓËÉÅ ×ÙÒÁÖÅÎÉÑ:
158 % [a + b + c, a * b * c, foo = bar, a*b < c*d];
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]
165 \item óÐÉÓËÉ É ÍÁÔÒÉÃÙ.
166 üÌÅÍÅÎÔÁÍÉ ÓÐÉÓËÁ ÉÌÉ ÍÁÔÒÉÃÙ ÍÏÇÕÔ ÂÙÔØ ÌÀÂÙÅ ×ÙÒÁÖÅÎÉÑ, × ÔÏÍ ÞÉÓÌÅ ÓÐÉÓËÉ ÉÌÉ
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)]];
172 % M: matrix ([%pi, 17], [29, %e]);
173 % M2: matrix ([[%pi, 17], a*d - b*c], [matrix ([1, a], [b, 7]), %e]);
178 (
%i1) L: [a, b, c, %pi, %e, 1729, 1/(a*d - b*c)];
180 (
%o1) [a, b, c, %pi, %e, 1729, ---------]
183 % (éÎÁÞÅ ÄÒÏÂØ ÂÕÄÅÔ ÒÁÚÏÒ×ÁÎÁ ÎÁ Ä×Å ÓÔÒÁÎÉÃÙ)
185 (
%i2) L2: [a, b, [c, %pi, [%e, 1729], 1/(a*d - b*c)]];
187 (
%o2) [a, b, [c, %pi, [%e, 1729], ---------]]
195 (
%o4) [c, %pi, [%e, 1729], ---------]
197 (
%i5) M: matrix ([%pi, 17], [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 ]
215 \item ðÒÏÇÒÁÍÍÎÙÅ ÂÌÏËÉ~--- ×ÙÒÁÖÅÎÉÑ.
216 $x : y$ ÏÚÎÁÞÁÅÔ ÐÒÉÓ×ÁÉ×ÁÎÉÅ $y$ Ë $x$; ÚÎÁÞÅÎÉÅ ×ÙÒÁÖÅÎÉÑ ÐÒÉÓ×ÁÉ×ÁÎÉÑ~--- $y$.
217 $
\mathbf{block
}$ ÏÂßÅÄÉÎÑÅÔ ÎÅÓËÏÌØËÏ ×ÙÒÁÖÅÎÉÊ É ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏ ÉÈ ×ÙÞÉÓÌÑÅÔ;
218 ÚÎÁÞÅÎÉÅ ÂÌÏËÁ ÓÏÏÔ×ÅÔÓÔ×ÕÅÔ ÚÎÁÞÅÎÉÀ ÅÇÏ ÐÏÓÌÅÄÎÅÇÏ ×ÙÒÁÖÅÎÉÑ.
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);
225 (
%i1) (a: 42) - (b: 17);
229 (
%i3) block ([a], a: 42, a^2 - 1600) + block ([b], b: 5, %pi^b);
232 (
%i4) (if a > 1 then %pi else %e) + (if b < 0 then 1/2 else 1/7);
238 \item $
\mathbf{op
}$ ×ÏÚ×ÒÁÝÁÅÔ ÏÐÅÒÁÔÏÒ, $
\mathbf{args
}$ ×ÏÚ×ÒÁÝÁÅÔ ÁÒÇÕÍÅÎÔÙ,
239 $
\mathbf{atom
}$ ÏÐÒÅÄÅÌÑÅÔ, Ñ×ÌÑÅÔÓÑ ÌÉ ×ÙÒÁÖÅÎÉÅ ÁÔÏÍÏÍ:
244 % op (foo (p, q) := p - q);
246 % args (p + q > p*q);
247 % args (sin (p + q));
249 % args (foo (p, q) := p - q);
252 % atom (sin (p + q));
257 (
%i2) op (p + q > p*q);
259 (
%i3) op (sin (p + q));
261 (
%i4) op (foo (p, q));
263 (
%i5) op (foo (p, q) := p - q);
267 (
%i7) args (p + q > p*q);
269 (
%i8) args (sin (p + q));
271 (
%i9) args (foo (p, q));
273 (
%i10) args (foo (p, q) := p - q);
274 (
%o10) [foo(p, q), p - q]
279 (
%i13) atom (sin (p + q));
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)));
294 (
%i1) op ('(block ([a], a: 42, a^2 - 1600)));
296 (
%i2) op ('(if p > q then p else q));
298 (
%i3) op ('(for x in L do print (x)));
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)]
313 \noindentúÎÁÞÅÎÉÅ ÓÉÍ×ÏÌÁ~--- ×ÙÒÁÖÅÎÉÅ, Ó×ÑÚÁÎÎÏÅ Ó ÜÔÉÍ ÓÉÍ×ÏÌÏÍ.
314 ëÁÖÄÙÊ ÓÉÍ×ÏÌ ÉÍÅÅÔ ÚÎÁÞÅÎÉÅ; ÅÓÌÉ ÚÎÁÞÅÎÉÅ ÎÅ ÚÁÄÁ×ÁÌÏÓØ, ÓÉÍ×ÏÌ ×ÙÞÉÓÌÑÅÔÓÑ
315 ÓÁÍ × ÓÅÂÑ. îÁÐÒÉÍÅÒ, $x$ ÉÍÅÅÔ ÚÎÁÞÅÎÉÅ $x$, ÅÓÌÉ ÓÉÍ×ÏÌÕ ÎÅ ÐÒÉÓ×ÁÉ×ÁÌÏÓØ
318 þÉÓÌÁ É ÓÔÒÏËÉ ÓÏ×ÐÁÄÁÀÔ ÓÏ Ó×ÏÉÍÉ ÚÎÁÞÅÎÉÑÍÉ.
320 ÷ÙÒÁÖÅÎÉÅ-ÎÅ-ÁÔÏÍ ×ÙÞÉÓÌÑÅÔÓÑ ÐÒÉÂÌÉÚÉÔÅÌØÎÏ ÔÁËÉÍ ÏÂÒÁÚÏÍ:
323 \item ÷ÙÞÉÓÌÑÅÔÓÑ ËÁÖÄÙÊ ÁÒÇÕÍÅÎÔ ÏÐÅÒÁÔÏÒÁ.
324 \item åÓÌÉ ÏÐÅÒÁÔÏÒ Ó×ÑÚÁÎ Ó ×ÙÚÏ×ÏÍ ÆÕÎËÃÉÉ, ÔÏ ÚÎÁÞÅÎÉÅ, ×ÏÚ×ÒÁÝÅÎÎÏÅ ÆÕÎËÃÉÅÊ,
325 Ñ×ÌÑÅÔÓÑ ÚÎÁÞÅÎÉÅÍ ×ÙÒÁÖÅÎÉÑ.
328 ÷ÙÞÉÓÌÅÎÉÅ ÍÏÖÅÔ ÐÒÏÈÏÄÉÔØ ÐÏ-ÒÁÚÎÏÍÕ. îÅËÏÔÏÒÙÅ ÉÚÍÅÎÅÎÉÑ ÕÍÅÎØÛÁÀÔ ÏÂßÅÍ
332 \item îÅËÏÔÏÒÙÅ ÆÕÎËÃÉÉ ÎÅ ×ÙÞÉÓÌÑÀÔ Ó×ÏÉ ÁÒÇÕÍÅÎÔÙ ÉÌÉ ÞÁÓÔØ ÉÚ ÎÉÈ, ÌÉÂÏ
333 ÍÅÎÑÀÔ ÈÏÄ ×ÙÞÉÓÌÅÎÉÑ ÁÒÇÕÍÅÎÔÏ×.
334 % Examples: $\mathbf{kill}$, $\mathbf{save}$, $\mathbf{sum}$, $\mathbf{:=}$ (function definition).
335 \item ïÄÉÎÏÞÎÁÑ ËÁ×ÙÞËÁ $'$ ÐÒÅÄÏÔ×ÒÁÝÁÅÔ ×ÙÞÉÓÌÅÎÉÅ:
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)$.
345 îÅËÏÔÏÒÙÅ ÉÚÍÅÎÅÎÉÑ Õ×ÅÌÉÞÉ×ÁÀÔ ÏÂßÅÍ ×ÙÞÉÓÌÅÎÉÊ:
348 \item ä×Å ÏÄÉÎÏÞÎÙÅ ËÁ×ÙÞËÉ $''a$ ×ÙÚÙ×ÁÀÔ ÄÏÐÏÌÎÉÔÅÌØÎÏÅ ×ÙÞÉÓÌÅÎÉÅ × ÍÏÍÅÎÔ ÏÂÒÁÂÏÔËÉ $a$.
349 \item $
\mathbf{ev
}(a)$ ×ÙÚÙ×ÁÅÔ ÄÏÐÏÌÎÉÔÅÌØÎÏÅ ×ÙÞÉÓÌÅÎÉÅ $a$ ÐÒÉ ËÁÖÄÏÍ ×ÙÞÉÓÌÅÎÉÉ
351 \item úÁÐÉÓØ $
\mathbf{apply
}(f,
[a_1,
\ldots, a_n
])$ ×ÙÚÙ×ÁÅÔ ×ÙÞÉÓÌÅÎÉÅ
352 ÁÒÇÕÍÅÎÔÏ× $a_1,
\ldots, a_n$, ÄÁÖÅ ÅÓÌÉ $f$ ÓÔÁ×ÉÔ ÐÅÒÅÄ ÎÉÍÉ ÏÄÉÎÏÞÎÙÅ
354 \item $
\mathbf{define
}$ ÓÏÏÔ×ÅÔÓÔ×ÕÅÔ ÏÐÒÅÄÅÌÅÎÉÀ ÆÕÎËÃÉÉ ×ÒÏÄÅ $
\mathbf{:=
}$,
355 ÎÏ ×ÙÞÉÓÌÑÅÔ ÔÅÌÏ ÆÕÎËÃÉÉ, × ÔÏ ×ÒÅÍÑ ËÁË $
\mathbf{:=
}$ ÏÔËÌÁÄÙ×ÁÅÔ
359 òÁÓÓÍÏÔÒÉÍ, ËÁË ×ÙÞÉÓÌÑÀÔÓÑ ÎÅËÏÔÏÒÙÅ ×ÙÒÁÖÅÎÉÑ.
363 \item óÉÍ×ÏÌ ×ÙÞÉÓÌÑÅÔÓÑ ÓÁÍ × ÓÅÂÑ, ÅÓÌÉ ÅÍÕ ÎÅ ÐÒÉÓ×ÁÉ×ÁÌÏÓØ ÚÎÁÞÅÎÉÅ:
364 % block (a: 1, b: 2, e: 5);
368 (
%i1) block (a: 1, b: 2, e: 5);
370 (
%i2) [a, b, c, d, e];
371 (
%o2) [1, 2, c, d, 5]
374 \item áÒÇÕÍÅÎÔÙ ÏÐÅÒÁÔÏÒÏ× ×ÙÞÉÓÌÑÀÔÓÑ ÏÂÙÞÎÙÍ ÐÕÔÅÍ (ÅÓÌÉ ×ÙÞÉÓÌÅÎÉÅ ÎÅ ÏÔÌÏÖÅÎÏ
375 ÔÅÍ ÉÌÉ ÉÎÙÍ ÏÂÒÁÚÏÍ):
376 % block (x: %pi, y: %e);
382 (
%i1) block (x: %pi, y: %e);
392 \item åÓÌÉ ÏÐÅÒÁÔÏÒ Ó×ÑÚÁÎ Ó ×ÙÚÏ×ÏÍ ÆÕÎËÃÉÉ, ÚÎÁÞÅÎÉÅ, ×ÏÚ×ÒÁÝÅÎÎÏÅ ÆÕÎËÃÉÅÊ,
393 Ñ×ÌÑÅÔÓÑ ÚÎÁÞÅÎÉÅÍ ×ÙÒÁÖÅÎÉÑ (ÅÓÌÉ ×ÙÞÉÓÌÅÎÉÅ ÎÅ ÏÔÌÏÖÅÎÏ); ÉÎÁÞÅ ×ÙÞÉÓÌÅÎÉÅ ÄÁÅÔ
394 ÄÒÕÇÏÅ ×ÙÒÁÖÅÎÉÅ Ó ÔÅÍ ÖÅ ÏÐÅÒÁÔÏÒÏÍ:
395 % foo (p, q) := p - q;
401 (
%i1) foo (p, q) := p - q;
402 (
%o1) foo(p, q) := p - q
411 \item îÅËÏÔÏÒÙÅ ÆÕÎËÃÉÉ ÏÔËÌÁÄÙ×ÁÀÔ ×ÙÞÉÓÌÅÎÉÅ ÁÒÇÕÍÅÎÔÏ×, ÎÁÐÒÉÍÅÒ,
412 $
\mathbf{save
}$, $
\mathbf{:=
}$, $
\mathbf{kill
}$:
413 % block (a: 1, b: %pi, c: x + y);
415 % save ("tmp.save", a, b, c);
422 (
%i1) block (a: 1, b: %pi, c: x + y);
425 (
%o2) [1, %pi, y + x]
426 (
%i3) save ("tmp.save", a, b, c);
434 (
%i6) kill (a, b, c);
440 \item ïÄÉÎÏÞÎÁÑ ËÁ×ÙÞËÁ ÐÒÅÄÏÔ×ÒÁÝÁÅÔ ×ÙÞÉÓÌÅÎÉÅ, ÄÁÖÅ ÅÓÌÉ ÏÎÏ ÄÏÌÖÎÏ ÐÒÏÉÚ×ÏÄÉÔØÓÑ:
441 % foo (x, y) := y - x;
442 % block (a: %e, b: 17);
449 (
%i1) foo (x, y) := y - x;
450 (
%o1) foo(x, y) := y - x
451 (
%i2) block (a: %e, b: 17);
463 \item ä×Å ÏÄÉÎÏÞÎÙÅ ËÁ×ÙÞËÉ ×ÙÚÙ×ÁÀÔ ÄÏÐÏÌÎÉÔÅÌØÎÏÅ ×ÙÞÉÓÌÅÎÉÅ ×Ï ×ÒÅÍÑ ÏÂÒÁÂÏÔËÉ
466 % foo (x) := diff (sin (x), x);
467 % foo (x) := ''(diff (sin (x), x));
470 (
%i1) diff (sin (x), 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)
478 \item $
\mathbf{ev
}$ ×ÓÑËÉÊ ÒÁÚ ×ÙÚÙ×ÁÅÔ ÄÏÐÏÌÎÉÔÅÌØÎÏÅ ×ÙÞÉÓÌÅÎÉÅ (ÓÒÁ×ÎÉÔÅ
479 ÜÔÏ Ó ÐÏ×ÅÄÅÎÉÅÍ ÄÌÑ Ä×ÕÈ ËÁ×ÙÞÅË):
480 % block (xx: yy, yy: zz);
488 (
%i1) block (xx: yy, yy: zz);
492 (
%i3) foo (x) := ''x;
496 (
%i5) bar (x) := ev (x);
497 (
%o5) bar(x) := ev(x)
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];
509 % [a, b, c, aa, bb, cc];
512 (
%i1) block (a: aa, b: bb, c: cc);
514 (
%i2) block (aa: 11, bb: 22, cc: 33);
516 (
%i3) [a, b, c, aa, bb, cc];
517 (
%o3) [aa, bb, cc, 11, 22, 33]
518 (
%i4) apply (kill, [a, b, c]);
520 (
%i5) [a, b, c, aa, bb, cc];
521 (
%o5) [aa, bb, cc, aa, bb, cc]
522 (
%i6) kill (a, b, c);
524 (
%i7) [a, b, c, aa, bb, cc];
525 (
%o7) [a, b, c, aa, bb, cc]
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));
534 (
%i1) integrate (sin (a*x), x, 0, %pi);
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));
542 (
%o3) foo(x) := - - ----------
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 òÁÓÓÍÏÔÒÉÍ ÎÅÓËÏÌØËÏ ÐÒÉÍÅÒÏ×.
569 \item úÎÁË ËÁ×ÙÞËÉ ÏÔËÌÁÄÙ×ÁÅÔ ×ÙÞÉÓÌÅÎÉÅ, ÎÏ ÎÅ ÕÐÒÏÝÅÎÉÅ;
570 åÓÌÉ ÄÌÑ ÇÌÏÂÁÌØÎÏÇÏ ÆÌÁÇÁ $
\mathbf{simp
}$ ÕÓÔÁÎÏ×ÌÅÎÏ $
\mathbf{false
}$,
571 ÔÏ ÕÐÒÏÝÅÎÉÅ ÎÅ ÐÒÏÉÚ×ÏÄÉÔÓÑ, ÎÏ ÐÒÏÉÚ×ÏÄÉÔÓÑ ×ÙÞÉÓÌÅÎÉÅ:
573 % '[1 + 1, x + x, x * x, sin (%pi)];
575 % block ([x: 1], x + x);
579 (
%i1) '[1 + 1, x + x, x * x, sin (%pi)];
581 (
%o1) [2, 2 x, x , 0]
583 (
%i3) block ([x: 1], x + x);
587 \item îÅËÏÔÏÒÙÅ ÔÏÖÄÅÓÔ×Á ÎÅ ÐÒÉÍÅÎÑÀÔÓÑ Á×ÔÏÍÁÔÉÞÅÓËÉ.
588 $
\mathbf{expand
}$, $
\mathbf{ratsimp
}$, $
\mathbf{trigexpand
}$, $
\mathbf{demoivre
}$~---
589 ÐÒÉÍÅÒÙ ÆÕÎËÃÉÊ, ÐÒÉÍÅÎÑÀÝÉÈ ÔÏÖÄÅÓÔ×Á:
617 (
%i6) trigexpand (%);
618 (
%o6) 2 cos(x) sin(x)
619 (
%i7) a * exp (b * %i);
623 (
%o8) a (%i sin(b) + cos(b))
628 \section{apply, map É lambda
}
632 \item $
\mathbf{apply
}$ ÓÏÚÄÁÅÔ É ×ÙÞÉÓÌÑÅÔ ×ÙÒÁÖÅÎÉÅ. áÒÇÕÍÅÎÔÙ ×ÙÒÁÖÅÎÉÑ
633 ×ÓÅÇÄÁ ×ÙÞÉÓÌÑÀÔÓÑ (ÄÁÖÅ, ÅÓÌÉ ÂÙ ÏÎÉ ÎÅ ×ÙÞÉÓÌÑÌÉÓØ ÐÒÉ ÄÒÕÇÉÈ ÏÂÓÔÏÑÔÅÌØÓÔ×ÁÈ):
635 % apply (sin, [x * %pi]);
636 % L: [a, b, c, x, y, z];
640 (
%i1) apply (sin, [x * %pi]);
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
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]);
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]
665 \item $
\mathbf{lambda
}$ ÓÏÚÄÁÅÔ ÌÑÍÂÄÁ-×ÙÒÁÖÅÎÉÅ (ÂÅÚÙÍÑÎÎÕÀ ÆÕÎËÃÉÀ). ìÑÍÂÄÁ-×ÙÒÁÖÅÎÉÅ
666 ÍÏÖÅÔ ÉÓÐÏÌØÚÏ×ÁÔØÓÑ × ÎÅËÏÔÏÒÙÈ ÓÌÕÞÁÑÈ ËÁË ÏÂÙÞÎÁÑ ÆÕÎËÃÉÑ. $
\mathbf{lambda
}$
667 ÎÅ ×ÙÞÉÓÌÑÅÔ ÔÅÌÏ ÆÕÎËÃÉÉ:
669 % f: lambda ([x, y], (x + y)*(x - y));
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]);
677 (
%i1) f: lambda ([x, y], (x + y)*(x - y));
678 (
%o1) lambda([x, y], (x + y) (x - y))
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)]
689 \section{÷ÓÔÒÏÅÎÎÙÅ ÔÉÐÙ ÏÂßÅËÔÏ×
}
691 \noindentïÂßÅËÔ ÐÒÅÄÓÔÁ×ÌÑÅÔÓÑ × ×ÉÄÅ ×ÙÒÁÖÅÎÉÑ. ëÁË É ÄÒÕÇÉÅ ×ÙÒÁÖÅÎÉÑ, ÏÂßÅËÔ ÓÏÄÅÒÖÉÔ ÏÐÅÒÁÔÏÒ
694 ïÓÎÏ×ÎÙÅ ×ÓÔÒÏÅÎÎÙÅ ÔÉÐÙ ÏÂßÅËÔÏ×~--- ÓÐÉÓËÉ, ÍÁÔÒÉÃÙ É ÍÎÏÖÅÓÔ×Á.
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$.
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$.
742 \subsection{íÎÏÖÅÓÔ×Á
}
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$.
761 \section{ôÉÐÉÞÎÙÅ ÚÁÄÁÞÉ
}
763 \subsection{ïÐÒÅÄÅÌÅÎÉÅ ÆÕÎËÃÉÉ
}
767 \item æÕÎËÃÉÑ ÏÐÒÅÄÅÌÑÅÔÓÑ ÏÐÅÒÁÔÏÒÏÍ $
\mathbf{:=
}$, ÐÒÉ ÜÔÏÍ ×ÙÞÉÓÌÅÎÉÅ ÔÅÌÁ ÆÕÎËÃÉÉ
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);
779 (
%i1) foo (x) := diff (sin(x)^2, x);
781 (
%o1) foo(x) := diff(sin (x), x)
783 (
%o2) 2 cos(u) sin(u)
785 Non-variable
2nd argument to diff:
791 \item $
\mathbf{define
}$ ÏÐÒÅÄÅÌÑÅÔ ÆÕÎËÃÉÀ É ×ÙÞÉÓÌÑÅÔ ÅÅ ÔÅÌÏ.
793 \noindent÷ ÓÌÅÄÕÀÝÅÍ ÐÒÉÍÅÒÅ $
\mathbf{diff
}$ ×ÙÞÉÓÌÑÅÔÓÑ ÅÄÉÎÏÖÄÙ (ÐÒÉ ÏÐÒÅÄÅÌÅÎÉÉ), ÐÏÜÔÏÍÕ
794 $
\mathbf{foo
} (
1)$ ÎÅ ×ÙÚÙ×ÁÅÔ ÏÛÉÂËÉ:
795 % define (foo (x), diff (sin(x)^2, x));
800 (
%i1) define (foo (x), diff (sin(x)^2, x));
801 (
%o1) foo(x) := 2 cos(x) sin(x)
803 (
%o2) 2 cos(u) sin(u)
805 (
%o3) 2 cos(1) sin(1)
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]);
815 % [subst (s[1], eq_1), subst (s[1], eq_2)];
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 = -----------------]]
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,
833 (b +
5 a) y -
%pi (b + 5) y - %pi
834 ----------------- - --------------- -
5 y =
0]
837 (
%o6) [%pi = %pi, 0 = 0]
840 \subsection{éÎÔÅÇÒÉÒÏ×ÁÎÉÅ É ÄÉÆÆÅÒÅÎÃÉÒÏ×ÁÎÉÅ
}
842 $
\mathbf{integrate
}$ ×ÙÞÉÓÌÑÅÔ ÏÐÒÅÄÅÌÅÎÎÙÅ É ÎÅÏÐÒÅÄÅÌÅÎÎÙÅ ÉÎÔÅÇÒÁÌÙ:
843 % integrate (1/(1 + x), x, 0, 1);
844 % integrate (exp(-u) * sin(u), u, 0, inf);
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);
852 (
%i1) integrate (1/(1 + x), x, 0, 1);
854 (
%i2) integrate (exp(-u) * sin(u), u, 0, inf);
858 (
%i3) assume (a > 0);
860 (
%i4) integrate (1/(1 + x), x, 0, a);
862 (
%i5) integrate (exp(-a*u) * sin(a*u), u, 0, inf);
866 (
%i6) integrate (exp (sin (t)), t, 0, %pi);
874 (
%i7) 'integrate (exp(-u) * sin(u), u, 0, inf);
884 $
\mathbf{diff
}$ ×ÙÞÉÓÌÑÅÔ ÐÒÏÉÚ×ÏÄÎÙÅ É ÄÉÆÆÅÒÅÎÃÉÁÌÙ:
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);
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);
896 (
%i3) diff (sin (y*x), y);
898 (
%i4) diff (sin (y*x), x, 2);
901 (
%i5) 'diff (sin (y*x), x, 2);
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"]]);
920 (
%i1) plot2d (exp(-u) * sin(u), [u, 0, 2*%pi]);
922 (
%i2) plot2d ([exp(-u), exp(-u) * sin(u)], [u, 0, 2*%pi]);
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,
931 (
%i5) plot2d ([discrete, xx, yy]);
933 (
%i6) plot2d ([discrete, xx, yy], [gnuplot_curve_styles, ["with points"]]);
937 óÍ. ÔÁËÖÅ $
\mathbf{plot3d
}$.
939 \subsection{óÏÈÒÁÎÅÎÉÅ É ÚÁÇÒÕÚËÁ ÆÁÊÌÏ×
}
941 $
\mathbf{save
}$ ÚÁÐÉÓÙ×ÁÅÔ ×ÙÒÁÖÅÎÉÑ × ÆÁÊÌ:
944 % save ("my.session", a, b);
945 % save ("my.session", all);
950 (
%i2) b: foo^2 * bar;
953 (
%i3) save ("my.session", a, b);
955 (
%i4) save ("my.session", all);
959 $
\mathbf{load
}$ ÞÉÔÁÅÔ ×ÙÒÁÖÅÎÉÑ ÉÚ ÆÁÊÌÁ.
960 % load ("my.session");
965 (
%i1) load ("my.session");
974 óÍ. ÔÁËÖÅ $
\mathbf{stringout
}$ É $
\mathbf{batch
}$.
976 \section{ðÒÏÇÒÁÍÍÉÒÏ×ÁÎÉÅ ÐÏÄ Maxima
}
979 % argument-quoting and argument-evaluating functions
980 % directory organization: src, tests, share, doc
982 óÕÝÅÓÔ×ÕÅÔ ÏÄÎÏ ÐÒÏÓÔÒÁÎÓÔ×Ï ÉÍÅÎ, ÓÏÄÅÒÖÁÝÅÅ ×ÓÅ ÓÉÍ×ÏÌÙ Maxima. äÒÕÇÏÅ
983 ÐÒÏÓÔÒÁÎÓÔ×Ï ÉÍÅÎ ÓÏÚÄÁÔØ ÎÅÌØÚÑ.
985 ÷ÓÅ ÐÅÒÅÍÅÎÎÙÅ ÇÌÏÂÁÌØÎÙ, ÅÓÌÉ ÎÅ ÏÐÒÅÄÅÌÅÎÙ ÌÏËÁÌØÎÏ~--- × ÆÕÎËÃÉÑÈ, ÌÑÍÂÄÁ-×ÙÒÁÖÅÎÉÑÈ
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.
1007 \item ÷ÓÅ ÐÅÒÅÍÅÎÎÙÅ ÇÌÏÂÁÌØÎÙ, ÅÓÌÉ ÎÅ ÏÐÒÅÄÅÌÅÎÙ ÌÏËÁÌØÎÏ~--- × ÆÕÎËÃÉÑÈ,
1008 ÌÑÍÂÄÁ-×ÙÒÁÖÅÎÉÑÈ É ÂÌÏËÁÈ:
1010 % (x: 42, y: 1729, z: foo*bar);
1011 % f (x, y) := x*y*z;
1013 % lambda ([x, z], (x - z)/y);
1014 % apply (%, [uu, vv]);
1015 % block ([y, z], y: 65536, [x, y, z]);
1018 (
%i1) (x: 42, y: 1729, z: foo*bar);
1020 (
%i2) f (x, y) := x*y*z;
1021 (
%o2) f(x, y) := x y z
1024 (
%i4) lambda ([x, z], (x - z)/y);
1026 (
%o4) lambda([x, z], -----)
1028 (
%i5) apply (%, [uu, vv]);
1032 (
%i6) block ([y, z], y: 65536, [x, y, z]);
1033 (
%o6) [42, 65536, z]
1036 \item úÎÁÞÅÎÉÅÍ ÐÅÒÅÍÅÎÎÏÊ ÓÞÉÔÁÅÔÓÑ ÔÏ, ÞÔÏ ÂÙÌÏ ÐÒÉÓ×ÏÅÎÏ × ÐÏÓÌÅÄÎÉÊ ÒÁÚ, × Ñ×ÎÏÍ ×ÉÄÅ,
1037 ÌÉÂÏ ÞÅÒÅÚ ÐÒÉÓ×ÁÉ×ÁÎÉÅ ÚÎÁÞÅÎÉÑ ÌÏËÁÌØÎÏÊ ÐÅÒÅÍÅÎÎÏÊ:
1042 % bar (x) := foo (%e);
1046 (
%i1) foo (y) := x - y;
1047 (
%o1) foo(y) := x - y
1052 (
%i4) bar (x) := foo (%e);
1053 (
%o4) bar(x) := foo(%e)
1060 \section{Lisp É Maxima
}
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 É ÎÁÏÂÏÒÏÔ.
1092 \item úÁÐÉÓØ
{\bf :lisp
} $
\mathit{expr
}$ ×ÙÞÉÓÌÑÅÔ $
\mathit{expr
}$ × ÉÎÔÅÒÐÒÅÔÁÔÏÒÅ Lisp:
1101 ((MEXPT SIMP) ((MPLUS SIMP) $AA $BB)
2)
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);
1111 (
%i1) :lisp (defun $foo (a b) `((mplus) ((mtimes) ,a ,b) $%pi))
1113 (
%i1) (p: x + y, q: x - y);
1116 (
%o2) (x - y) (y + x) + %pi
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)))
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))>
1130 (
%i2) bar (''p, ''q);
1134 \item úÁÐÉÓØ $(
\mathbf{mfuncall\ '\$
}\mathrm{foo\
}a_1
\ldots a_n)$
1135 ×ÙÚÙ×ÁÅÔ ÉÚ Lisp ÆÕÎËÃÉÀ $
\mathbf{foo
}$, ÏÐÒÅÄÅÌÅÎÎÕÀ × Maxima:
1138 % :lisp (displa (mfuncall '$blurf '((mplus) $grotz $mumble)))
1140 (
%i1) blurf (x) := x^2;
1143 (
%i2) :lisp (displa (mfuncall '$blurf '((mplus) $grotz $mumble)))