===== Introduction to LaTeX for Mathematical Expressions =====
The goal of the lesson is to become familiar with LaTeX, specifically for the purpose of writing mathematical expressions.
==== 1. Introduction to LaTeX ====
**What is LaTeX?**
LaTeX is a high-quality typesetting system, primarily used for technical and scientific documents. It is particularly powerful for formatting complex mathematical equations and formulas, making it a preferred choice in academia and research.
**What are the advantages of LaTeX?**
* **Handling Complex Documents**: It is ideal for mathematical formulas, citations, and cross-referencing in technical writing.
* **Consistent Layout**: Automatically ensures a uniform, professional design by separating content from formatting.
* **Scalability**: Suitable for large projects, allowing version control and modular structure.
* **Longevity**: LaTeX's plain text format ensures long-term compatibility and durability.
* **Academic Preference**: Often required in academic and scientific publishing.
**Getting Started:**
- **Overleaf**: We will use Overleaf, a free online LaTeX editor, which allows you to write and compile LaTeX documents directly in your browser.
- Sign up at [[https://www.overleaf.com/|Overleaf]].
- Overleaf offers collaborative features, version control, and a vast library of LaTeX templates.
**Basic Document Structure:**
\documentclass{article} % Specifies the document class (article, report, book, etc.)
\begin{document} % Begins the content of the document
% Your content goes here
\end{document} % Ends the content of the document
- **\documentclass{article}**: Defines the overall layout and style of the document.
- **\begin{document}** and **\end{document}**: Everything between these commands will be included in the output document.
==== 2. Writing Basic Mathematical Expressions ====
=== Inline vs. Display Math ===
- **Inline Math**: For mathematical expressions that appear within a line of text, use ''$...$''.
- E.g. $E = mc^2$ is written as ''$E = mc^2$'' in LaTeX.
- **Display Math**: For standalone equations, use ''$$...$$''.
- E.g. To display $$E = mc^2$$ on its own line, use ''$$E = mc^2$$''.
== Example ==
\documentclass{article}
\begin{document}
The equation $E = mc^2$ is famous in physics. It is so important that we can highlight $$E = mc^2$$ by putting it to a separate line.
\end{document}
This code will became:
{{:tanszek:oktatas:techcomm:pasted:20240902-141219.png}}
=== Basic Mathematical Symbols ===
- **Exponents (superscripts)**: Use ''^'' for superscripts.
- E.g. $x^2$ is written as ''$x^2$''.
- **Subscripts**: Use `_` for subscripts.
- E.g. $a_1$ is written as ''$a_1$''.
- **Fractions**: Use `\frac{numerator}{denominator}`.
- E.g. $\frac{a}{b}$ is written as ''$\frac{a}{b}$''.
== Examples ==
\documentclass{article}
\begin{document}
% Exponent and subscript
The formula for the area of a circle is $A = \pi r^2$.
% Fraction
The equation $\frac{a}{b} = c$ represents a fraction.
% Combined
The equation for kinetic energy is $K = \frac{1}{2}mv^2$.
\end{document}
This code will become:
{{:tanszek:oktatas:techcomm:pasted:20240902-141644.png}}
==== 3. Special Mathematical Symbols in LaTeX ====
LaTeX provides a variety of symbols to accurately represent mathematical expressions.
- The **plus-minus symbol** is used to denote values that can be either positive or negative and is written as ''\pm'', which displays as $\pm$.
- To express **square roots**, the square root symbol is used, which is written as ''\sqrt{...}''. For example, ''\sqrt{2}'' produces $\sqrt{2}$
- For **higher-order roots**, such as a cubic root, the syntax is ''\sqrt[3]{...}'', yielding $\sqrt[3]{9}$
- Another common symbol is the **infinity symbol**, represented as ''\infty'', and it is displayed as $\infty$
- For **greater than or equal to** and **less than or equal to** symbols, use ''\geq'' and ''\leq'', which render as $\geq$ and $\leq$, respectively.
=== Summation ===
The general form of summation in LaTeX is written using the ''\sum'' command. For example, the sum from $i=1$ to $n$ is given by:
$$\sum_{i=1}^{n} i^2$$
This expression sums the squares of integers from 1 to $n$.
=== Derivative ===
The derivative of a function $f(x)$ with respect to $x$ is represented in LaTeX using the ''\frac'' command for fractions. The notation for the derivative of $f(x)$ with respect to $x$ is:
$$\frac{d}{dx} f(x)$$
This gives the rate of change of $f(x)$ with respect to $x$.
=== Partial Derivative ===
For partial derivatives, the ''\partial'' command is used. The partial derivative of a function $f(x, y)$ with respect to $x$ is:
$$\frac{\partial}{\partial x} f(x, y)$$
This expression gives the partial derivative of $f$ with respect to $x$, holding other variables constant.
=== Partial Integration ===
Partial integration, also known as integration by parts, can be expressed in LaTeX. For the specific example of integrating $x \sin(x)$ from $a$ to $b$, the integral is written as:
\[
\int_{a}^{b} x \sin(x) \, dx
\]
This represents the definite integral of $x \sin(x)$ with respect to $x$ from $a$ to $b$.
==== 4. Aligning Equations ====
=== Align Environment ===
- The `align` environment is used to align multiple equations. Each line of the equation is aligned using the `&` symbol, typically before the equal sign or any other operator.
- Use `\\` to separate lines.
== Example ==
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
3x + 2y + 0z &= 6 \\
4x - y &= 25
\end{align}
\end{document}
This code will become:
{{:tanszek:oktatas:techcomm:pasted:20240902-142323.png}}
**Explanation:**
- **\usepackage{amsmath}**: The `amsmath` package is required for advanced mathematical typesetting features, including the `align` environment.
- **&**: This symbol is used to align equations at the specified point, usually before an operator like `=`.
**Tips:**
- You can label equations using the ''\label{}'' command and refer to them later with ''\ref{}''.
- Example:
\begin{equation} \label{eq:quadratic}
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
\end{equation}
To refer to this equation later, use ''Equation \ref{eq:quadratic}''.
==== 5. Exercise ====
Reproduce the following mathematical proof in LaTeX. Use inline and display math, as well as basic and special symbols! Save the result in PDF format!
{{:tanszek:oktatas:techcomm:pasted:20240902-144955.png}}
Raw text:
Proof: √2 is Irrational
Assume, for contradiction, that 2 is rational. Then it can be expressed as a fraction a/b, where a and b are coprime integers.
Then:
HERE COMES AN EQUATION.
Squaring both sides:
HERE COMES AN EQUATION.
Multiplying both sides by b2:
HERE COMES AN EQUATION.
This implies that a2 is even, so a must also be even. Let a = 2k for some integer k.
Substituting into the equation:
HERE COMES AN EQUATION.
Dividing by 2:
HERE COMES AN EQUATION.
This implies that b2 is even, so b must also be even.
But if both a and b are even, they are not coprime, which contradicts our original assumption. Therefore, 2 must be irrational.