(* Content-type: application/vnd.wolfram.mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 8.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 157, 7] NotebookDataLength[ 6353, 187] NotebookOptionsPosition[ 6040, 171] NotebookOutlinePosition[ 6381, 186] CellTagsIndexPosition[ 6338, 183] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell[BoxData[ RowBox[{ RowBox[{"(*", RowBox[{"Input", " ", "data"}], "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"A", "=", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"4", ",", RowBox[{"-", "2"}], ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "2"}], ",", "4", ",", RowBox[{"-", "2"}]}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", RowBox[{"-", "2"}], ",", "4"}], "}"}]}], "}"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"b", "=", RowBox[{"{", RowBox[{"11", ",", RowBox[{"-", "16"}], ",", "17"}], "}"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"n", "=", RowBox[{"Length", "[", "A", "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{"(*", RowBox[{"Forward", " ", "elimination"}], "*)"}], "\[IndentingNewLine]", RowBox[{"For", "[", RowBox[{ RowBox[{"k", "=", "1"}], ",", " ", RowBox[{"k", "\[LessEqual]", "n"}], ",", " ", RowBox[{"k", "++"}], ",", "\[IndentingNewLine]", RowBox[{"For", "[", RowBox[{ RowBox[{"i", "=", RowBox[{"k", "+", "1"}]}], ",", RowBox[{"i", "\[LessEqual]", "n"}], ",", RowBox[{"i", "++"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"l", "=", FractionBox[ RowBox[{"A", "[", RowBox[{"[", RowBox[{"i", ",", "k"}], "]"}], "]"}], RowBox[{"A", "[", RowBox[{"[", RowBox[{"k", ",", "k"}], "]"}], "]"}]]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"A", "[", RowBox[{"[", RowBox[{"i", ",", "k"}], "]"}], "]"}], "=", "0"}], ";", "\[IndentingNewLine]", RowBox[{"For", "[", RowBox[{ RowBox[{"j", "=", RowBox[{"k", "+", "1"}]}], ",", RowBox[{"j", "\[LessEqual]", "n"}], ",", RowBox[{"j", "++"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"A", "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}], "=", RowBox[{ RowBox[{"A", "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}], "-", RowBox[{"l", "*", RowBox[{"A", "[", RowBox[{"[", RowBox[{"k", ",", "j"}], "]"}], "]"}]}]}]}], ";"}]}], "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"b", "[", RowBox[{"[", "i", "]"}], "]"}], "=", RowBox[{ RowBox[{"b", "[", RowBox[{"[", "i", "]"}], "]"}], "-", RowBox[{"l", "*", RowBox[{"b", "[", RowBox[{"[", "k", "]"}], "]"}]}]}]}], ";"}]}], "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]", "]"}], "\[IndentingNewLine]", RowBox[{"(*", RowBox[{"Backward", " ", "substitution"}], "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"x", "=", RowBox[{"Table", "[", RowBox[{"0", ",", RowBox[{"{", RowBox[{"i", ",", "n"}], "}"}]}], "]"}]}], " ", ";", RowBox[{"(*", RowBox[{ RowBox[{"We", " ", "create", " ", "a", " ", "list"}], ",", " ", RowBox[{ "in", " ", "which", " ", "we", " ", "shall", " ", "keep", " ", "the", " ", "values", " ", "of", " ", "the", " ", "unknowns"}]}], "*)"}], "\[IndentingNewLine]", RowBox[{"For", "[", RowBox[{ RowBox[{"i", "=", "n"}], ",", RowBox[{"i", "\[GreaterEqual]", "1"}], ",", " ", RowBox[{"i", "--"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"x", "[", RowBox[{"[", "i", "]"}], "]"}], "=", FractionBox[ RowBox[{ RowBox[{"b", "[", RowBox[{"[", "i", "]"}], "]"}], "-", RowBox[{"Sum", "[", RowBox[{ RowBox[{ RowBox[{"A", "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}], RowBox[{"x", "[", RowBox[{"[", "j", "]"}], "]"}]}], ",", RowBox[{"{", RowBox[{"j", ",", RowBox[{"i", "+", "1"}], ",", "n"}], "}"}]}], "]"}]}], RowBox[{"A", "[", RowBox[{"[", RowBox[{"i", ",", "i"}], "]"}], "]"}]]}]}], "\[IndentingNewLine]", "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]", "x", "\[IndentingNewLine]"}]}]], "Input", CellChangeTimes->{{3.6557929521573105`*^9, 3.6557929531373124`*^9}, { 3.655792992582371*^9, 3.655793106106538*^9}, {3.655793138812117*^9, 3.655793169457162*^9}, {3.6557932145632286`*^9, 3.6557935316707597`*^9}, { 3.655793580854902*^9, 3.6557936143739595`*^9}, 3.655793659345024*^9, { 3.655793741346494*^9, 3.6557937470565023`*^9}, {3.6557939568350487`*^9, 3.655794013999318*^9}, {3.655794130158848*^9, 3.655794131032898*^9}, { 3.7191297905910125`*^9, 3.719129852713566*^9}, 3.719129943545761*^9}], Cell[BoxData[ RowBox[{"{", RowBox[{"1", ",", RowBox[{"-", "2"}], ",", "3"}], "}"}]], "Output", CellChangeTimes->{{3.6557935281107545`*^9, 3.655793532430761*^9}, { 3.655793601173933*^9, 3.6557936155339613`*^9}, {3.655793660055025*^9, 3.6557936686830397`*^9}, 3.655793748596504*^9, 3.655794079447712*^9, 3.719129861566072*^9, 3.7191299462389145`*^9}] }, Open ]] }, WindowSize->{944, 982}, WindowMargins->{{Automatic, 0}, {Automatic, 0}}, FrontEndVersion->"10.1 for Microsoft Windows (64-bit) (March 23, 2015)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[579, 22, 5074, 137, 576, "Input"], Cell[5656, 161, 368, 7, 88, "Output"] }, Open ]] } ] *) (* End of internal cache information *)