create context-beginner-vi
[cuteobr.git] / context-beginner-vi / vi / ma-cb-vi-math.tex
blob67bb39f22ea7822f1cafd7f1b62adc008c2ea3bc
1 \startcomponent ma-cb-vi-math
2 \project ma-cb
3 \product ma-cb-vi
4 \environment ma-cb-env-vi
6 %\chapter[formulas]{Typesetting math}
7 \chapter[formulas]{Sắp chữ toán học}
9 %\section{Introduction}
10 \section{Giới thiệu}
12 %\index {math}
13 \index {toán}
15 %\TEX\ is {\em the} typesetting program for math. However,
16 %this is not the extensive chapter on typesetting math you
17 %might expect. We advise you to do some further reading on
18 %typesetting formulae in \TEX. See for example: \footnote{In
19 %this introduction on typesetting math we relied on the
20 %booklet {\em \TEX niques} by Arthur Samuel.}
21 \TEX\ là chương trình sắp chữ {\em dành} cho toán. Tuy nhiên, đây không phải
22 chương mở rộng về cách sắp chữ toán học mà bạn có thể mong đợi. Chúng tôi đề
23 nghị bạn đọc xa hơn về cách sắp chữ các công thức bằng \TEX. Ví dụ các sách:
24 \footnote{Trong phần giới thiệu về cách sắp chữ toón học này, chúng tôi dựa
25 vào cuốn {\em \TEX niques} của Arthur Samuel.}
27 %\startitemize[packed]
28 %\item {\em The \TeX Book} by D.E. Knuth
29 %\item {\em The Beginners Book of \TeX} by S. Levy and R. Seroul
30 %\stopitemize
31 \startitemize[packed]
32 \item {\em The \TeX Book} by D.E. Knuth
33 \item {\em The Beginners Book of \TeX} by S. Levy and R. Seroul
34 \stopitemize
36 %Furthermore a \CONTEXT\ math module and its
37 %accompanying manual will be published in due time.
38 Một module toán của \CONTEXT\ và sổ tay đi kèm của nó sẽ được xuất bản trong
39 thời gian tới.
41 %\section{Typesetting math}
42 \section{Sắp chữ toán học}
44 \index {math mode}
45 \index {display mode}
46 \index {text mode}
48 %Normally different conventions are applied for typesetting
49 %normal text and math text. These conventions are \quote{known}
50 %by \TEX\ and applied accordingly when generating a document.
51 %We can rely on \TEX\ for delivering high quality math output.
52 Bình thường, các quy ước khác nhau được áp dụng cho sắp chữ văn bản bình
53 thường và văn bản toán. Các quy ước này được \quote{biết} đến bởi \TEX\ và
54 được áp dụng phù hợp khi tạo ra tài liệu. Chúng ta có thể dựa vào \TEX\ để
55 xuất ra biểu thức toán chất lượng cao.
57 %A number of conventions for math are:
58 Một số các quy ước cho toán là:
60 %\startitemize[n,packed]
62 %\item Characters are typeset in $math\ italic$ (don't confuse
63 % this with the normal {\it italic characters} in a font).
65 %\item Symbols like Greek characters ($\alpha$, $\chi$)
66 % and math symbols ($\leq$, $\geq$, $\in$) are used.
68 %\item Spacing will differ from normal spacing.
70 %\item Math expression have a different alignment than that of
71 % the running text.
73 %\item The sub and superscripts are downsized automatically,
74 % like in $a^{b}_{c}$.
76 %\item Certain symbols have different appearances in the
77 % inline and display mode.
79 %\stopitemize
80 \startitemize[n,packed]
82 \item Các kí tự được sắp chữ bằng kí tự toán $nghiêng$ (đừng nhầm lẫn với kí
83 tự in nghiêng trong font chữ).
85 \item Các kí hiệu như là kí tự Hi Lạp ($\alpha$, $\chi$) và kí tự toán như
86 ($\leq$, $\geq$, $\in$) được dùng.
88 \item Kí tự khoảng trắng không giống bình thường.
90 \item Diễn đạt toán có cách sắp hàng khác với văn bản thường.
92 \item Các kí tự cơ số và lũy thừa được thu nhỏ tự động như thế này $a^{b}_{c}$.
94 \item Vài kí tự có cách thể hiện khác nhau trong phương thức trực tiếp và cách
95 hiển thị.
97 \stopitemize
99 %When typesetting math you have to work in the so called math
100 %mode in which math expressions can be defined by means of
101 %plain \TEX||commands.
102 Khi bạn sắp chữ toán học, bạn phải làm việc bằng phương thức toán là phương
103 thức mà cách diễn đạt toán có thể được định nghĩa bằng các lệnh thuần \TEX.
105 %Math mode has two alternatives: text mode and display mode.
106 %Math mode in text mode is activated by \type{$} and
107 %\type{$}, while display mode is activated by \type{$$} and
108 %\type{$$}.
109 Phương thức toán có hai tùy chọn: kiểu văn bản và kiểu hiển thị. Kiểu văn bản
110 được kích hoạt bằng cặp kí tự \type{$} trong khi kiểu hiển thị được kích hoạt
111 bằng cặp kí tự \type{$$}.
113 \startbuffer
114 The Hasselt community covers an area of 42,05 \Square \Kilo \Meter.
115 Now if you consider a circular area of this size with the market
116 place of Hasselt as the center point $M$ you can calculate its
117 diameter with ${{1}\over{4}} \pi r^2$.
118 \stopbuffer
120 \typebuffer
122 This will become:
124 \getbuffer
126 The many \type{{}} (grouping) in ${{1}\over{4}} \pi r^2$ are
127 essential for separating operations in the expression. If
128 you omit the outer curly braces like this:
129 \type{${1}\over{4} \pi r^2$}, you would get a non desired
130 result: ${1}\over{4} \pi r^2$.
132 The letters and numbers are typeset in three different
133 sizes: text size $a+b$, script size $\scriptstyle a+b$ and
134 scriptscript size $\scriptscriptstyle a+b$. These can be
135 influenced by the commands \type{\scriptstyle} and
136 \type{\scriptscriptstyle}.
138 Symbols like $\int$ and $\sum$ will have a different form in
139 text and display mode. If we type \type {$\sum_{n=1}^{m}$}
140 or \type {$\int_{-\infty}^{+\infty}$} we will get
141 {$\sum_{n=1}^{m}$} and {$\int_{-\infty}^{+\infty}$}. But
142 when you type \type {$$\sum_{n=1}^{m}$$} \type
143 {$$\int_{-\infty}^{+\infty}$$} to activate display mode you
144 will get:
146 \startformula
147 \sum_{n=1}^{m} \quad {\rm and} \quad \int_{-\infty}^{+\infty}
148 \stopformula
150 With the commands \type {\nolimits} and \type{\limits} you
151 can influence the appearances of \type{\sum} and \type{\int}:
153 \startformula
154 \sum_{n=1}^{m}\nolimits \quad {\rm and} \quad \int_{-\infty}^{+\infty}\limits
155 \stopformula
157 For typesetting fractions there is the command \type
158 {\over}. In \CONTEXT\ you can use the alternative
159 \type {\frac}. For ${\frac{a}{1+b}}+c$ we type for instance
160 \type {${\frac{a}{1+b}}+c$}.
162 Other commands to put one thing above the other, are:
164 \startbuffer[atop]
165 ${a} \atop {b}$
166 \stopbuffer
167 \startbuffer[choose]
168 ${n+1} \choose {k}$
169 \stopbuffer
170 \startbuffer[brack]
171 ${m} \brack {n}$
172 \stopbuffer
173 \startbuffer[brace]
174 ${m} \brace {n-1}$
175 \stopbuffer
177 \starttabulate[|l|l|l|l|]
178 \NC \type {\atop}
179 \NC \typebuffer[atop]
180 \NC \mathstrut\getbuffer[atop]
182 \NC\NR
183 \NC \type {\choose}
184 \NC \typebuffer[choose]
186 \NC \mathstrut\getbuffer[choose]
187 \NC\NR
188 \NC \type {\brack}
189 \NC \typebuffer[brack]
190 \NC \mathstrut\getbuffer[brack]
192 \NC\NR
193 \NC \type {\brace}
194 \NC \typebuffer[brace]
196 \NC \mathstrut\getbuffer[brace]
197 \NC\NR
198 \stoptabulate
200 \TEX\ can enlarge delimiters like (~) and $\{~\}$
201 automatically if the left and right delimiter is preceeded
202 by the commands \type {\left} and \type {\right}
203 respectively. If we type \type
204 {$$1+\left(\frac{1}{1-x^{x-2}}\right)^3$$} we get:
206 \startformula
207 1+\left(\frac{1}{1-x^{x-2}}\right)^3
208 \stopformula
210 Sub and superscripts are invoked by \quote {\type{_}} and
211 \quote {\type{^}}. They have effect on the next first
212 character so grouping with $\{$~$\}$ is necessary in case of
213 multi character sub and superscripts.
215 In certain situations the delimiters can be preceeded by
216 \type{\bigl}, \type{\Bigl}, \type{\biggl} and \type{\Biggl}
217 and their right counterparts. Even bigger delimiters can be
218 produced by placing \type{\left} and \type{\right} in a
219 \type{\vbox} construction. When we type a senseless
220 expression like \type{$$\left(\vbox to
221 16pt{}x^{2^{2^{2^{2}}}}\right)$$} we get:
223 \startformula
224 \left(\vbox to 16pt{}x^{2^{2^{2^{2}}}}\right)
225 \stopformula
227 In display mode the following delimiters will work in the
228 automatic enlargement mechanism:
230 \starttabulate[|l|l|l|l|l|l|l|l|]
231 \NC \type{\lfloor} \NC $\lfloor$
232 \NC \type{\langle} \NC $\langle$
233 \NC \type{\vert} \NC $\vert$
234 \NC \type{\downarrow} \NC $\downarrow$
235 \NC\NR
236 \NC \type{\rfloor} \NC $\rfloor$
237 \NC \type{\rangle} \NC $\rangle$
238 \NC \type{\Vert} \NC $\Vert$
239 \NC \type{\Downarrow} \NC $\Downarrow$
240 \NC\NR
241 \NC \type{\lceil} \NC $\lceil$
242 \NC \type{/} \NC $/$
243 \NC \type{\uparrow} \NC $\uparrow$
244 \NC \type{\updownarrow} \NC $\updownarrow$
245 \NC\NR
246 \NC \type{\rceil} \NC $\rceil$
247 \NC \type{\backslash} \NC $\backslash$
248 \NC \type{\Uparrow} \NC $\Uparrow$
249 \NC \type{\Updownarrow} \NC $\Updownarrow$
250 \NC\NR
251 \stoptabulate
253 In display mode we should typeset only one fraction and
254 otherwise switch to the \type{a/b} notation. To get:
256 \startformula
257 a_0 + {\frac{a}{a_1 + \frac{1}{a_2}}}
258 \stopformula
260 we will not type
261 \type{$$a_0+{\frac{a}{a_1+\frac{1}{a_2}}}$$}
262 but prefer
263 \type{$$a_0 + {\frac{a}{a_1 + 1/a_2}}$$},
264 to obtain:
266 \startformula
267 a_0 + {\frac{a}{a_1 + 1/a_2}}
268 \stopformula
270 In addition we could also use the command
271 \type{\displaystyle}. If we would type \type {$$a_0 +
272 {\frac{a}{a_1 + \frac{1}{\strut \displaystyle a_2}}}$$} we
273 will get:
275 \startformula
276 a_0 + {\frac{a}{a_1 + \frac{1}{\displaystyle a_2}}}
277 \stopformula
279 Below we demonstrate the commands \type{\matrix},
280 \type{\pmatrix}, \type{\ldots}, \type{\cdots} and
281 \type{\cases} without any further explanation.
283 \startbuffer[b]
285 \stopbuffer
287 \startbuffer[a]
288 A=\left(\matrix{x-\lambda & 1 & 0 \cr
289 0 & x-\lambda & 1 \cr
290 0 & 0 & x-\lambda \cr}\right)
291 \stopbuffer
293 \typebuffer[b,a,b] \startformula\getbuffer[a]\stopformula
295 \startbuffer[a]
296 A=\left|\matrix{x-\mu& 1 & 0 \cr
297 0 & x-\mu & 1 \cr
298 0 & 0 & x-\mu \cr}\right|
299 \stopbuffer
301 \typebuffer[b,a,b] \startformula\getbuffer[a]\stopformula
303 \startbuffer[a]
304 A=\pmatrix{a_{11} & a_{12} & \ldots & a_{1n} \cr
305 a_{21} & a_{22} & \ldots & a_{2n} \cr
306 \vdots & \vdots & \ddots & \vdots \cr
307 a_{m1} & a_{m2} & \ldots & a_{mn} \cr}
308 \stopbuffer
310 \typebuffer[b,a,b] \startformula\getbuffer[a]\stopformula
312 \startbuffer[a]
313 A=\pmatrix{a_{11} & a_{12} & \ldots & a_{1n} \cr
314 a_{21} & a_{22} & \ldots & a_{2n} \cr
315 \vdots & \vdots & \ddots & \vdots \cr
316 a_{m1} & a_{m2} & \ldots & a_{mn} \cr}
317 \stopbuffer
319 \typebuffer[b,a,b] \startformula\getbuffer[a]\stopformula
321 \startbuffer[a]
322 |x|=\cases{ x, & als $x\geq0$; \cr
323 -x, & anders \cr}
324 \stopbuffer
326 \typebuffer[b,a,b] \startformula\getbuffer[a]\stopformula
328 To typeset normal text in a math expression we have to
329 consider the following. First a space is not typeset in math
330 mode so we have to enforce one with \type{ \ } (backslash).
331 Second we have to indicate a font switch, because the text
332 should not appear in $math\ italic$ but in the actual font.
333 So in \CONTEXT\ we have to type \type{$$x^3+{\tf lower\
334 order\ terms}$$} to get:
336 \startformula
337 x^3+{\tf lower\ order\ terms}
338 \stopformula
340 The math functions like $\sin$ and $\tan$ that have to be
341 typeset in the actual font are predefined functions in
342 \TEX:
344 \starttabulate[|l|l|l|l|l|l|l|l|]
345 \NC \type{\arccos} \NC \type{\cos} \NC \type{\csc} \NC \type{\exp} \NC \type{\ker} \NC \type{\limsup} \NC \type{\min} \NC \type{\sinh} \NC\NR
346 \NC \type{\arcsin} \NC \type{\cosh} \NC \type{\deg} \NC \type{\gcd} \NC \type{\lg} \NC \type{\ln} \NC \type{\Pr} \NC \type{\sup} \NC\NR
347 \NC \type{\arctan} \NC \type{\cot} \NC \type{\det} \NC \type{\hom} \NC \type{\lim} \NC \type{\log} \NC \type{\sec} \NC \type{\tan} \NC\NR
348 \NC \type{\arg} \NC \type{\coth} \NC \type{\dim} \NC \type{\inf} \NC \type{\liminf} \NC \type{\max} \NC \type{\sin} \NC \type{\tanh} \NC\NR
349 \stoptabulate
351 If we type the sinus function
352 \type {$$\sin 2\theta=2\sin\theta\cos\theta$$}
353 or type the limit function
354 \type {$$\lim_{x\to0}{\frac{\sin x}{x}}=1$$} we will
355 get:
357 \startformula
358 \sin 2\theta=2\sin\theta\cos\theta
359 \quad {\tf or} \quad
360 \lim_{x\to0}{\frac{\sin x}{x}}=1
361 \stopformula
363 Alignment in math expressions may need special attention. In
364 multi line expressions we sometimes need alignment at the
365 \quote {$=$} sign. This is done by the command
366 \type{\eqalign}. If we type:
368 \startbuffer
369 $$\eqalign{
370 ax^2+bx+c &= 0 \cr
371 x &= \frac{-b \pm \sqrt{b^2-4ac}}{2a} \cr}$$
372 \stopbuffer
374 \typebuffer
376 we get:
378 \startformula
379 \eqalign{
380 ax^2+bx+c &= 0 \cr
381 x &= \frac{-b \pm \sqrt{b^2-4ac}}{2a} \cr}
382 \stopformula
384 Sometimes alignment at more than one location is wanted.
385 Watch the second line in the next example and see how it is
386 defined:
388 \startbuffer
389 $$\eqalign{
390 ax+bx+\cdots+yx+zx & = x(a +b+ \cdots \cr
391 &\phantom{= x(a~}+y+z) \cr
392 & = y \cr}$$
393 \stopbuffer
395 \typebuffer
397 This results in:
399 \startformula
400 \eqalign{
401 ax+bx+\cdots+yx+zx & = x(a +b+ \cdots \cr
402 &\phantom{= x(a~}+y+z) \cr
403 & = y \cr}
404 \stopformula
406 Next to the command \type{\phantom} there are
407 \type{\hphantom} without height and depth and
408 \type{\vphantom} without width.
410 You can rely on \TEX\ for spacing within a math expression.
411 In some situations, however you may want to influence
412 spacing. This is done by:
414 \starttabulate[|l|r|]
415 \NC \type{\!} \NC $-\frac{1}{6}$\type{\quad} \NC\NR
416 \NC \type{\,} \NC $\frac{1}{6}$\type{\quad} \NC\NR
417 \NC \type{\>} \NC $\frac{2}{9}$\type{\quad} \NC\NR
418 \NC \type{\;} \NC $\frac{5}{18}$\type{\quad} \NC\NR
419 \stoptabulate
421 These \quote {spaces} are related to \type {\quad} that stands
422 for the width of the capital \quote{M}.
424 The use of the command \type{\prime} speaks for itself. For
425 example if would want $y_1^\prime+y_2^{\prime\prime}$ you
426 should type \type{$y_1^\prime+y_2^{\prime\prime}$}.
428 An expression like $\root 3 \of {x^2+y^2}$ is obtained by
429 \type{$\root 3 \of {x^2+y^2}$}.
431 At the end of this section we point to the command
432 \type{\mathstrut} which we can use to enforce
433 consistency, for example within the root symbol.
434 With \type{$\sqrt{\mathstrut a}+\sqrt{\mathstrut d}+\sqrt{\mathstrut y}$}
435 we will get $\sqrt{\mathstrut a}+\sqrt{\mathstrut d}+\sqrt{\mathstrut y}$
436 in stead of $\sqrt{a}+\sqrt{d}+\sqrt{y}$.
438 See \in{appendix}[overviews] for a complete overview
439 of math commands.
441 \section{Placing formulaes}
443 \index{formula}
445 \Command{\tex{placeformula}}
446 \Command{\tex{startformula}}
447 \Command{\tex{setupformulae}}
449 You can typeset numbered formulaes with:
451 \shortsetup{placeformula}
452 \shortsetup{startformula}
454 Two examples:
456 \startbuffer
457 \placeformula[formula:aformula]
458 \startformula
459 y=x^2
460 \stopformula
462 \placeformula
463 \startformula
464 \int_0^1 x^2 dx
465 \stopformula
466 \stopbuffer
468 \typebuffer
470 \getbuffer
472 The \CONTEXT\ commands \type {\startformula} $\cdots$
473 \type{\stopformula} replace the begin and end \type{$$}. So
474 if you type:
476 \startbuffer
478 \int_0^1 x^2 dx
480 \stopbuffer
482 \typebuffer
484 you will get an expression that is {\em displayed} in the
485 middle of a page, but that is not as well aligned as the
486 previous examples.
488 \getbuffer
490 The command \type{\placeformula} handles spacing around the
491 formulae and the numbering of the formula. The bracket pair
492 is optional and is used for cross-references and to switch
493 numbering on and off.
495 \startbuffer
496 \placeformula[first one]
497 \startformula
498 y=x^2
499 \stopformula
501 \placeformula[middle one]
502 \startformula
503 y=x^3
504 \stopformula
506 \placeformula[last one]
507 \startformula
508 y=x^4
509 \stopformula
510 \stopbuffer
512 \getbuffer
514 \in{Formula}[middle one] was typed like this:
516 \startbuffer
517 \placeformula[middle one]
518 \startformula
519 y=x^3
520 \stopformula
521 \stopbuffer
523 \typebuffer
525 The label \type{[middle one]} is used for refering to this
526 formula. Such a reference is made with
527 \type{\in{formula}[middle one]}.
529 If no numbering is required you type:
531 \type{\placeformula[-]}
533 Numbering of formulae is set up with \type{\setupnumbering}.
534 In this manual numbering is set up with
535 \type{\setupnumbering[way=bychapter]}. This means that
536 the chapter number preceeds the formula number and numbering
537 is reset with each new chapter. For reasons of consistency
538 the tables, figures, intermezzi etc. are numbered in
539 the same way. Therefore you use \type{\setupnumbering} in
540 the set up area of your input file.
542 Formulae can be set up with:
544 \shortsetup{setupformulae}
546 \stopcomponent