How to Solve Equations and Improve Alignment in Latex Math?

In summary: Even better, to get a superscript in $\LaTeX$, use the caret: `^` and the next character will be the superscript, as in $x^3$.$\begin{align}r^2+x^{2}&=(x + 5)^2 + (y - 3)^2\\r^2&=(x - 1)^2 + (y + 1)^2\\r^2&=(x - 0)^2 + (y + 2)^2.\end{align}$Hi, I'm new to $\LaTeX$ and I'm having trouble figuring out how to make the equations in the code below line up at the equals signs. I've tried using
  • #1
Casio1
86
0
$y=2x+1$

$y=2x^2+3x+5$

$ a+3b=1$
$2a - b=1$

Multiply through by 3

$6a - 3b = 3$

Subtract equation (3) from (1)

$6a - 3b = 3$
$ a + 3b = 1$
$7a - 0b = 4$

a =$\frac{4}{7}$

Just learning latex on here and trying to understand how I can keep everything in line, which seems difficult with some parts above, is there something I am missing out?

Please advise

Kind regards

Casio
 
Physics news on Phys.org
  • #2
Casio said:
Just learning latex on here and trying to understand how I can keep everything in line, which seems difficult with some parts above, is there something I am missing out?
What do you mean by difficulties of keeping everything in line? You should include the complete formula between the dollar signs, i.e., write $a=\frac{4}{7}$ instead of a =$\frac{4}{7}$. Also, from the typography viewpoint, it is arguably better to write fractions in inline formulas and in sub- and superscripts using a slash instead of \frac: \(4/7\) instead of \(\frac{4}{7}\). The command \frac is convenient for large display formulas (i.e., formulas that take their own line). However, this remark is probably more appropriate for fine book typesetting rather than online forums.
 
  • #3
Casio said:
$y=2x+1$

$y=2x^2+3x+5$

$ a+3b=1$
$2a - b=1$

Multiply through by 3

$6a - 3b = 3$

Subtract equation (3) from (1)

$6a - 3b = 3$
$ a + 3b = 1$
$7a - 0b = 4$

a =$\frac{4}{7}$

Just learning latex on here and trying to understand how I can keep everything in line, which seems difficult with some parts above, is there something I am missing out?

Please advise

Kind regards

Casio

To add to Evgeny.Makarov's comments, you can use the align environment (among many, many possibilities in $\LaTeX$) to align equations by the equals sign. For example, the code

Code:
\begin{align*}
a&=x+y\\
b&=x-y
\end{align*}

produces

\begin{align*}
a&=x+y\\
b&=x-y
\end{align*}
 
  • #4
$\begin{align}r^2=(x + 5)^2 + (y - 3)^2\end{align}$
$\begin{align}r^2=(x - 1)^2 + (y + 1)^2\end{align}$
$\begin{align}r^2=(x - 0)^2 + (y + 2)^2\end{align}$

${2}/{3} + {4}/{6}=$

How is this?

Better
 
  • #5
Casio said:
$\begin{align}r^2=(x + 5)^2 + (y - 3)^2\end{align}$
$\begin{align}r^2=(x - 1)^2 + (y + 1)^2\end{align}$
$\begin{align}r^2=(x - 0)^2 + (y + 2)^2\end{align}$

${2}/{3} + {4}/{6}=$

How is this?

Better

It is better, but only by accident. There are three things you could do to improve this code.

1. Use only one align environment.
2. Use ampersands to control how things are aligned.
3. Leave off the dollar signs. The align environment is automatically math mode.

For example, suppose you wanted to type these:

Code:
$\begin{align}r^2+x^{2}=(x + 5)^2 + (y - 3)^2\end{align}$
$\begin{align}r^2=(x - 1)^2 + (y + 1)^2\end{align}$
$\begin{align}r^2=(x - 0)^2 + (y + 2)^2\end{align}$

produces

$\begin{align}r^2+x^{2}=(x + 5)^2 + (y - 3)^2\end{align}$
$\begin{align}r^2=(x - 1)^2 + (y + 1)^2\end{align}$
$\begin{align}r^2=(x - 0)^2 + (y + 2)^2\end{align}$

Not aligned the way we want!

Try this code:

Code:
\begin{align}r^2+x^{2}&=(x + 5)^2 + (y - 3)^2\\
r^2&=(x - 1)^2 + (y + 1)^2\\
r^2&=(x - 0)^2 + (y + 2)^2\end{align}

producing

\begin{align}r^2+x^{2}&=(x + 5)^2 + (y - 3)^2\\
r^2&=(x - 1)^2 + (y + 1)^2\\
r^2&=(x - 0)^2 + (y + 2)^2.\end{align}

Much better. Notice the double backslashes at the end of each line marking where the code should begin the next line.

Incidentally: as a defensive $\LaTeX$ programming habit, I always put curly braces around exponents and subscripts, even if it's only one character. That way, if I want to insert another character in the exponent or subscript later, I won't wonder why I get this sort of thing: $x^45$ instead of $x^{45}$.
 

Related to How to Solve Equations and Improve Alignment in Latex Math?

What is Latex Math?

Latex Math is a type-setting language used for writing mathematical equations and expressions. It is commonly used in scientific and academic fields for its ability to create complex equations with precision and clarity.

How do I use Latex Math to solve equations?

To use Latex Math to solve equations, you will need to learn the syntax and commands for writing equations. Once you have a basic understanding of the language, you can use it in a document editor or online tool to input your equations and receive the solutions.

What are the advantages of using Latex Math for solving equations?

Some advantages of using Latex Math for solving equations include its ability to handle complex equations and expressions, its precision and clarity in displaying equations, and its compatibility with a variety of document editors and online tools.

Are there any resources available to help me learn Latex Math?

Yes, there are many resources available to help you learn Latex Math, such as online tutorials, forums, and user guides. You can also find books and online courses specifically focused on using Latex Math for solving equations.

Can Latex Math be used for solving equations in any field of science?

Yes, Latex Math can be used for solving equations in any field of science, including physics, chemistry, biology, and mathematics. It is a versatile tool that can handle equations from various disciplines with ease.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
3K
  • Precalculus Mathematics Homework Help
Replies
6
Views
945
  • MATLAB, Maple, Mathematica, LaTeX
Replies
11
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
322
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • Precalculus Mathematics Homework Help
Replies
5
Views
2K
  • Precalculus Mathematics Homework Help
Replies
4
Views
657
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • Precalculus Mathematics Homework Help
Replies
3
Views
1K
Back
Top