Professional Documents
Culture Documents
LaTeX Cho GV THCS
LaTeX Cho GV THCS
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e
e
LATEX DÀNH CHO GIÁO VIÊN a
a
e a
e
e TRUNG HỌC CƠ SỞ a
a
e a
e a
e a
e a
e Hứa Đức Sinh a
e A a
e Nhóm Toán và LTEX a
e a
e a
e Ngày 16 tháng 7 năm 2018 a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
e a
dccccccccccccccccccccccccccccccccccccccccccccccb
Mục lục
GIỚI THIỆU 3
2
MỤC LỤC
3.7.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.8 Sử dụng lệnh \opset{<option>} để thiết lập các tùy chọn cho cả tài liệu . . . . 26
Trang 3
GIỚI THIỆU
LATEX là một công cụ soạn thảo mã nguồn mở giúp cho việc soạn thảo và in ấn tài liệu với
chất lượng bản in cực cao. LATEX hỗ trợ tối đa việc soạn thảo các công thức toán học, vẽ hình
véc-tơ, . . . Việc tạo các chú thích, tham chiếu, bảng biểu, mục lục, . . . một cách dễ dàng chỉ với
vài dòng lệnh đơn giản. Hơn nữa, vì là mã nguồn mở nên người soạn có thể tự tùy biến và tạo
ra các gói lệnh để phục vụ cho nhu cầu cá nhân cũng như cho cộng đồng.
Khác với các phần mềm soạn thảo kiểu WYSIWYG (như Microsoft Word), người soạn thảo
phải học cách soạn thảo dựa trên các dòng lệnh, đây cũng là một vấn đề chủ yếu làm cho những
người mới rất ngại khi tiếp xúc với LATEX.
May thay, nhờ sự phát triển của mạng xã hội Facebook, đặc biệt là sự ra đời của Nhóm
Toán và LATEX đã giúp cho cộng đồng người Việt có một nơi để giao lưu, học hỏi, trao đổi các
vấn đề về LATEX, trong đó có tôi.
Qua một thời gian học hỏi, bản thân tôi cũng gom nhặt được một chút kiến thức sơ khai về
A
L TEX trong cái kho tàng kiến thức đồ sộ ấy. Nhận thấy được sự khó khăn của rất nhiều thầy
cô khi mới tiếp xúc với LATEX, tôi viết tài liệu nho nhỏ này hy vọng sẽ giúp ích được cho các
thầy cô, đặc biệt là các thầy cô dạy THCS có thể dùng nó như là một tài liệu tham khảo.
Tài liệu được viết trong một thời gian ngắn và đặc biệt là sự hạn chế hiểu biết về LATEX của
bản thân nên sẽ không thể tránh khỏi được những thiếu sót và sai sót. Rất mong nhận được
sự góp ý chân thành của các thầy cô và bạn đọc để tài liệu được hoàn thiện hơn. Mọi ý kiến
đóng góp xin gửi về địa chỉ hdsinh.maths@gmail.com.
Hứa Đức Sinh
Ngày 16 tháng 7 năm 2018
4
Chương 1
Hiện nay có rất nhiều tài liệu trên mạng viết về LATEX kể cả tiếng Việt lẫn tiếng nước ngoài.
Ở đây tôi chỉ liệt kê ra một vài trang web giúp học hỏi và trao đổi những vấn đề có liên quan
đến LATEX, hy vọng nó sẽ giúp ích được nhiều cho quý thầy cô. Xin cảm ơn!
1. https://ctan.org/
2. https://www.facebook.com/groups/toanvalatex/
3. https://tex.stackexchange.com/
4. https://en.wikibooks.org/wiki/LaTeX/Mathematics
5. https://www.overleaf.com/
6. https://nhdien.wordpress.com/
7. http://math2it.com/
8. http://viettug.net/
9. http://vntex.sourceforge.net/vntexse3.html
10. https://www.luyenthithukhoa.vn/blog-trung-tam/900-huong-dan-su-dung-latex
..
.
5
Chương 2
Ở chương này tôi có sưu tầm và tổng hợp được một số macro hữu ích dành cho toán THCS
từ trang chủ https://tex.stackexchange.com. Trong quá trình sử dụng tôi có điều chỉnh lại tên
các macro cho hợp lý và dễ nhớ cho người sử dụng.
Cách 1: \usepackage{tkz-euclide}
\newif\ifcomma
\newcommand{\primes}[2]{%
\commafalse%
\foreach\numb in {#1,...,#2}{%
\pgfmathisprime{\numb}%
\ifnum\pgfmathresult=1
\ifcomma, \numb\else\numb\global\commatrue\fi%
\fi%
}%
}
Cách 2: \makeatletter
\def\primes#1#2{{%
\def\comma{\def\comma{, }}%
\count@\@ne\@tempcntb#2\relax\@curtab#1\relax
\@primes}}
\def\@primes{\loop\advance\count@\@ne
\expandafter\ifx\csname p-\the\count@\endcsname\relax
\ifnum\@tempcntb<\count@\else
\ifnum\count@<\@curtab\else\comma\the\count@\fi\fi\else\repeat
\@tempcnta\count@\loop\advance\@tempcnta\count@
\expandafter\let\csname p-\the\@tempcnta\endcsname\@ne
\ifnum\@tempcnta<\@tempcntb\repeat
\ifnum\@tempcntb>\count@\expandafter\@primes\fi}
\makeatother
6
2.2. TẠO BẢNG CÁC SỐ NGUYÊN TỐ LỚN NẰM TRONG ĐOẠN [A,B] BẰNG GÓI LỆNH XINTTOOLS.STY
2.1.3 Các ví dụ
\primes{1}{10}
2, 3, 5, 7
\primes{1}{100}
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97
\primes{1}{1000}
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101,
103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199,
211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317,
331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443,
449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577,
587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701,
709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839,
853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983,
991, 997
2.2 Tạo bảng các số nguyên tố lớn nằm trong đoạn [a,b]
bằng gói lệnh xinttools.sty
2.2.1 Khai báo trước \begin{document}
\usepackage{xinttools}
\makeatletter
\long\def\@gobblethree #1#2#3{}% thought that was in the kernel already...
% xinttools has \xint_gobble_iii but
% let’s not scare people with \catcode‘_ 11
% can be customized
% Nota Bene: must NOT be empty (can be a space, or a single character, but must
% not be empty) (the expandable cancellation of
% pre-/post-separator is handled in a more efficient way which however is not
% compatible with an empty separator)
\newcommand{\PrimeSeparator}{, }
\newcommand{\PrimeList}[2]{%
\expandafter\Primes@a\the\numexpr #1\expandafter.\the\numexpr #2.%
}
Trang 7
2.2. TẠO BẢNG CÁC SỐ NGUYÊN TỐ LỚN NẰM TRONG ĐOẠN [A,B] BẰNG GÓI LỆNH XINTTOOLS.STY
\makeatletter
\newcommand{\nbColumns}{10}
\newcounter{cellcount}
Trang 8
2.2. TẠO BẢNG CÁC SỐ NGUYÊN TỐ LỚN NẰM TRONG ĐOẠN [A,B] BẰNG GÓI LỆNH XINTTOOLS.STY
\newcommand{\SetUpSeparatorForTabular}
{\setcounter{cellcount}{1}%
\renewcommand\PrimeSeparator
{\ifnum\nbColumns=\value{cellcount}%
\expandafter\@firstoftwo
\else\expandafter\@secondoftwo
\fi {\\\setcounter{cellcount}{1}}
{&\stepcounter{cellcount}}}%
}
2.2.3 Các ví dụ
\begin{table}[!htbp]
\centering
\caption{\strut Bảng số nguyên tố từ 2000 đến 3000}
\renewcommand{\nbColumns}{11}
\SetUpSeparatorForTabular
\begin{tabular}{*{\nbColumns}c}
\hline
\PrimeList{2000}{3000} \\
\hline
\end{tabular}
\end{table}
\begin{table}[!htbp]
\centering
\caption{\strut Bảng số nguyên tố từ 20000 and 21000}
\renewcommand{\nbColumns}{7}
Trang 9
2.3. LIỆT KÊ N SỐ NGUYÊN TỐ ĐẦU TIÊN
\SetUpSeparatorForTabular
\begin{tabular}{*{\nbColumns}c}
\hline
\PrimeList{20000}{21000} \\
\hline
\end{tabular}
\end{table}
Trang 10
2.4. PHÂN TÍCH RA THỪA SỐ NGUYÊN TỐ (DẠNG CÂY)
Macro trên rất dễ xung đột với các lệnh khác trong LATEX, hiện tại tôi vẫn chưa tìm được
! các macro khác để thay thế nên ta tạm chấp nhận macro này.
2.3.3 Các ví dụ
Bạn có thể copy riêng đoạn code sau sang một file tex mới để chạy thử nghiệm:
\documentclass{article}
\usepackage[utf8]{vietnam}
\newif\ifprime \newif\ifunknown % boolean variables
\newcount\n \newcount\p \newcount\d \newcount\a % integer variables
\def\primes#1{2,~3% assume that #1 is at least 3
\n=#1 \advance\n by-2 % n more to go
\p=5 % odd primes starting with p
\loop\ifnum\n>0 \printifprime\advance\p by2 \repeat}
\def\printp{, % we will invoke \printp if p is prime
\ifnum\n=1 và~\fi % ‘and’ precedes the last value
\number\p \advance\n by -1 }
\def\printifprime{\testprimality \ifprime\printp\fi}
\def\testprimality{{\d=3 \global\primetrue
\loop\trialdivision \ifunknown\advance\d by2 \repeat}}
\def\trialdivision{\a=\p \divide\a by\d
\ifnum\a>\d \unknowntrue\else\unknownfalse\fi
\multiply\a by\d
\ifnum\a=\p \global\primefalse\unknownfalse\fi}
\begin{document}
100 số nguyên tố đầu tiên là \primes{100} \\
1000 số nguyên tố đầu tiên là \primes{1000} \\
\end{document}
\usepackage{forest,mathtools,siunitx}
\makeatletter
\def\ifNum#1{\ifnum#1\relax
\expandafter\pgfutil@firstoftwo\else
\expandafter\pgfutil@secondoftwo\fi}
\forestset{
num content/.style={
delay={
content/.expanded={\noexpand\num{\forestoption{content}}}}},
pt@prime/.style={draw, circle},
Trang 11
2.4. PHÂN TÍCH RA THỪA SỐ NGUYÊN TỐ (DẠNG CÂY)
pt@start/.style={},
pt@normal/.style={},
start primeTree/.style={%
/utils/exec=%
% \pt@start holds the current minimum factor, we’ll start with 2
\def\pt@start{2}%
% \pt@result will hold the to-be-typeset factorization, we’ll start with
% \pgfutil@gobble since we don’t want a initial \times
\let\pt@result\pgfutil@gobble
% \pt@start@cnt holds the number of ^factors for the current factor
\def\pt@start@cnt{0}%
% \pt@lStart will later hold "l"ast factor used
\let\pt@lStart\pgfutil@empty,
alias=pt-start,
pt@start/.try,
delay={content/.expanded={$\noexpand\num{\forestove{content}}
\noexpand\mathrlap{{}= \noexpand\pt@result}$}},
primeTree},
primeTree/.code=%
% take the content of the node and save it in the count
\c@pgf@counta\forestove{content}\relax
% if it’s 2 we’re already finished with the factorization
\ifNum{\c@pgf@counta=2}{%
% add the factor
\pt@addfactor{2}%
% finalize the factorization of the result
\pt@addfactor{}%
% and set the style to the prime style
\forestset{pt@prime/.try}%
}{%
% this simply calculates content/2 and saves it in \pt@end
% this is later used for an early break of the recursion since no factor
% can be greater then content/2 (for integers of course)
\edef\pt@content{\the\c@pgf@counta}%
\divide\c@pgf@counta2\relax
\advance\c@pgf@counta1\relax % to be on the safe side
\edef\pt@end{\the\c@pgf@counta}%
\pt@do}}
Trang 12
2.4. PHÂN TÍCH RA THỪA SỐ NGUYÊN TỐ (DẠNG CÂY)
Trang 13
2.4. PHÂN TÍCH RA THỪA SỐ NGUYÊN TỐ (DẠNG CÂY)
2.4.3 Các ví dụ
\PrimeTree{36} \PrimeTree{90}
36 = 22 × 32 90 = 2 × 32 × 5
2 18 2 45
2 9 3 15
3 3 3 5
Trang 14
2.5. PHÂN TÍCH RA THỪA SỐ NGUYÊN TỐ (CHIA CỘT)
\PrimeTree{112} \PrimeTree{612}
112 = 24 × 7 612 = 22 × 32 × 17
2 56 2 306
2 28 2 153
2 14 3 51
2 7 3 17
\PrimeTree{7875} \PrimeTree{22230}
7875 = 32 × 53 × 7 22 230 = 2 × 32 × 5 × 13 × 19
3 2625 2 11 115
3 875 3 3705
5 175 3 1235
5 35 5 247
5 7 13 19
\usepackage{pstricks}
\usepackage{xlop} %Gói chính
\newcount\primeindex
\newcount\tryindex
\newif\ifprime
\newif\ifagain
\newcommand\getprime[1]{%
\opcopy{2}{P0}%
\opcopy{3}{P1}%
\opcopy{5}{try}
\primeindex=2
\loop
\ifnum\primeindex<#1\relax
\testprimality
Trang 15
2.5. PHÂN TÍCH RA THỪA SỐ NGUYÊN TỐ (CHIA CỘT)
\ifprime
\opcopy{try}{P\the\primeindex}%
\advance\primeindex by1
\fi
\opadd * {try}{2}{try}%
\ifnum\primeindex<#1\relax
\testprimality
\ifprime
\opcopy{try}{P\the\primeindex}%
\advance\primeindex by1
\fi
\opadd * {try}{4}{try}%
\fi
\repeat
}
\newcommand\testprimality{%
\begingroup
\againtrue
\global\primetrue
\tryindex=0
\loop
\opidiv * {try}{P\the\tryindex}{q}{r}%
\opcmp{r}{0}%
\ifopeq \global\primefalse \againfalse \fi
\opcmp{q}{P\the\tryindex}%
\ifoplt \againfalse \fi
\advance\tryindex by1
\ifagain
\repeat
\endgroup
}
\newcommand\PrimeColumn[2][nil]{%
\begingroup
\opset{#1}%
\opcopy{#2}{NbtoDecompose}%
\opabs{NbtoDecompose}{NbtoDecompose}%
\opinteger{NbtoDecompose}{NbtoDecompose}%
\opcmp{NbtoDecompose}{0}%
\ifopeq
I refuse to factorize zero.
\else
\setbox1=\hbox{\opdisplay{operandstyle.1}%
{NbtoDecompose}}%
{\setbox2=\box2{}}%
\count255=1
\primeindex=0
\loop
\opcmp{NbtoDecompose}{1}\ifopneq
Trang 16
2.5. PHÂN TÍCH RA THỪA SỐ NGUYÊN TỐ (CHIA CỘT)
\opidiv * {NbtoDecompose}{P\the\primeindex}{q}{r}%
\opcmp{0}{r}\ifopeq
\ifvoid2
\setbox2=\hbox{%
\opdisplay{intermediarystyle.\the\count255}%
{P\the\primeindex}}%
\else
\setbox2=\vtop{%
\hbox{\box2}
\hbox{%
\opdisplay{intermediarystyle.\the\count255}%
{P\the\primeindex}}}
\fi
\opcopy{q}{NbtoDecompose}%
\advance\count255 by1
\setbox1=\vtop{%
\hbox{\box1}
\hbox{%
\opdisplay{operandstyle.\the\count255}%
{NbtoDecompose}}
}%
\else
\advance\primeindex by1
\fi
\repeat
\hbox{\box1
\kern0.5\opcolumnwidth
\opvline(0,0.75){\the\count255.25}
\kern0.5\opcolumnwidth
\box2}%
\fi
\endgroup
}
\getprime{50} %Ước lượng số lượng số nguyên tố cần dùng
\PrimeColumn[operandstyle=\<màu>,intermediarystyle=\<màu>]{<number>}
2.5.3 Các ví dụ
2 7 31 229
Trang 17
2.6. PHÂN TÍCH RA THỪA SỐ NGUYÊN TỐ (CHỈ ĐƯA RA ĐÁP SỐ)
\PrimeColumn[operandstyle=\blue,intermediarystyle=\red]{252}
2 52 2
1 26 2
6 3 3
2 1 3
7 7
1
\PrimeColumn{374220}
3 7 4 2 20 2
1 8 7 1 10 2
9 3 5 5 5 3
3 1 1 8 5 3
1 0 3 9 5 3
3 4 6 5 3
1 1 5 5 3
3 8 5 5
7 7 7
1 1 11
1
\makeatletter
Trang 18
2.6. PHÂN TÍCH RA THỪA SỐ NGUYÊN TỐ (CHỈ ĐƯA RA ĐÁP SỐ)
\ifnum\factorize@n>1
\factorize@process{\the\factorize@n}{1}%
\fi%
\else%
\factorize@process{\the\factorize@n}{1}%
\fi%
\factorize@end{#1}%
}
\def\factorize@loop{%
\factorize@t=\factorize@p
\multiply\factorize@t by \factorize@p
\ifnum\factorize@t>\factorize@n\else%
\factorize@try%
\advance\factorize@p by 2
\factorize@t=\factorize@p
\multiply\factorize@t by \factorize@p
\ifnum\factorize@t>\factorize@n\else%
\factorize@try%
\advance\factorize@p by 4
\factorize@loop%
\fi%
\fi%
}
\def\factorize@try{%
\factorize@w=0
\factorize@try@aux%
\ifnum\factorize@w>0
\factorize@process{\the\factorize@p}{\the\factorize@w}%
\advance\factorize@c by \factorize@w
\fi%
}
\def\factorize@try@aux{%
\factorize@t=\factorize@n
\divide\factorize@t by \factorize@p
\multiply\factorize@t by \factorize@p
\ifnum\factorize@n=\factorize@t
\divide\factorize@n by \factorize@p
\advance\factorize@w by 1
\factorize@try@aux%
\fi%
}
Trang 19
2.6. PHÂN TÍCH RA THỪA SỐ NGUYÊN TỐ (CHỈ ĐƯA RA ĐÁP SỐ)
$%$
\par%
}
\def\factorize@process#1#2{%
\ifnum\factorize@c>0
\times%
\fi%
\ifnum#2>1
#1^{#2}%
\else%
#1%
\fi%
}
\makeatother
2.6.3 Các ví dụ
\PrimeAns{36} \PrimeAns{90}
36 = 22 × 32 90 = 2 × 32 × 5
\PrimeAns{112} \PrimeAns{612}
112 = 24 × 7 612 = 22 × 32 × 17
\PrimeAns{7875} \PrimeAns{22230}
7875 = 32 × 53 × 7 22230 = 2 × 32 × 5 × 13 × 19
Trang 20
Chương 3
Gói xlop.sty được thiết kế để thực hiện các phép tính số học một cách tự động đối với các
số lớn tùy ý và có thể hiển thị được kết quả ở dạng cột hoặc dòng. Tài liệu này sẽ chỉ liệt kê
những chức năng hay dùng nhất và phù hợp với sách giáo khoa hiện hành của Việt Nam. Để
hiểu rõ hết các chức năng của gói lệnh, các bạn có thể tải manuals của gói lệnh tại đây.
\opadd{45.05}{78.4} \opadd[carryadd=false]{45.05}{78.4}
1
4 5.0 5 4 5.0 5
+ +
7 8.4 7 8.4
1 2 3.4 5 1 2 3.4 5
\opadd[carryadd=false,decimalsepsymbol={,}]{45.05}{78.4}
4 5,0 5
+
7 8,4
1 2 3,4 5
\opadd[carryadd=false,decimalsepsymbol={,},columnwidth=0.5em]{45.05}{78.4}
45,05
+
78,4
123,45
21
3.3. PHÉP TRỪ
\opadd[carryadd=false,decimalsepsymbol={,},columnwidth=0.5em,%
decimalsepwidth=0.27778em]{45.05}{78.4}
45,05
+
78,4
123,45
\opadd[operandstyle=\blue,resultstyle=\red,%
carrystyle=\scriptsize\green]{45.89}{127.5}
1 1
4 5.8 9
+
1 2 7.5
1 7 3.3 9
\opadd[carryadd=false,decimalsepsymbol={,},style=text]{45.05}{78.4}
\opadd[carryadd=false,decimalsepsymbol={,},style=text]{-2.5}{-3.8}
\opadd[carryadd=false,decimalsepsymbol={,},style=text,%
parenthesisnegative=all]{-2.5}{-3.8}
\opadd[carryadd=false,decimalsepsymbol={,},style=text,%
parenthesisnegative=last]{-2.5}{-3.8}
\opsub{-245}{72} \opsub[style=text]{-245}{72}
1 −245 − 72 = −317
245
+
72
317
\opsub{1.2}{2.45} \opsub[style=text]{1.2}{2.45}
Trang 22
3.4. PHÉP NHÂN
\opmul{453}{1001205}
4 53
×
1001 2 05
2 2 65
90 6 ·
453
453 · ·
453545 865
\opmul[displayshiftintermediary=none]{453}{1001205}
453
×
1001205
2265
906
453
453
453545865
\opmul[displayintermediary=all]{453}{1001205}
4 53
×
1001 2 05
2 2 65
0 0 0
90 6
453
000
000
453
453545865
\opmul[displayintermediary=None]{453}{1001205}
453
×
1001205
453545865
\opmul[decimalsepsymbol={,}]{3.1416}{12.8}
3,1 4 16
×
1 2,8
2513 28
6283 2
31416
4 0,2 1 2 48
Trang 23
3.5. PHÉP CHIA
\opmul[style=text]{01.44}{25}
1.44 × 25 = 36
\newcommand\hole[1]{\texttt{\_}}
\opmul[decimalsepsymbol={,},intermediarystyle=\hole,resultstyle=\hole,%
resultstyle.d=\white]{2.46}{35.7}
2,4 6
×
3 5,7
____
____
___
_ _,_ _ _
Cú pháp:
opdiv[<option>]{number 1}{number 2}
hoặc opidiv[<option>]{number 1}{number 2}
\opdiv{132054}{3}
132054 3
12 44018
005
024
0
\opdiv{10}{3}
25 7
40 3.5 7 1 4 2 8 5 7 1
50
10
30
20
60
40
50
10
3
\opdiv[period]{10}{3}
Trang 24
3.5. PHÉP CHIA
25 7
40 3.5 7 1 4 2 8
50
10
30
20
60
4
\opdiv[maxdivstep=5]{25}{7}
25 7
40 3.5 7 1 4
50
10
30
2
\opidiv{10}{3}
25 7
4 3
\opdiv[style=text]{25}{7}
25 ÷ 7 ≈ 3.571428571
\opdiv[style=text,period]{25}{7}
25 ÷ 7 = 3.571428. . .
\opdiv[period,style=text,equalsymbol=$\approx$,hrulewidth=0.2pt,%
vruleperiod=0.8,afterperiodsymbol=]{25}{7}
25 ÷ 7 ≈ 3.571428
\opdiv[maxdivstep=5,style=text]{25}{7}
25 ÷ 7 ≈ 3.5714
\opidiv[style=text]{25}{7}
25 = 7 × 3 + 4
\opdiv[decimalsepsymbol={,},columnwidth=0.6em,decimalsepwidth=0.27778em,%
displayintermediary=nonzero,voperation=top]{251}{25}
251 25
−
25 10,04
0100
−
100
0
Trang 25
3.6. TÌM ƯỚC CHUNG LỚN NHẤT (ƯCLN) CỦA HAI SỐ
$\text{ƯCLN}(12;8)=\opgcd{12}{8}{d} \opprint{d}$
ƯCLN(12; 8) = 4
$\text{ƯCLN}(1284;744)=\opgcd{1284}{744}{d} \opprint{d}$
ƯCLN(1284; 744) = 12
$\text{ƯCLN}(1234567890;13579)=\opgcd{1234567890}{13579}{d} \opprint{d}$
ƯCLN(1234567890; 13579) = 1
| − 25| = 25
Trang 26
3.8. SỬ DỤNG LỆNH \OPSET{<OPTION>} ĐỂ THIẾT LẬP CÁC TÙY CHỌN CHO CẢ TÀI LIỆU
3.7.3 ...
Trang 27
Chương 4
\polyadd\P{2x+1}{x+x^2} \polyprint\P
x2 + 3x + 1
\polyadd\P{x^3+x+1}{2x^2-x-2} \polyprint\P
x3 + 2x2 − 1
28
4.2. CỘNG, TRỪ, NHÂN, CHIA ĐA THỨC
− x2 + x + 1
\polysub\P{x^3+x+1}{2x^2-x-2} \polyprint\P
x3 − 2x2 + 2x + 3
x2 − 1
\polymul\P{x+1}{x^2-x+1} \polyprint\P
x3 + 1
\polymul\P{x^2-x+2}{2x^3-3x+1} \polyprint\P
\polylongdiv[style=D]{2x^4+x^3-x+1}{x^2+2}
2x4 + x3 − x + 1 x2 + 2
− 2x4 − 4x2 2x2 + x − 4
x3 − 4x2 − x
− x3 − 2x
− 4x2 − 3x + 1
4x2 +8
− 3x + 9
\polylongdiv[style=D]{x^3-x^2+x-1}{x-1}
x3 − x2 + x − 1 x − 1
− x3 + x2 x2 + 1
x−1
−x+1
0
Trang 29
4.2. CỘNG, TRỪ, NHÂN, CHIA ĐA THỨC
• style=A • style=B
x2 +1 x3 − x2 + x − 1 = x − 1 x2 + 1
− x3 + x2
x−1 x 3 − x2 + x − 1
− x 3 + x2 x−1
x−1 −x+1
−x+1 0
0
• style=C
x3 − x2 + x − 1 ÷ x − 1 = x2 + 1
− x3 + x2
x−1
−x+1
0
\polylongdiv[style=D,stage=1]{x^3-x^2+x-1}{x-1}
x3 − x2 + x − 1 x − 1
\polylongdiv[style=D,stage=2]{x^3-x^2+x-1}{x-1}
x3 − x2 + x − 1 x − 1
x2
\polylongdiv[style=D,stage=3]{x^3-x^2+x-1}{x-1}
x3 − x2 + x − 1 x − 1
− x3 + x2 x2
\polylongdiv[style=D,stage=4]{x^3-x^2+x-1}{x-1}
x3 − x2 + x − 1 x − 1
− x3 + x2 x2
x−1
\polylongdiv[style=D,stage=5]{x^3-x^2+x-1}{x-1}
x3 − x2 + x − 1 x − 1
− x3 + x2 x2 + 1
x−1
\polylongdiv[style=D,stage=6]{x^3-x^2+x-1}{x-1}
Trang 30
4.3. SƠ ĐỒ HORNER
x3 − x2 + x − 1 x − 1
− x3 + x2 x2 + 1
x−1
−x+1
\polylongdiv[style=D,stage=7]{x^3-x^2+x-1}{x-1}
x3 − x2 + x − 1 x − 1
− x3 + x2 x2 + 1
x−1
−x+1
0
\polylongdiv[style=C,div=:]{x^3-x^2+x-1}{x-1}
x3 − x2 + x − 1 : x − 1 = x2 + 1
− x3 + x2
x−1
−x+1
0
\polylongdiv[style=C,div=/]{x^3-x^2+x-1}{x-1}
x3 − x2 + x − 1 / x − 1 = x2 + 1
− x3 + x2
x−1
−x+1
0
4.2.4.4 Sử dụng lệnh \polyset{<key=list value>} để thiết lập các tùy chọn cho
cả tài liệu
Chẳng hạn, dùng lệnh \polyset{style=D,stage=1,div=:} đặt trước \begin{document},
khi đó các tùy chọn đã thiết lập sẽ có tác dụng trên toàn bộ văn bản.
4.3 Sơ đồ Horner
Cú pháp: \polyhornerscheme[<key=value list>]{<polynomial>}
\polyhornerscheme[x=1]{x^3+x^2-1}
1 1 0 −1
1 1 2 2
1 2 2 1
Trang 31
4.4. PHÂN TÍCH ĐA THỨC THÀNH NHÂN TỬ
\polyhornerscheme[x=1,showvar=true]{x^3+x^2-1}
1 1 0 −1
x=1 1 2 2
1 2 2 1
\polyhornerscheme[x=1,showmiddlerow=false]{x^3+x^2-1}
1 1 0 −1
1 2 2 1
\polyfactorize{(x-1)(x-1)(x^2+1)}
2
x2 + 1 x−1
\polyfactorize{2x^3+x^2-7x+3}
√ √
13
1 1
2 x− 2 x+ 2 + 2 x + 2 − 213
1
Thêm \displaystyle:
$\displaystyle\polyfactorize{2x^3+x^2-7x+3}$
!
1
1
√ !
13 1
√ !
13
=⇒ 2 x − x+ + x+ −
2 2 2 2 2
\polyfactorize{120x^5-274x^4+225x^3-85x^2+15x-1}
120 x − 1 x − 12 x − 13 x − 14 x − 51
4.5 Thuật toán Euclide tìm ước chung lớn nhất của hai
đa thức
Cú pháp: \polylonggcd{<polynomial 1>}{<polynomial 2>}
\polylonggcd{(x-1)(x-1)(x^2+1)}{(x-1)(x+1)(x+1)}
x4 − 2x3 + 2x2 − 2x + 1 = x3 + x2 − x − 1 · x − 3 + 6x2 − 4x − 2
x3 + x2 − x − 1 = 6x2 − 4x − 2 · 16 x + 185
+ 49 x − 49
4
x − 49 · 27 x + 29 + 0
6x2 − 4x − 2 = 9 2
Trang 32
Tài liệu tham khảo
[1] https://tex.stackexchange.com/.
33