Math & ScienceSolution for a System of linear Equations

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
thenight
Posts: 5
Joined: Thu Apr 18, 2013 12:45 pm

Solution for a System of linear Equations

Post by thenight »

Hi!

I'm a beginner in LaTeX. I need some help to write LaTeX code for this:
linear-equation-system.png
linear-equation-system.png (16.04 KiB) Viewed 16448 times
Do I have to use {tabular} or are there any other ways to code this?

Thanks in advance for helping me out.
Last edited by localghost on Thu Apr 18, 2013 8:10 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Solution for a System of linear Equations

Post by localghost »

Show what you have tried so far in form of a self-contained and minimal example to give an adequate problem description.


Best regards and welcome to the board
Thorsten
thenight
Posts: 5
Joined: Thu Apr 18, 2013 12:45 pm

Solution for a System of linear Equations

Post by thenight »

So far the best I have come up is

Code: Select all

\begin{cases}
$y=2x-5$\\
$4x-2y-10=0$
\end{cases}
\begin{tabular}{l c r}
$2x-y-5=0$ & $|\cdot (-2)|$ & $ -4x+2x+10=0$\\
$4x-2y-10=0$ &$|\cdot 1|$ & $4x-2y-10=0$\\\hline
& & $0=0$
\end{tabular}
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Solution for a System of linear Equations

Post by Stefan Kottwitz »

Hi,

welcome to the board!

One tipp, a minimal example should be compilable, i.e. a complete small document beginning with \documentclass and ending with \end{document}. So readers can directly test it and help you.

If I would need to typeset this pretty complex diagram, I would
  • use an {array} environment for the whole thing, because of left alignment, the horizontal line, and math mode for the cells,
  • use an aligned environment of the amsmath package for small equation blocks,
  • use \left\{ and \right. for the big braces, I guess a cases environment is not needed here. The mathmode document explains more.
However, this structure is a bit unusual. Perhaps compare with good math books, and see if any book would use such setup. If you perhaps then would decide not to use tabular layout with horizontal and vertical lines cutting through math expressions, we would not need to contruct that layout.

Stefan
LaTeX.org admin
thenight
Posts: 5
Joined: Thu Apr 18, 2013 12:45 pm

Re: Solution for a System of linear Equations

Post by thenight »

Okay,
Thank you for the tips.
thenight
Posts: 5
Joined: Thu Apr 18, 2013 12:45 pm

Solution for a System of linear Equations

Post by thenight »

Hi!
I have still some problem with this code. It gives me some errors and and it is not quite the same I need.
Thanks in advance.

Code: Select all

\documentclass[a4paper,fleqn,12pt]{article}
\usepackage[english]{babel}
\usepackage{amsmath,amsfonts,amsthm}

\begin{document}
\[\left\lbrace \begin{array}{l}
y=2x-5\\
4x-2y-10=0
\end{array}\right. \Rightarrow\]

\[\begin{array}{lcr}
\Rightarrow \left\lbrace
\begin{align*}
2x-y-5=0\\
4x-2y-10=0
\end{align*}&
\begin{align*}
\left| \begin{array}{c}
\cdot (-2)\\\cdot 1 
\end{array} \right| 
\end{align*}&+
\begin{align*}
-4x+2y+10=0\\
4x-2y-10=0
\end{align*}
\\\cline{1-3}
&&$0=0$
\end{array} \]

\end{document}
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Solution for a System of linear Equations

Post by localghost »

As Stefan already remarked, this is a quite unusual way of writing such stuff. Nevertheless you can try something like this.

Code: Select all

\documentclass[12pt,a4paper,fleqn]{article}
\usepackage[T1]{fontenc}
\usepackage{amsmath,amsfonts,amsthm}
\usepackage{booktabs,multirow}

\begin{document}
  \[
    \left\lbrace
    \begin{aligned}
      y &= 2x-5\\
     4x-2y-10 &= 0
    \end{aligned}
    \right. \qquad\Rightarrow
  \]

  \[
    \begin{array}{@{}r@{\,}c@{\,}lcccccr@{\,}c@{\,}l@{}}
      2x-y-5 & = & 0 & & & \begin{array}{|c|}\cdot\,(-2)\end{array} & & \multirow{2}{*}{+} & -4x+2y+10 & = & 0 \\
      4x-2y-10 & = & 0 & & & \begin{array}{|c|}\cdot\,1\phantom{(-)}\end{array} & & & 4x-2y-10 & = & 0 \\ \midrule
      & & & & & & & & 0 & = & 0 \\
    \end{array}
  \]
\end{document}
I would typeset such things by the gauss package, thus apply the Gaussian elimination.


Best regards and welcome to the board
Thorsten
thenight
Posts: 5
Joined: Thu Apr 18, 2013 12:45 pm

Re: Solution for a System of linear Equations

Post by thenight »

Thank you for replying.
Post Reply