Math Manipulation
This is what LaTeX is famous for!
It's really easy to write basic equations in LATEX. Let's look at this example:
\begin{document}
Định lý Pythagorean \(x^2 + y^2 = z^2\) đã được chứng minh là sai với các số mũ khác 2. Điều đó có nghĩa là phương trình dưới đây vô nghiệm:
\[ x^n + y^n = z^n \]
\end{document}
In this example, mathematical expressions are described inside the delimeter \( \) or \[ \]. However, how it is displayed depends on the choice of delimeter.
Math mode
LATEX allows two writing modes for mathematical expressions: the inline math mode and display math mode.
inline math mode is used to write formulas that are part of a paragraph
display math mode is used to write expressions that are not part of a paragraph, and are therefore put on separate lines
Inline math mode
There are 3 delimeters than can be used to typeset the mathematical expression:
\(...\)$...$\begin{math}...\end{math}
It all works, but it's LATEXstandard to use \(...\) to express math. If you want to know why, head to this question.
Display math mode
In display math mode, mathematical expressions are displayed on a separate line. You can use these delimeters to typeset your math:
$$...$$\[...\]\begin{displaymath}...\end{displaymath}\begin{equation}...\end{equation}\begin{equation*}...\end{equation*}- only available when importamsmath
It's suggested to use \[...\] instead of $$...$$. You can read more about this here.
Let's have a look at this example:

Math Syntax in LATEX
In LATEX, numbers and letters are displayed without the need of any special syntax, numbers in math mode will be printed normally while letters will be printed in italics.
Subscripts and Superscripts
The use of superscripts and subscripts is very common in mathematical expressions involving exponents, indexes, and in some special operators.
Let's define an integral as an example:
The result is:

By convention, superscripts and subscripts in LATEX are created using the characters ^ and _ respectively. The command \limits changes the way the limits are displayed in the integral, if not present the limits would be next to the integral symbol instead of being on top and bottom:

Greek letters and Blackboard-bold letters
To summary, it just depends on the syntax to write these characters. Let's look at this example:

Every Greek letters can be written using a command. You can have a complete list of Greek characters here. In addition, you can also use \mathbb to display letters in blackboard-style. (\mathbb need to be put in inline math mode)
Brackets and Parentheses
Parentheses and brackets are very common in mathematical formulas. LATEXprovides a set of commands that provides you with brackets in different sizes and styles.
Parentheses
(x+y)
(x+y)
Brackets
[x+y]
[x+y]
Braces
\{x+y\}
{x+y}
Pipes
|x+y|
∣x+y∣
Double pipes
\|x+y\|
∥x+y∥
Let's take this equation for universal gravitation as an example:

By default, the size of the brackets are fixed, even in display math mode. In order for them to be dynamically resized, we can use the \left and \right command combine with the left/right brackets. Let's look at this example:

Thanks to the \left and \right command, we can create dynamically-resized pairs of brackets. However, even if you want to use only one bracket, both commands are mandatory. In order to solve this, we just need to put a dot after the command we want. Let's look at this exercise as an example:

Fractions and Binomials
In order to typeset binomial coefficients you need to use the command \binom from amsmath package:

Fractions, however, is more flexible. Its visual appearance will change depending on whether they appear in inline math mode, or typeset in display math mode. Let's look at this example:

As in the example, fraction is typeset using the \frac command with the syntax \frac{numerator}{denominator}
However, if you want to write text as numerator or denominator, you can not typeset it normally, but you need to use the \text command from amsmath, which is used to prevent LATEX from typesetting the text as regular mathematical content. Here is the example:

Fractions can be nested, however, if they are deeply nested, may not produce ideal results. You can use \cfrac from amsmath to solve this.
Special functions
As shown in the previous part of Fractions, if you type normal characters in math mode, it will become italics. As a result, when it comes to special functions like sine, cosine, tangent, you need to use a command to properly typeset them. Let's look at this example:

You can find a lot of commands for different operations here.
Calculus Notation
Square root and more
In order to typeset square root, you can use the following command: \sqrt[index]{radicand}. Here is an example:

Limits
Limits can be displayed differently between inline and display math mode. Let's look at this example:

Regarding the → symbol, you can also use \to from amsmath.
Integrals
Integral expression can be typeset using the \int_{lower}^{upper} command. And in order to get the final result by calculating with the upper and lower limit, you can use \vert. Like limits, its display can be different between display math mode and inline math mode.

The default length of \vert is pretty short, you can enhance that by using \big or \bigg.
You can also typeset double integrals, triple integrals using \iint, \iiint, respectively.

It's also noteworthy that you can change the place of the integral limits using the command \limits_{lower limit}^{upper_limit}. This is also applied in inline math mode. Let's look at this example:

If you notice, you may see the dx notation placing too close to the equation. Therefore, I will introduce a set of command to create small "space" in your mathematical notion, which will beautify your math.

This can also be used in text environment, only integrals.
Sums and Products (Sigma notation and Pi notation)
Like integral, Sigma notation and Pi notation use a similar syntax: \sum_{lower}^{upper} and \prod_{lower}^{upper}. Both of them may be displayed differently when in display math mode or inline math mode. Here is the example:

Vectors
Vectors are a widely explored subject within Algebra. Therefore, in order to write this in LATEX, you need to import the esvect package (this package must be manually installed). After that, you can use the command \vv to create vector notations.

However, in some situations, you may have multiple r vectors, and you may want to number them.

When it comes to calculating the dot product of 2 vectors, you may need a pair of angle brackets. The correct way to write it is \langle and \rangle ("l" and "r" are left and right, respectively).

Last updated