You are on page 1of 33

^______________________________________________`

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

1 MỘT VÀI TRANG WEB HỌC LATEX 4

2 MỘT SỐ MACRO QUAN TRỌNG 5


2.1 Liệt kê các số nguyên tố nằm trong đoạn [a,b] . . . . . . . . . . . . . . . . . . . 5
2.1.1 Khai báo trước \begin{document} . . . . . . . . . . . . . . . . . . . . . 5
2.1.2 Cách sử dụng . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.1.3 Các ví dụ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 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 6
2.2.1 Khai báo trước \begin{document} . . . . . . . . . . . . . . . . . . . . . 6
2.2.2 Cách sử dụng . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.2.3 Các ví dụ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.3 Liệt kê n số nguyên tố đầu tiên . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.3.1 Khai báo trước \begin{document} . . . . . . . . . . . . . . . . . . . . . 9
2.3.2 Cách sử dụng . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.3.3 Các ví dụ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.4 Phân tích ra thừa số nguyên tố (dạng cây) . . . . . . . . . . . . . . . . . . . . . 10
2.4.1 Khai báo trước \begin{document} . . . . . . . . . . . . . . . . . . . . . 10
2.4.2 Cách sử dụng . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.4.3 Các ví dụ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.5 Phân tích ra thừa số nguyên tố (chia cột) . . . . . . . . . . . . . . . . . . . . . . 14
2.5.1 Khai báo trước \begin{document} . . . . . . . . . . . . . . . . . . . . . 14
2.5.2 Cách sử dụng . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.5.3 Các ví dụ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.6 Phân tích ra thừa số nguyên tố (chỉ đưa ra đáp số) . . . . . . . . . . . . . . . . 17
2.6.1 Khai báo trước \begin{document} . . . . . . . . . . . . . . . . . . . . . 17
2.6.2 Cách sử dụng . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.6.3 Các ví dụ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

3 GÓI LỆNH XLOP.STY 20


3.1 Khai báo gói lệnh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.2 Phép cộng . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.3 Phép trừ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.4 Phép nhân . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.5 Phép chia . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.6 Tìm ước chung lớn nhất (ƯCLN) của hai số . . . . . . . . . . . . . . . . . . . . 25
3.7 Một số lệnh tính toán khác . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.7.1 Tính căn bậc hai của một số . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.7.2 Tính giá trị tuyệt đối của một số . . . . . . . . . . . . . . . . . . . . . . 25

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

4 GÓI LỆNH POLYNOM.STY XỬ LÝ CÁC VẤN ĐỀ VỀ ĐA THỨC 27


4.1 Khai báo gói lệnh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.2 Cộng, trừ, nhân, chia đa thức . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.2.1 Cộng hai đa thức . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.2.2 Trừ hai đa thức . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.2.3 Nhân hai đa thức . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.2.4 Chia hai đa thức . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.2.4.1 Thực hiện đầy đủ các bước . . . . . . . . . . . . . . . . . . . . 28
4.2.4.2 Thực hiện từng bước . . . . . . . . . . . . . . . . . . . . . . . . 29
4.2.4.3 Sử dụng tùy chọn div=<token> dành cho style=C . . . . . . . 30
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 . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.3 Sơ đồ Horner . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.4 Phân tích đa thức thành nhân tử . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.5 Thuật toán Euclide tìm ước chung lớn nhất của hai đa thức . . . . . . . . . . . 31

TÀI LIỆU THAM KHẢO 32

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

MỘT VÀI TRANG WEB HỌC LATEX

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

MỘT SỐ MACRO QUAN TRỌNG

Ở 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.

2.1 Liệt kê các số nguyên tố nằm trong đoạn [a,b]


2.1.1 Khai báo trước \begin{document}

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.2 Cách sử dụng


\primes{<a>}{<b>}

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

\def\Primes@a #1.#2.{\ifnum #2<2 \expandafter\@gobblethree


\else
\ifnum #1>#2
\expandafter\expandafter\expandafter\@gobblethree
\fi\fi
\Primes@b {#1}{#2}}

\def\Primes@abort@b\fi #1\fi #2#3.#4.{\fi }

\def\Primes@b #1#2{\ifnum #2=2 2\Primes@abort@b\fi


\ifnum #1<3 2\expandafter\@firstoftwo
\else\expandafter\@secondoftwo
\fi
{\Primes@c 3}
{\expandafter\Primes@GobFirstSep
\romannumeral-‘0\expandafter\Primes@c
\the\numexpr 2*((#1-1)/2)+1}%
.#2.}

% 3<= #1 odd but if #1=#2=2n initially, then now #1>#2


%
\def\Primes@abort@c\fi #1.#2.{\fi \space\Primes@GobFirstSep}

\def\Primes@c #1.#2.{\ifnum #1>#2 \Primes@abort@c\fi


\expandafter\Primes@d\the\numexpr 2*(#2/2)-1.#1.}

\def\Primes@d #1.#2.{% here #2 is odd start and #1 odd finish, #1>=#2


\xintiloop [#2+2]
{\xintiloop [3+2]
\ifnum\xintouteriloopindex<\numexpr\xintiloopindex*\xintiloopindex\relax
\PrimeSeparator\@gobble\Primes@GobFirstSep\xintouteriloopindex
\expandafter\xintbreakiloop
\fi
\ifnum\xintouteriloopindex=\numexpr
(\xintouteriloopindex/\xintiloopindex)*\xintiloopindex\relax
\else
\repeat
}% no space here
\ifnum \xintiloopindex <#1 \repeat
}

% PrimeSeparator ne doit pas être vide, au minimun un espace


\def\Primes@GobFirstSep #1\Primes@GobFirstSep {}

\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.2 Cách sử dụng


\PrimeList{<a>}{<b>}

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}

Bảng 2.1: Bảng số nguyên tố từ 2000 đến 3000


2003 2011 2017 2027 2029 2039 2053 2063 2069 2081 2083
2087 2089 2099 2111 2113 2129 2131 2137 2141 2143 2153
2161 2179 2203 2207 2213 2221 2237 2239 2243 2251 2267
2269 2273 2281 2287 2293 2297 2309 2311 2333 2339 2341
2347 2351 2357 2371 2377 2381 2383 2389 2393 2399 2411
2417 2423 2437 2441 2447 2459 2467 2473 2477 2503 2521
2531 2539 2543 2549 2551 2557 2579 2591 2593 2609 2617
2621 2633 2647 2657 2659 2663 2671 2677 2683 2687 2689
2693 2699 2707 2711 2713 2719 2729 2731 2741 2749 2753
2767 2777 2789 2791 2797 2801 2803 2819 2833 2837 2843
2851 2857 2861 2879 2887 2897 2903 2909 2917 2927 2939
2953 2957 2963 2969 2971 2999

\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}

Bảng 2.2: Bảng số nguyên tố từ 20000 and 21000


20011 20021 20023 20029 20047 20051 20063
20071 20089 20101 20107 20113 20117 20123
20129 20143 20147 20149 20161 20173 20177
20183 20201 20219 20231 20233 20249 20261
20269 20287 20297 20323 20327 20333 20341
20347 20353 20357 20359 20369 20389 20393
20399 20407 20411 20431 20441 20443 20477
20479 20483 20507 20509 20521 20533 20543
20549 20551 20563 20593 20599 20611 20627
20639 20641 20663 20681 20693 20707 20717
20719 20731 20743 20747 20749 20753 20759
20771 20773 20789 20807 20809 20849 20857
20873 20879 20887 20897 20899 20903 20921
20929 20939 20947 20959 20963 20981 20983

2.3 Liệt kê n số nguyên tố đầu tiên


2.3.1 Khai báo trước \begin{document}

\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}

Trang 10
2.4. PHÂN TÍCH RA THỪA SỐ NGUYÊN TỐ (DẠNG CÂY)

2.3.2 Cách sử dụng


\primes{<n>}

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}

2.4 Phân tích ra thừa số nguyên tố (dạng cây)


2.4.1 Khai báo trước \begin{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}}

%%% our main "function"


\def\pt@do{%
% let’s test if the current factor is already greather then the max factor
\ifNum{\pt@end<\pt@start}{%
% great, we’re finished, the same as above
\expandafter\pt@addfactor\expandafter{\pt@content}%
\pt@addfactor{}%
\def\pt@next{\forestset{pt@prime/.try}}%
}{%
% this calculates int(content/factor)*factor

Trang 12
2.4. PHÂN TÍCH RA THỪA SỐ NGUYÊN TỐ (DẠNG CÂY)

% if factor is a factor of content (without remainder), the result will


% equal content. The int(content/factor) is saved in \pgf@temp.
\c@pgf@counta\pt@content\relax
\divide\c@pgf@counta\pt@start\relax
\edef\pgf@temp{\the\c@pgf@counta}%
\multiply\c@pgf@counta\pt@start\relax
\ifNum{\the\c@pgf@counta=\pt@content}{%
% yeah, we found a factor, add it to the result and ...
\expandafter\pt@addfactor\expandafter{\pt@start}%
% ... add the factor as the first child with style pt@prime
% and the result of int(content/factor) as another child.
\edef\pt@next{\noexpand\forestset{%
append={[\pt@start, pt@prime/.try]},
append={[\pgf@temp, pt@normal/.try]},
% forest is complex, this makes sure that for the second child, the
% primeTree style is not executed too early (there must be a better way).
delay={
for descendants={
delay={if n’=1{primeTree, num content}{}}}}}}%
}{%
% Alright this is not a factor, let’s get the next factor
\ifNum{\pt@start=2}{%
% if the previous factor was 2, the next one will be 3
\def\pt@start{3}%
}{%
% hmm, the previos factor was not 2,
% let’s add 2, maybe we’ll hit the next prime number
% and maybe a factor
\c@pgf@counta\pt@start
\advance\c@pgf@counta2\relax
\edef\pt@start{\the\c@pgf@counta}%
}%
% let’s do that again
\let\pt@next\pt@do
}%
}%
\pt@next
}

%%% this builds the \pt@result macro with the factors


\def\pt@addfactor#1{%
\def\pgf@tempa{#1}%
% is it the same factor as the previous one
\ifx\pgf@tempa\pt@lStart
% add 1 to the counter
\c@pgf@counta\pt@start@cnt\relax
\advance\c@pgf@counta1\relax
\edef\pt@start@cnt{\the\c@pgf@counta}%
\else

Trang 13
2.4. PHÂN TÍCH RA THỪA SỐ NGUYÊN TỐ (DẠNG CÂY)

% a new factor! Add the previous one to the product of factors


\ifx\pt@lStart\pgfutil@empty\else
% as long as there actually is one, the \ifnum makes sure we do not add ^1
\edef\pgf@tempa{\noexpand\num{\pt@lStart}\ifnum\pt@start@cnt>1
^{\noexpand\num{\pt@start@cnt}}\fi}%
\expandafter\pt@addfactor@\expandafter{\pgf@tempa}%
\fi
% setup the macros for the next round
\def\pt@lStart{#1}% <- current (new) factor
\def\pt@start@cnt{1}% <- first time
\fi
}
%%% This simply appends "\times #1" to \pt@result, with etoolbox this would be
%%% \appto\pt@result{\times#1}
\def\pt@addfactor@#1{%
\expandafter\def\expandafter\pt@result\expandafter{\pt@result \times #1}}

%%% Our main macro:


%%% #1 = possible optional argument for forest (can be tikz too)
%%% #2 = the number to factorize
\newcommand*{\PrimeTree}[2][]{%
\begin{forest}%
% as the result is set via \mathrlap it doesn’t update the bounding box
% let’s fix this:
tikz={execute at end scope={\pgfmathparse{width("${}=\pt@result$")}%
\path ([xshift=\pgfmathresult pt]pt-start.east);}},
% other optional arguments
#1
% And go!
[#2, start primeTree]
\end{forest}}
\makeatother

2.4.2 Cách sử dụng


\PrimeTree{<number>}

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

2.5 Phân tích ra thừa số nguyên tố (chia cột)


2.5.1 Khai báo trước \begin{document}

\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

2.5.2 Cách sử dụng


• Chỉ ra số nguyên tố thứ n (n < 50): \opprint{P<n>}
Muốn thay đổi số lớn hơn thì chỉnh tham số của lệnh getprime.

• Phân tích ra thừa số nguyên tố (dạng cột):

\PrimeColumn[operandstyle=\<màu>,intermediarystyle=\<màu>]{<number>}

2.5.3 Các ví dụ

\opprint{P0} \opprint{P3} \opprint{P10} \opprint{P49}

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

2.6 Phân tích ra thừa số nguyên tố (chỉ đưa ra đáp số)


2.6.1 Khai báo trước \begin{document}

\makeatletter

\newcount\factorize@n % the number to be factorized


\newcount\factorize@t % temporary
\newcount\factorize@p % a candidate factor
\newcount\factorize@c % counter of factors (total)
\newcount\factorize@w % counter of factors (power of given candidate)

% machinery for factorization


%
\def\FrimeAns#1{%
\factorize@begin{#1}%
\factorize@n=#1
\factorize@c=0
\factorize@p=2
\factorize@try%
\factorize@p=3
\factorize@try%
\factorize@p=5
\factorize@loop%
\ifnum\factorize@c>0

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%
}

% Stubs to be called at start, end, and when a factor is found


%
\def\factorize@begin#1{%
\noindent%
$#1 =%$
}
\def\factorize@end#1{%

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.2 Cách sử dụng


\PrimeAns{<number>}

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 LỆNH XLOP.STY

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.

3.1 Khai báo gói lệnh


Khai báo \usepackage{xlop} trước \begin{document}.
Trong một số trường hợp khác cần khai báo thêm \usepackage{pstricks}.

3.2 Phép cộng

Cú pháp: \opadd[<option>]{<number 1>}{number 2}

\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}

45,05 + 78,4 = 123,45

\opadd[carryadd=false,decimalsepsymbol={,},style=text]{-2.5}{-3.8}

−2,5 + −3,8 = −6,3

\opadd[carryadd=false,decimalsepsymbol={,},style=text,%
parenthesisnegative=all]{-2.5}{-3.8}

(−2,5) + (−3,8) = (−6,3)

\opadd[carryadd=false,decimalsepsymbol={,},style=text,%
parenthesisnegative=last]{-2.5}{-3.8}

−2,5 + (−3,8) = −6,3

3.3 Phép trừ

Cú pháp: opsub[<option>]{number 1}{number 2}

\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}

2.4 5 1.2 − 2.45 = −1.25



1.2
1.2 5

Trang 22
3.4. PHÉP NHÂN

3.4 Phép nhân

Cú pháp: \opmul[<option>]{number 1}{number 2}

\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
____
____
___
_ _,_ _ _

3.5 Phép chia

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Ố

3.6 Tìm ước chung lớn nhất (ƯCLN) của hai số

Cú pháp: \opgcd{<number 1>}{number 2}{d} \opprint{d}


Công dụng: Lệnh \opgcd{<number 1>}{number 2}{d} sẽ tìm ƯCLN của hai số
<number 1> và <number 2> rồi gán giá trị đó cho d. Lệnh \opprint{d} thực hiện việc
in ra giá trị của d.

$\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

3.7 Một số lệnh tính toán khác


3.7.1 Tính căn bậc hai của một số

Cú pháp: \opsqrt[<option>]{<number>}{x} \opprint{x}


Công dụng: Lệnh \opsqrt[<option>]{<number>}{x} sẽ tính căn bậc hai của <number>
theo <option> rồi lấy giá trị đó gán cho x. Lệnh \opprint{x} thực hiện việc in ra giá
trị của x.

$\sqrt{2} \approx \opsqrt{2}{x} \opprint{x}$



2 ≈ 1.4142135623
$\sqrt{2} \approx \opsqrt[maxdivstep=4]{2}{x} \opprint{x}$

2 ≈ 1.4142

3.7.2 Tính giá trị tuyệt đối của một số

Cú pháp: \opabs{<number>}{x} \opprint{x}

$|-25| = \opabs{-25}{x} \opprint{x}$

| − 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 ...

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
Chẳng hạn, khai báo \opset{decimalsepsymbol={,}} trước \begin{document}, khi đó
toàn bộ tài liệu sẽ có tùy chọn decimalsepsymbol={,}.

Trang 27
Chương 4

GÓI LỆNH POLYNOM.STY XỬ LÝ


CÁC VẤN ĐỀ VỀ ĐA THỨC

4.1 Khai báo gói lệnh


Khai báo \usepackage{polynom} trước \begin{document}.

4.2 Cộng, trừ, nhân, chia đa thức


Gói polynom chủ yếu thực hiện được các phép toán cộng, trừ, nhân, chia đối với đa thức
một biến. Đối với đa thức nhiều biến, việc tính toán vẫn còn rất nhiều sai sót.
Giải thích một số từ ngữ tiếng Anh:
• Polynomial: Đa thức.
• Add: Thêm vào (cộng).
• Subtract: Trừ.
• Multiply: Nhân.
• Divide: Chia.
• Greatest common divisor (gcd): Ước chung lớn nhất.

4.2.1 Cộng hai đa thức

\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

• Lệnh \polyadd\P{2x+1}{x+x^2} thực hiện việc cộng hai đa thức 2x + 1 và x + x2 ,


sau đó lấy kết quả và gán vào P.
!
• Lệnh \polyprint\P thực hiện việc in ra P.

28
4.2. CỘNG, TRỪ, NHÂN, CHIA ĐA THỨC

4.2.2 Trừ hai đa thức


\polysub\P{2x+1}{x+x^2} \polyprint\P

− x2 + x + 1

\polysub\P{x^3+x+1}{2x^2-x-2} \polyprint\P

x3 − 2x2 + 2x + 3

4.2.3 Nhân hai đa thức


\polymul\P{x+1}{x-1} \polyprint\P

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

2x5 − 2x4 + x3 + 4x2 − 7x + 2

4.2.4 Chia hai đa thức


4.2.4.1 Thực hiện đầy đủ các bước

\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

! Ngoài style=D còn có các kiểu style=A, style=B, style=C.

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

4.2.4.2 Thực hiện từng bước


Sử dụng tùy chọn stage=<value>

\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

4.2.4.3 Sử dụng tùy chọn div=<token> dành cho style=C

\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

4.4 Phân tích đa thức thành nhân tử


Cú pháp: \polyfactorize{<polynomial>}

\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/.

[2] Jean-Côme Charpentier, Xlop v0.26 User Manual, 2017.


[3] Carsten Heinz, Hendri Adriaens, The Polynom Package, 2017.

33

You might also like