Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Gaussian elimination methods' topicStudent Support Forum > General > "Gaussian elimination methods"

< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic
Author Comment/Response
Bill Simpson
09/07/12 9:37pm

From In[11]:=
B={{1.1161, 0.1254, 0.1397, 0.149, 1.5471},
{0.1582, 1.1675, 0.1768, 0.1871, 1.4471},
{0.1968, 0.2071, 1.2168, 0.2271, 1.7471},
{0.2368, 0.2471, 0.2568, 1.2671, 1.8471})

In[12]:=(*We must process all four columns*)
For[column=1,column≤4,column++,
(*Find the pivot row*)
(*Begin by assuming the first row is the pivot row*)
pivotrow=1;
For[row=2,row≤4,row++,
If[B[[row,column]]>B[[pivotrow,column]],
(*element is larger, revise pivot row assumption*)
pivotrow=row]
];
(*Now we know the pivot row*)
(*Process all four rows*)
For[row=1,row≤4,row++,
If[row≠pivotrow,
(*then we subtract scaled pivot row from row*)
B[[row]]=B[[row]]-B[[row,column]]/B[[pivotrow,column]]*B[[pivotrow]],
(*else we scale the row to have a leading 1*)
B[[row]]=B[[row]]/B[[row,column]]
]
];
];
Print["B=",MatrixForm[B]];

From In[19]:=B=
{{1.0000, 1.3877*^-17, 0.0000, -1.3877*^-17, 1.0542},
{0.0000, 1.0000, 0.0000, 0.0000, 0.8057},
{0.0000, 0.0000, 1.0000, -2.7755*^-17, 0.9584},
{0.0000, 0.0000, 0.0000, 1.0000, 0.9093}}

Study this and test this very carefully to make certain that I have made no mistakes in this.
But there is some chance this is at least partly correct because the result seems to match

In[31]:= LinearSolve[A,RHS]

Out[31]= {1.05427,0.80576,0.958446,0.909333}

URL: ,

Subject (listing for 'Gaussian elimination methods')
Author Date Posted
Gaussian elimination methods Tatjana 09/07/12 09:42am
Re: Gaussian elimination methods Bill Simpson 09/07/12 9:37pm
Re: Gaussian elimination methods Bill Simpson 09/07/12 11:53pm
Re: Re: Gaussian elimination methods Tatjana 09/08/12 1:19pm
Re: Re: Re: Gaussian elimination methods Bill Simpson 09/08/12 5:57pm
< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic