Solve Linear Equations Using Gauss-Jordan in C

  • Thread starter Thread starter niteshadw
  • Start date Start date
  • Tags Tags
    Matrix
AI Thread Summary
The discussion focuses on using the Gauss-Jordan algorithm to solve a system of linear equations in C. Participants clarify the process of forming and reducing the augmented matrix, addressing initial confusion about blank spaces in the equations. Step-by-step reductions are shared, leading to a row-reduced form of the matrix. Ultimately, the correct solutions for the variables are confirmed as x1 = 3, x2 = -1, x3 = 0, and x4 = -2. The thread highlights collaboration in understanding and applying the Gauss-Jordan elimination method.
niteshadw
Messages
20
Reaction score
0
Use the Gauss-Jordan algorithm to find all solutions of the following system of linear equations in C:

x1 + x2 + x3 [] = 2
2x1 [] + 2x3 + 2x4 = 2
x1 + 2x2 + 2x3 [] = 1
2x1 + 2x2 [] + x4 = 2

[] signify a blank space in the equation. How do you even proceed to do this, I have never seen it. Any help would be appreciated. Thank you.
 
Physics news on Phys.org
In matrix-form, it looks like this:

\left( {\begin{array}{*{20}c}<br /> 1 &amp; 1 &amp; 1 &amp; 0 &amp; 2 \\<br /> 2 &amp; 0 &amp; 2 &amp; 2 &amp; 2 \\<br /> 1 &amp; 2 &amp; 2 &amp; 0 &amp; 1 \\<br /> 2 &amp; 2 &amp; 0 &amp; 1 &amp; 2 \\<br /> \end{array}} \right)

Do you know how Gaussian elimination works?
 
How about this:

\left(<br /> \begin{array}{cccc|c}1 &amp; 1 &amp; 1 &amp; 0 &amp; 2\\<br /> 2 &amp; 0 &amp; 2 &amp; 2 &amp; 2 \\<br /> 1 &amp; 2 &amp; 2 &amp; 0 &amp; 2 \\<br /> 2 &amp; 2 &amp; 0 &amp; 1 &amp; 1 <br /> \end{array}\right)<br />

That's the augumented matrix Niteshadw.

So, reduce it. Here, I'll do the first part. I'll multiply the top row by -2 and then add it to the second row yielding:

<br /> \left(<br /> \begin{array}{cccc|c}1 &amp; 1 &amp; 1 &amp; 0 &amp; 2 \\<br /> 0 &amp; -2 &amp; 0 &amp; 2 &amp; -2 \\<br /> 1 &amp; 2 &amp; 2 &amp; 0 &amp; 2 \\<br /> 2 &amp; 2 &amp; 0 &amp; 1 &amp; 1 <br /> \end{array}\right)<br />

Can you continue doing this until you get it to row-reduced form?
 
Last edited:
Typo! The first matrix in Saltydog's response should be
\left(\begin{array}{cccc|c}1 &amp; 1 &amp; 1 &amp; 0 &amp; 2\\ 2 &amp; 0 &amp; 2 &amp; 2 &amp; 2 \\ 1 &amp; 2 &amp; 2 &amp; 0 &amp; 1 \\ 2 &amp; 2 &amp; 0 &amp; 1 &amp; 2 \end{array}\right)

Except for separating out the "augmenting" part, that's just what TD said.
 
saltydog said:
How about this:

\left(<br /> \begin{array}{cccc|c}1 &amp; 1 &amp; 1 &amp; 0 &amp; 2\\<br /> 2 &amp; 0 &amp; 2 &amp; 2 &amp; 2 \\<br /> 1 &amp; 2 &amp; 2 &amp; 0 &amp; 2 \\<br /> 2 &amp; 2 &amp; 0 &amp; 1 &amp; 1 <br /> \end{array}\right)<br />

That's the augumented matrix Stunner.

So, reduce it. Here, I'll do the first part. I'll multiply the top row by -2 and then add it to the second row yielding:

<br /> \left(<br /> \begin{array}{cccc|c}1 &amp; 1 &amp; 1 &amp; 0 &amp; 2 \\<br /> 0 &amp; -2 &amp; 0 &amp; 2 &amp; -2 \\<br /> 1 &amp; 2 &amp; 2 &amp; 0 &amp; 2 \\<br /> 2 &amp; 2 &amp; 0 &amp; 1 &amp; 1 <br /> \end{array}\right)<br />

Can you continue doing this until you get it to row-reduced form?

Hmm..looks simple enough, just did not know what to do with those blank spots...Ok, I got this,

\left(<br /> \begin{array}{cccc|c}1 &amp; 0 &amp; 0 &amp; 0 &amp; 3\\<br /> 0 &amp; 1 &amp; 0 &amp; 0 &amp; -1 \\<br /> 0 &amp; 0 &amp; 1 &amp; 0 &amp; 0 \\<br /> 0 &amp; 0 &amp; 0 &amp; 1 &amp; -2 <br /> \end{array}\right)<br />

so um,
x_4 = -2x_4
x_3 = 0
x_2 = -x_2
x_1 = 3x_1

are those the solutions?
Thank you for the help thus far...
 
I think you row-reduced fine but the last column refers to the constants, not to an unknown. So the solution should be:

\left\{ \begin{array}{l}<br /> x_1 = 3 \\ <br /> x_2 = - 1 \\ <br /> x_3 = 0 \\ <br /> x_4 = - 2 \\ <br /> \end{array} \right
 
I multiplied the values first without the error limit. Got 19.38. rounded it off to 2 significant figures since the given data has 2 significant figures. So = 19. For error I used the above formula. It comes out about 1.48. Now my question is. Should I write the answer as 19±1.5 (rounding 1.48 to 2 significant figures) OR should I write it as 19±1. So in short, should the error have same number of significant figures as the mean value or should it have the same number of decimal places as...
Thread 'A cylinder connected to a hanging mass'
Let's declare that for the cylinder, mass = M = 10 kg Radius = R = 4 m For the wall and the floor, Friction coeff = ##\mu## = 0.5 For the hanging mass, mass = m = 11 kg First, we divide the force according to their respective plane (x and y thing, correct me if I'm wrong) and according to which, cylinder or the hanging mass, they're working on. Force on the hanging mass $$mg - T = ma$$ Force(Cylinder) on y $$N_f + f_w - Mg = 0$$ Force(Cylinder) on x $$T + f_f - N_w = Ma$$ There's also...

Similar threads

Back
Top