math_examples.tex

Download
latex 509 lines 13.3 KB
  1% ============================================================================
  2% math_examples.tex - Basic Mathematical Typesetting in LaTeX
  3% ============================================================================
  4% This document demonstrates fundamental mathematical typesetting features
  5% in LaTeX, including inline and display mathematics, fractions, exponents,
  6% Greek letters, and common mathematical operators.
  7%
  8% Compilation:
  9%   pdflatex math_examples.tex
 10% ============================================================================
 11
 12\documentclass[11pt]{article}
 13
 14% Essential math packages
 15\usepackage{amsmath}    % Enhanced math environments
 16\usepackage{amssymb}    % Additional math symbols
 17\usepackage{amsfonts}   % Mathematical fonts
 18
 19% Page layout
 20\usepackage[margin=1in]{geometry}
 21
 22% Better font encoding
 23\usepackage[T1]{fontenc}
 24\usepackage{lmodern}
 25
 26% Color for highlighting
 27\usepackage{xcolor}
 28
 29% Hyperlinks
 30\usepackage{hyperref}
 31\hypersetup{colorlinks=true, linkcolor=blue}
 32
 33\title{Basic Mathematical Typesetting in \LaTeX}
 34\author{Mathematics Department}
 35\date{\today}
 36
 37\begin{document}
 38
 39\maketitle
 40
 41\tableofcontents
 42
 43\section{Introduction}
 44
 45\LaTeX{} excels at typesetting mathematical content. This document demonstrates
 46basic mathematical features that every \LaTeX{} user should know.
 47
 48% ============================================================================
 49\section{Inline vs. Display Mathematics}
 50% ============================================================================
 51
 52\subsection{Inline Mathematics}
 53
 54Inline mathematics is embedded within text using single dollar signs or
 55\verb|\(...\)|. For example, the quadratic formula is $x = \frac{-b \pm
 56\sqrt{b^2-4ac}}{2a}$ and the famous equation $E=mc^2$ shows mass-energy
 57equivalence.
 58
 59The Pythagorean theorem states that $a^2 + b^2 = c^2$ for a right triangle.
 60We can also write inequalities like $0 < x \leq 10$ or $-\infty < y < \infty$.
 61
 62\subsection{Display Mathematics}
 63
 64Display mathematics is set apart from text, centered and on its own line.
 65Use double dollar signs \verb|$$...$$| or \verb|\[...\]| for unnumbered
 66equations:
 67
 68\[
 69\int_0^\infty e^{-x^2} \, dx = \frac{\sqrt{\pi}}{2}
 70\]
 71
 72For numbered equations that can be referenced, use the \texttt{equation}
 73environment (see Section~\ref{sec:numbering} for details).
 74
 75% ============================================================================
 76\section{Fractions and Binomial Coefficients}
 77% ============================================================================
 78
 79\subsection{Fractions}
 80
 81The \verb|\frac{numerator}{denominator}| command creates fractions:
 82
 83\[
 84\frac{a}{b}, \quad \frac{x^2 + y^2}{z^2}, \quad
 85\frac{1}{1 + \frac{1}{1 + \frac{1}{x}}}
 86\]
 87
 88In inline mode, fractions appear smaller: $\frac{1}{2}$ or $\frac{a+b}{c+d}$.
 89For better inline appearance, use \verb|\tfrac| (text-style fraction) or
 90\verb|/|: compare $\frac{1}{2}$ vs. $\tfrac{1}{2}$ vs. $1/2$.
 91
 92For display-style fractions in text, use \verb|\dfrac|: $\dfrac{a}{b}$.
 93
 94\subsection{Binomial Coefficients}
 95
 96Binomial coefficients use \verb|\binom{n}{k}|:
 97
 98\[
 99\binom{n}{k} = \frac{n!}{k!(n-k)!}, \quad
100\binom{5}{2} = 10, \quad
101\sum_{k=0}^n \binom{n}{k} = 2^n
102\]
103
104% ============================================================================
105\section{Exponents and Subscripts}
106% ============================================================================
107
108\subsection{Superscripts (Exponents)}
109
110Use the caret \verb|^| for superscripts:
111
112\[
113x^2, \quad y^{10}, \quad e^{i\pi}, \quad 2^{2^{2^2}} = 2^{16} = 65536
114\]
115
116For multiple characters in the exponent, use braces: $x^{n+1}$ not $x^n+1$.
117
118\subsection{Subscripts}
119
120Use underscore \verb|_| for subscripts:
121
122\[
123x_1, \quad a_{ij}, \quad \sum_{i=1}^n x_i, \quad
124\lim_{x \to \infty} f(x)
125\]
126
127\subsection{Combining Subscripts and Superscripts}
128
129You can combine both (order doesn't matter):
130
131\[
132x_i^2, \quad x^2_i, \quad \sum_{i=1}^{n} x_i^2, \quad
133{}_nP_r = \frac{n!}{(n-r)!}
134\]
135
136% ============================================================================
137\section{Greek Letters}
138% ============================================================================
139
140\subsection{Lowercase Greek Letters}
141
142Greek letters are fundamental in mathematics. Use backslash followed by the
143letter name:
144
145\[
146\alpha, \beta, \gamma, \delta, \epsilon, \varepsilon, \zeta, \eta, \theta,
147\vartheta, \iota, \kappa, \lambda, \mu, \nu, \xi, \pi, \varpi, \rho, \varrho,
148\sigma, \varsigma, \tau, \upsilon, \phi, \varphi, \chi, \psi, \omega
149\]
150
151Note the variant forms: $\epsilon$ vs. $\varepsilon$, $\theta$ vs. $\vartheta$,
152$\phi$ vs. $\varphi$, $\pi$ vs. $\varpi$, $\rho$ vs. $\varrho$,
153$\sigma$ vs. $\varsigma$.
154
155\subsection{Uppercase Greek Letters}
156
157\[
158\Gamma, \Delta, \Theta, \Lambda, \Xi, \Pi, \Sigma, \Upsilon, \Phi, \Psi, \Omega
159\]
160
161Note: Some Greek letters like $A, B, E, Z, H, I, K, M, N, O, P, T, X$ are
162identical to Latin letters and don't have special commands.
163
164% ============================================================================
165\section{Roots and Radicals}
166% ============================================================================
167
168Square roots use \verb|\sqrt|, and nth roots use \verb|\sqrt[n]|:
169
170\[
171\sqrt{2}, \quad \sqrt{x^2 + y^2}, \quad \sqrt[3]{27} = 3, \quad
172\sqrt[n]{x^n} = x, \quad \sqrt{1 + \sqrt{1 + \sqrt{1 + \cdots}}}
173\]
174
175% ============================================================================
176\section{Sums, Products, and Limits}
177% ============================================================================
178
179\subsection{Summation}
180
181The \verb|\sum| command creates summation notation:
182
183\[
184\sum_{i=1}^n i = \frac{n(n+1)}{2}, \quad
185\sum_{i=0}^\infty \frac{1}{2^i} = 2, \quad
186\sum_{k=0}^n \binom{n}{k} x^k y^{n-k} = (x+y)^n
187\]
188
189In inline mode, limits appear beside the symbol: $\sum_{i=1}^n x_i$. To force
190display-style limits in inline mode, use \verb|\limits|: $\sum\limits_{i=1}^n x_i$.
191
192\subsection{Products}
193
194The \verb|\prod| command creates product notation:
195
196\[
197\prod_{i=1}^n i = n!, \quad
198\prod_{i=1}^n x_i, \quad
199\prod_{p \text{ prime}} \left(1 - \frac{1}{p^2}\right) = \frac{6}{\pi^2}
200\]
201
202\subsection{Limits}
203
204The \verb|\lim| command creates limit notation:
205
206\[
207\lim_{x \to 0} \frac{\sin x}{x} = 1, \quad
208\lim_{n \to \infty} \left(1 + \frac{1}{n}\right)^n = e, \quad
209\lim_{x \to a^+} f(x), \quad \lim_{x \to a^-} f(x)
210\]
211
212Other limit-like operators: $\limsup$, $\liminf$, $\sup$, $\inf$, $\max$, $\min$.
213
214% ============================================================================
215\section{Integrals}
216% ============================================================================
217
218\subsection{Single Integrals}
219
220The \verb|\int| command creates integral signs:
221
222\[
223\int f(x) \, dx, \quad
224\int_0^1 x^2 \, dx = \frac{1}{3}, \quad
225\int_{-\infty}^{\infty} e^{-x^2} \, dx = \sqrt{\pi}
226\]
227
228Note the use of \verb|\,| for a thin space before $dx$.
229
230\subsection{Multiple Integrals}
231
232Multiple integrals use \verb|\iint|, \verb|\iiint|, etc.:
233
234\[
235\iint_D f(x,y) \, dA, \quad
236\iiint_V f(x,y,z) \, dV, \quad
237\oint_C \mathbf{F} \cdot d\mathbf{r}
238\]
239
240The \verb|\oint| command creates a closed path integral symbol.
241
242\subsection{Definite Integrals with Evaluation Brackets}
243
244\[
245\left. \frac{x^3}{3} \right|_0^1 = \frac{1}{3} - 0 = \frac{1}{3}
246\]
247
248% ============================================================================
249\section{Common Mathematical Functions}
250% ============================================================================
251
252Many common functions have predefined commands that format them correctly
253(upright, with proper spacing):
254
255\[
256\sin x, \cos x, \tan x, \sec x, \csc x, \cot x
257\]
258
259\[
260\arcsin x, \arccos x, \arctan x, \sinh x, \cosh x, \tanh x
261\]
262
263\[
264\log x, \ln x, \lg x, \exp x
265\]
266
267\[
268\det A, \dim V, \ker f, \deg p, \gcd(a,b), \lcm(a,b)
269\]
270
271Compare $\sin x$ (correct, upright) with $sin x$ (incorrect, italicized as
272separate variables).
273
274% ============================================================================
275\section{Brackets and Delimiters}
276% ============================================================================
277
278\subsection{Manual Sizing}
279
280Parentheses, brackets, and braces can be sized manually:
281
282\[
283( ), \quad [ ], \quad \{ \}, \quad | |, \quad \| \|, \quad \langle \rangle
284\]
285
286Manual sizing with \verb|\big|, \verb|\Big|, \verb|\bigg|, \verb|\Bigg|:
287
288\[
289( \big( \Big( \bigg( \Bigg(
290\]
291
292\subsection{Automatic Sizing}
293
294Use \verb|\left| and \verb|\right| for automatic delimiter sizing:
295
296\[
297\left( \frac{x^2}{y^3} \right), \quad
298\left[ \sum_{i=1}^n x_i \right]^2, \quad
299\left\{ x \in \mathbb{R} : x^2 < 1 \right\}
300\]
301
302\[
303\left| \frac{a}{b} \right|, \quad
304\left\| \mathbf{v} \right\|, \quad
305\left\langle u, v \right\rangle
306\]
307
308Every \verb|\left| must have a matching \verb|\right|. Use \verb|\right.| for
309an invisible delimiter:
310
311\[
312\left. \frac{df}{dx} \right|_{x=0}
313\]
314
315% ============================================================================
316\section{Matrices and Vectors}
317% ============================================================================
318
319Matrices use the \texttt{matrix} environment (or variants with delimiters):
320
321\[
322\begin{matrix}
323a & b \\
324c & d
325\end{matrix}, \quad
326\begin{pmatrix}
327a & b \\
328c & d
329\end{pmatrix}, \quad
330\begin{bmatrix}
331a & b \\
332c & d
333\end{bmatrix}, \quad
334\begin{vmatrix}
335a & b \\
336c & d
337\end{vmatrix}
338\]
339
340Larger example:
341
342\[
343A = \begin{bmatrix}
3441 & 2 & 3 \\
3454 & 5 & 6 \\
3467 & 8 & 9
347\end{bmatrix}, \quad
348\mathbf{v} = \begin{pmatrix}
349x \\ y \\ z
350\end{pmatrix}
351\]
352
353% ============================================================================
354\section{Accents and Decorations}
355% ============================================================================
356
357Various accents and decorations are available:
358
359\[
360\hat{a}, \quad \bar{x}, \quad \tilde{n}, \quad \vec{v}, \quad \dot{x}, \quad
361\ddot{y}, \quad \acute{a}, \quad \grave{a}, \quad \check{a}, \quad \breve{a}
362\]
363
364Wide accents for longer expressions:
365
366\[
367\widehat{xyz}, \quad \widetilde{abc}, \quad \overline{a+b+c}, \quad
368\underline{x+y}
369\]
370
371Arrows above and below:
372
373\[
374\overrightarrow{AB}, \quad \overleftarrow{BA}, \quad
375\overbrace{a + b + c}^{\text{sum}}, \quad
376\underbrace{x + y + z}_{\text{variables}}
377\]
378
379% ============================================================================
380\section{Special Symbols and Relations}
381% ============================================================================
382
383\subsection{Binary Relations}
384
385\[
386<, \leq, \ll, \quad >, \geq, \gg, \quad =, \neq, \equiv, \approx, \sim,
387\simeq, \cong
388\]
389
390\[
391\in, \notin, \ni, \quad \subset, \subseteq, \supset, \supseteq, \quad
392\cup, \cap, \setminus
393\]
394
395\[
396\parallel, \perp, \quad \vdash, \models, \quad \propto, \quad \asymp
397\]
398
399\subsection{Binary Operators}
400
401\[
402+, -, \times, \div, \pm, \mp, \cdot, *, \circ, \bullet, \oplus, \ominus,
403\otimes, \odot
404\]
405
406\[
407\wedge, \vee, \quad \cap, \cup, \quad \sqcap, \sqcup
408\]
409
410\subsection{Arrows}
411
412\[
413\leftarrow, \rightarrow, \leftrightarrow, \quad
414\Leftarrow, \Rightarrow, \Leftrightarrow
415\]
416
417\[
418\uparrow, \downarrow, \updownarrow, \quad
419\nearrow, \searrow, \swarrow, \nwarrow
420\]
421
422\[
423\longleftarrow, \longrightarrow, \implies, \iff, \mapsto
424\]
425
426\subsection{Miscellaneous Symbols}
427
428\[
429\infty, \quad \nabla, \quad \partial, \quad \forall, \quad \exists, \quad
430\nexists, \quad \emptyset, \quad \varnothing, \quad \prime, \quad \hbar
431\]
432
433% ============================================================================
434\section{Number Sets and Special Fonts}
435% ============================================================================
436
437Standard number sets use blackboard bold (\verb|\mathbb|):
438
439\[
440\mathbb{N}, \quad \mathbb{Z}, \quad \mathbb{Q}, \quad \mathbb{R}, \quad
441\mathbb{C}, \quad \mathbb{H}
442\]
443
444Calligraphic letters (\verb|\mathcal|):
445
446\[
447\mathcal{A}, \mathcal{B}, \mathcal{C}, \mathcal{L}, \mathcal{O}, \mathcal{P}
448\]
449
450Script letters (\verb|\mathscr|, requires \texttt{mathrsfs} package):
451% \[
452% \mathscr{A}, \mathscr{B}, \mathscr{C}, \mathscr{L}
453% \]
454
455Fraktur letters (\verb|\mathfrak|):
456
457\[
458\mathfrak{A}, \mathfrak{B}, \mathfrak{C}, \mathfrak{g}, \mathfrak{h}
459\]
460
461% ============================================================================
462\section{Spacing in Math Mode}
463% ============================================================================
464
465\LaTeX{} handles most spacing automatically, but manual spacing is sometimes
466needed:
467
468\begin{itemize}
469    \item \verb|\,| -- thin space: $a\,b$
470    \item \verb|\:| -- medium space: $a\:b$
471    \item \verb|\;| -- thick space: $a\;b$
472    \item \verb|\quad| -- 1em space: $a\quad b$
473    \item \verb|\qquad| -- 2em space: $a\qquad b$
474    \item \verb|\!| -- negative thin space: $\int\!\!\!\int$ vs $\int\int$
475\end{itemize}
476
477Example uses:
478\[
479f(x) \, dx \quad \text{(thin space before differential)}
480\]
481\[
482\text{if } x > 0 \text{ then } y = x^2 \quad \text{(text mode for words)}
483\]
484
485% ============================================================================
486\section{Text in Math Mode}
487\label{sec:numbering}
488% ============================================================================
489
490To include normal text within math mode, use \verb|\text{...}|:
491
492\[
493f(x) = \begin{cases}
494x^2 & \text{if } x \geq 0 \\
495-x^2 & \text{if } x < 0
496\end{cases}
497\]
498
499Compare: $f(x) = x^2 if x > 0$ (wrong) vs. $f(x) = x^2 \text{ if } x > 0$ (correct).
500
501\end{document}
502
503% ============================================================================
504% COMPILATION TIP
505% ============================================================================
506% Compile with: pdflatex math_examples.tex
507% For best results, compile twice to resolve cross-references.
508% ============================================================================