Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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??

share|improve this question
2  
Have you read the documentation for Solve ? –  image_doctor Nov 8 '12 at 15:58
1  
    
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
add comment

1 Answer

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.