Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

closed as off-topic by Louis, MarcoB, J. M. May 23 at 16:07

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Louis, MarcoB, J. M.
If this question can be reworded to fit the rules in the help center, please edit the 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
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

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