# Solving linear equation

I want to solve following linear equations:

\begin{align*} 3 x - y &= 0\\ y + 2 z &= -1\\ x + y + z &= 3 \end{align*}

The output will be {x == 7/5, y == 21/5, z == -(13/5)}

I don't know the way of solve this. What function can be used. How can I solve this? Also it will be very thankful if you let me know the ways as many as possible.

Also especially, is there any specific way that using 'LU decomposition' to solve this equation??

-
Have you read the documentation for Solve ? – image_doctor Nov 8 '12 at 15:58
Mathematica has good documentation that you can find through the menu 'Help-> Documentation center' and you can also google like google.com/search?q=mathematica+lu+decomposition and google.com/search?q=mathematica+solve+linear+system – ssch Nov 8 '12 at 17:41

Solve[{3 x - y == 0, y + 2 z == -1, x + y + z == 3}, {x, y, z}]
{{x -> 7/5, y -> 21/5, z -> -13/5}}

LinearSolve[{{3, -1, 0}, {0, 1, 2}, {1, 1, 1}}, {0, -1, 3}]
{7/5, 21/5, -13/5}

RowReduce[{{3, -1, 0, 0}, {0, 1, 2, -1}, {1, 1, 1, 3}}][[All, -1]]
{7/5, 21/5, -13/5}

lu = LUDecomposition[{{3, -1, 0}, {0, 1, 2}, {1, 1, 1}}];
LUBackSubstitution[lu, {0, -1, 3}]
{7/5, 21/5, -13/5}


I'm sure there are other ways. See the docs for more info on functions you're unfamiliar with.

-