(* Content-type: application/mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 7.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 145, 7] NotebookDataLength[ 31271, 806] NotebookOptionsPosition[ 29380, 739] NotebookOutlinePosition[ 29742, 755] CellTagsIndexPosition[ 29699, 752] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell["\<\ Implementa\[CCedilla]\[ATilde]o do M\[EAcute]todo de Jacobi\ \>", "Subtitle", CellChangeTimes->{{3.528634701341174*^9, 3.528634792371771*^9}, { 3.528634853142254*^9, 3.528634915337235*^9}, {3.528636315016026*^9, 3.528636395093951*^9}, {3.5286364731551247`*^9, 3.5286365403845577`*^9}, { 3.528636637758952*^9, 3.528636714227992*^9}, {3.528636784395108*^9, 3.528636795048129*^9}, {3.5286368297229233`*^9, 3.528636864410487*^9}, { 3.528636915956449*^9, 3.528636917691555*^9}, {3.528637636293191*^9, 3.528637657467101*^9}, 3.5286377042336893`*^9, {3.528637915595739*^9, 3.528637973007505*^9}, {3.528642172098881*^9, 3.528642259948406*^9}, { 3.528642291555902*^9, 3.528642322988111*^9}, {3.528642363234952*^9, 3.528642484661255*^9}, {3.528642551883307*^9, 3.528642554137897*^9}, { 3.528642597531201*^9, 3.528642618609251*^9}, {3.528642654768762*^9, 3.528642671414716*^9}}], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"Jacobi", "[", RowBox[{"A_", ",", "b_", ",", "x0_", ",", "nmax_", ",", "tol_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"n", ",", "sol", ",", "oldsol", ",", "iter"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"n", "=", RowBox[{"Length", "[", "A", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"sol", " ", "=", " ", "x0"}], ";", "\[IndentingNewLine]", RowBox[{"oldsol", "=", RowBox[{"x0", "+", RowBox[{"2", "*", "tol"}]}]}], ";", "\[IndentingNewLine]", RowBox[{"iter", "=", "0"}], ";", "\[IndentingNewLine]", RowBox[{"While", "[", RowBox[{ RowBox[{"And", "[", RowBox[{ RowBox[{"iter", "<", "nmax"}], ",", RowBox[{ RowBox[{"Max", "[", RowBox[{"Abs", "[", RowBox[{"sol", "-", "oldsol"}], "]"}], "]"}], ">", "tol"}]}], "]"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"oldsol", "=", "sol"}], ";", "\[IndentingNewLine]", RowBox[{"For", "[", RowBox[{ RowBox[{"i", "=", "1"}], ",", RowBox[{"i", "\[LessEqual]", "n"}], ",", RowBox[{"i", "++"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"sol", "[", RowBox[{"[", "i", "]"}], "]"}], "=", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"b", "[", RowBox[{"[", "i", "]"}], "]"}], "-", RowBox[{"Sum", "[", RowBox[{ RowBox[{ RowBox[{"A", "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}], "*", RowBox[{"oldsol", "[", RowBox[{"[", "j", "]"}], "]"}]}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", RowBox[{"i", "-", "1"}]}], "}"}]}], "]"}], "-", RowBox[{"Sum", "[", RowBox[{ RowBox[{ RowBox[{"A", "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}], "*", RowBox[{"oldsol", "[", RowBox[{"[", "j", "]"}], "]"}]}], ",", RowBox[{"{", RowBox[{"j", ",", RowBox[{"i", "+", "1"}], ",", "n"}], "}"}]}], "]"}]}], ")"}], "/", RowBox[{"A", "[", RowBox[{"[", RowBox[{"i", ",", "i"}], "]"}], "]"}]}]}]}], "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", RowBox[{"iter", "++"}]}]}], "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", RowBox[{"Print", "[", RowBox[{ "\"\\"", ",", " ", "iter", ",", "\"\< itera\[CCedilla]\[OTilde]es\>\""}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"iter", "\[GreaterEqual]", "nmax"}], ",", RowBox[{ "Print", "[", "\"\\"", "]"}]}], "]"}], ";", "\[IndentingNewLine]", "sol"}]}], "\[IndentingNewLine]", "]"}]}], ";"}]], "Input", CellChangeTimes->{{3.528634701341174*^9, 3.528634792371771*^9}, { 3.528634853142254*^9, 3.528634915337235*^9}, {3.528636315016026*^9, 3.528636395093951*^9}, {3.5286364731551247`*^9, 3.5286365403845577`*^9}, { 3.528636637758952*^9, 3.528636714227992*^9}, {3.528636784395108*^9, 3.528636795048129*^9}, {3.5286368297229233`*^9, 3.528636864410487*^9}, { 3.528636915956449*^9, 3.528636917691555*^9}, {3.528637636293191*^9, 3.528637657467101*^9}, 3.5286377042336893`*^9, {3.528637915595739*^9, 3.528637973007505*^9}, {3.528642172098881*^9, 3.528642259948406*^9}, { 3.528642291555902*^9, 3.528642322988111*^9}, {3.528642363234952*^9, 3.528642484661255*^9}, {3.528642551883307*^9, 3.528642554137897*^9}, { 3.528642597531201*^9, 3.528642618609251*^9}, {3.528642654768762*^9, 3.528642671414716*^9}, {3.528642732524363*^9, 3.528642804378476*^9}, { 3.528642899271908*^9, 3.528643080607703*^9}, {3.528643119423668*^9, 3.528643132782837*^9}, {3.528643181789693*^9, 3.528643181850937*^9}}], Cell[CellGroupData[{ Cell["Exemplo", "Subsubsection", CellChangeTimes->{{3.528642640226227*^9, 3.528642641210806*^9}}], Cell[CellGroupData[{ Cell[BoxData[{ RowBox[{ RowBox[{"A", "=", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"4", ",", "1", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "4", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "1", ",", "2"}], "}"}]}], "}"}]}], ";", " ", RowBox[{"b", "=", RowBox[{"{", RowBox[{"1", ",", "0", ",", "1"}], "}"}]}], ";"}], "\[IndentingNewLine]", RowBox[{"Jacobi", "[", RowBox[{"A", ",", "b", ",", RowBox[{"{", RowBox[{"0.", ",", "0.", ",", "0."}], "}"}], ",", "100", ",", RowBox[{"10", "^", RowBox[{"(", RowBox[{"-", "8"}], ")"}]}]}], "]"}]}], "Input", CellChangeTimes->{{3.528636717469385*^9, 3.5286367760849257`*^9}, { 3.528642339984652*^9, 3.528642341175215*^9}, {3.528642493873045*^9, 3.528642516632236*^9}, {3.528642574690381*^9, 3.528642574950604*^9}, { 3.528642605981744*^9, 3.528642607173641*^9}}], Cell[BoxData[ InterpretationBox[ RowBox[{"\<\"Foram realizadas \"\>", "\[InvisibleSpace]", "34", "\[InvisibleSpace]", "\<\" itera\[CCedilla]\[OTilde]es\"\>"}], SequenceForm["Foram realizadas ", 34, " itera\[CCedilla]\[OTilde]es"], Editable->False]], "Print", CellChangeTimes->{{3.5286424864430447`*^9, 3.528642517440591*^9}, { 3.52864255736871*^9, 3.5286426082889338`*^9}, 3.5286427772161283`*^9, 3.528643016821059*^9, {3.528643086046359*^9, 3.5286431365379972`*^9}, 3.5286431858242197`*^9}], Cell[BoxData[ RowBox[{"{", RowBox[{"0.15384615102284727`", ",", RowBox[{"-", "0.2307692344271004`"}], ",", "0.6153846123146138`"}], "}"}]], "Output", CellChangeTimes->{{3.528636767832539*^9, 3.528636799310581*^9}, { 3.5286368346678467`*^9, 3.5286368684220552`*^9}, 3.52863692266534*^9, 3.528637661268312*^9, 3.528637707633511*^9, 3.5286379771432734`*^9, { 3.528642326980852*^9, 3.5286423448945312`*^9}, {3.528642422684153*^9, 3.528642517442416*^9}, {3.5286425573705397`*^9, 3.5286426082912283`*^9}, 3.528642777218115*^9, 3.528643016827168*^9, {3.528643086049704*^9, 3.5286431365396347`*^9}, 3.528643185826087*^9}] }, Open ]] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["\<\ Implementa\[CCedilla]\[ATilde]o do M\[EAcute]todo de Gauss - Seidel\ \>", "Subtitle", CellChangeTimes->{{3.5286427018585873`*^9, 3.5286427191427517`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{ RowBox[{"GaussSeidel", "[", RowBox[{"A_", ",", "b_", ",", "x0_", ",", "nmax_", ",", "tol_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"n", ",", "sol", ",", "oldsol"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"n", "=", RowBox[{"Length", "[", "A", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"sol", " ", "=", " ", "x0"}], ";", "\[IndentingNewLine]", RowBox[{"oldsol", "=", RowBox[{"x0", "+", RowBox[{"2", "*", "tol"}]}]}], ";", "\[IndentingNewLine]", RowBox[{"iter", "=", "0"}], ";", "\[IndentingNewLine]", RowBox[{"While", "[", RowBox[{ RowBox[{"And", "[", RowBox[{ RowBox[{"iter", "<", "nmax"}], ",", RowBox[{ RowBox[{"Max", "[", RowBox[{"Abs", "[", RowBox[{"sol", "-", "oldsol"}], "]"}], "]"}], ">", "tol"}]}], "]"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"oldsol", "=", "sol"}], ";", "\[IndentingNewLine]", RowBox[{"For", "[", RowBox[{ RowBox[{"i", "=", "1"}], ",", RowBox[{"i", "\[LessEqual]", "n"}], ",", RowBox[{"i", "++"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"sol", "[", RowBox[{"[", "i", "]"}], "]"}], "=", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"b", "[", RowBox[{"[", "i", "]"}], "]"}], "-", RowBox[{"Sum", "[", RowBox[{ RowBox[{ RowBox[{"A", "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}], "*", RowBox[{"sol", "[", RowBox[{"[", "j", "]"}], "]"}]}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", RowBox[{"i", "-", "1"}]}], "}"}]}], "]"}], "-", RowBox[{"Sum", "[", RowBox[{ RowBox[{ RowBox[{"A", "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}], "*", RowBox[{"oldsol", "[", RowBox[{"[", "j", "]"}], "]"}]}], ",", RowBox[{"{", RowBox[{"j", ",", RowBox[{"i", "+", "1"}], ",", "n"}], "}"}]}], "]"}]}], ")"}], "/", RowBox[{"A", "[", RowBox[{"[", RowBox[{"i", ",", "i"}], "]"}], "]"}]}]}]}], "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", RowBox[{"iter", "++"}]}]}], "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", RowBox[{"Print", "[", RowBox[{ "\"\\"", ",", " ", "iter", ",", "\"\< itera\[CCedilla]\[OTilde]es\>\""}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"iter", "\[GreaterEqual]", "nmax"}], ",", RowBox[{ "Print", "[", "\"\\"", "]"}]}], "]"}], ";", "\[IndentingNewLine]", "sol"}]}], "\[IndentingNewLine]", "]"}]}], ";"}], "\[IndentingNewLine]"}]], "Input", CellChangeTimes->{ 3.528642720199101*^9, 3.52864278419411*^9, {3.528642824132406*^9, 3.528642868988716*^9}, {3.528643218670312*^9, 3.528643232378654*^9}, { 3.528643291151485*^9, 3.528643294191291*^9}, {3.528643329663702*^9, 3.528643344199287*^9}}], Cell[CellGroupData[{ Cell[BoxData[{ RowBox[{ RowBox[{"A", "=", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"4", ",", "1", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "4", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "1", ",", "2"}], "}"}]}], "}"}]}], ";", " ", RowBox[{"b", "=", RowBox[{"{", RowBox[{"1", ",", "0", ",", "1"}], "}"}]}], ";"}], "\[IndentingNewLine]", RowBox[{"GaussSeidel", "[", RowBox[{"A", ",", "b", ",", RowBox[{"{", RowBox[{"0.", ",", "0.", ",", "0."}], "}"}], ",", "100", ",", RowBox[{"10", "^", RowBox[{"(", RowBox[{"-", "8"}], ")"}]}]}], "]"}]}], "Input", CellChangeTimes->{{3.528643355948208*^9, 3.528643359586039*^9}}], Cell[BoxData[ InterpretationBox[ RowBox[{"\<\"Foram realizadas \"\>", "\[InvisibleSpace]", "12", "\[InvisibleSpace]", "\<\" itera\[CCedilla]\[OTilde]es\"\>"}], SequenceForm["Foram realizadas ", 12, " itera\[CCedilla]\[OTilde]es"], Editable->False]], "Print", CellChangeTimes->{3.528643360737638*^9}], Cell[BoxData[ RowBox[{"{", RowBox[{"0.15384615313611505`", ",", RowBox[{"-", "0.23076922970417257`"}], ",", "0.6153846148520863`"}], "}"}]], "Output", CellChangeTimes->{3.528643360738295*^9}] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Elimina\[CCedilla]\[ATilde]o de Gauss", "Subtitle", CellChangeTimes->{{3.528698733373204*^9, 3.5286987378822117`*^9}}], Cell[BoxData[ RowBox[{"\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"ElimGauss", "[", RowBox[{"A_", ",", "b_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"A0", "=", "A"}], ",", RowBox[{"b0", "=", "b"}], ",", "n", ",", "i", ",", "p", ",", "k"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"n", "=", RowBox[{"Length", "[", "b", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"b0", "=", "b"}], ";", "\[IndentingNewLine]", RowBox[{"For", "[", RowBox[{ RowBox[{"p", "=", "1"}], ",", RowBox[{"p", "\[LessEqual]", "n"}], ",", RowBox[{"p", "++"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"b0", "[", RowBox[{"[", "p", "]"}], "]"}], "=", RowBox[{ RowBox[{"b0", "[", RowBox[{"[", "p", "]"}], "]"}], "/", RowBox[{"A0", "[", RowBox[{"[", RowBox[{"p", ",", "p"}], "]"}], "]"}]}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"A0", "[", RowBox[{"[", "p", "]"}], "]"}], "=", RowBox[{ RowBox[{"A0", "[", RowBox[{"[", "p", "]"}], "]"}], "/", RowBox[{"A0", "[", RowBox[{"[", RowBox[{"p", ",", "p"}], "]"}], "]"}]}]}], ";", "\[IndentingNewLine]", RowBox[{"For", "[", RowBox[{ RowBox[{"i", "=", "1"}], ",", RowBox[{"i", "\[LessEqual]", "n"}], ",", RowBox[{"i", "++"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"i", "\[NotEqual]", "p"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"b0", "[", RowBox[{"[", "i", "]"}], "]"}], "=", RowBox[{ RowBox[{"b0", "[", RowBox[{"[", "i", "]"}], "]"}], "-", RowBox[{ RowBox[{"A0", "[", RowBox[{"[", RowBox[{"i", ",", "p"}], "]"}], "]"}], "*", RowBox[{"b0", "[", RowBox[{"[", "p", "]"}], "]"}]}]}]}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"i", "!=", "p"}], ",", " ", "\[IndentingNewLine]", RowBox[{ RowBox[{"A0", "[", RowBox[{"[", "i", "]"}], "]"}], "=", RowBox[{ RowBox[{"A0", "[", RowBox[{"[", "i", "]"}], "]"}], "-", RowBox[{ RowBox[{"A0", "[", RowBox[{"[", RowBox[{"i", ",", "p"}], "]"}], "]"}], "*", RowBox[{"A0", "[", RowBox[{"[", "p", "]"}], "]"}]}]}]}]}], "]"}], ";"}]}], "\[IndentingNewLine]", "]"}], ";"}]}], "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", "b0"}]}], "]"}]}], ";"}]}]], "Input", CellChangeTimes->{{3.528698763589436*^9, 3.528699051657999*^9}, { 3.52869926734719*^9, 3.528699317505176*^9}, {3.528699418198339*^9, 3.5286995606960278`*^9}, 3.528699816331059*^9, {3.5287000583326607`*^9, 3.528700169436921*^9}, {3.528700200939096*^9, 3.528700203691576*^9}, { 3.528700236826641*^9, 3.5287003209601727`*^9}, {3.528700370661685*^9, 3.528700588720777*^9}, {3.528700654888451*^9, 3.528700691845048*^9}, { 3.528700763277141*^9, 3.528700767355136*^9}, {3.528700800971137*^9, 3.528700853728361*^9}, {3.5287008892009*^9, 3.5287008950630302`*^9}, { 3.528702249920147*^9, 3.528702254591709*^9}, {3.528707547945574*^9, 3.528707555903586*^9}, 3.528707628101203*^9, 3.528707731141157*^9, { 3.528707817467239*^9, 3.52870783347521*^9}, {3.528707864481937*^9, 3.528707978103734*^9}, {3.5287080672058163`*^9, 3.528708181214501*^9}, { 3.528708261736815*^9, 3.5287082675507917`*^9}, {3.528708401611903*^9, 3.528708401667987*^9}, {3.528708475064937*^9, 3.528708513125856*^9}, { 3.528708552823048*^9, 3.528708556461212*^9}, {3.528708613996683*^9, 3.5287086422206984`*^9}, {3.528708744087371*^9, 3.528708765068048*^9}, { 3.528708834763487*^9, 3.528708852058999*^9}, {3.528708917601404*^9, 3.528708931784237*^9}, {3.528709036244598*^9, 3.528709067283845*^9}, { 3.5287091528334703`*^9, 3.528709159231029*^9}, {3.5287092963662033`*^9, 3.528709298732993*^9}, {3.528709335748239*^9, 3.5287093437378473`*^9}, { 3.5287094170656977`*^9, 3.528709422376136*^9}, {3.528709606417365*^9, 3.528709617696762*^9}, {3.528709695902676*^9, 3.5287098089969177`*^9}, { 3.528709888536489*^9, 3.528709893550384*^9}, {3.528709970886569*^9, 3.528709973276409*^9}, {3.5287100053332663`*^9, 3.52871005896169*^9}, { 3.528710102624847*^9, 3.5287101499649973`*^9}, {3.528710187405477*^9, 3.528710232472199*^9}, {3.528710281185514*^9, 3.528710292080413*^9}, 3.528717374709201*^9, {3.528717436584766*^9, 3.528717436585229*^9}, { 3.529754625646037*^9, 3.529754626297392*^9}}], Cell[BoxData[""], "Input", CellChangeTimes->{{3.5297546245231123`*^9, 3.529754624544393*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{"n", "=", "2000"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"A", "=", RowBox[{ RowBox[{"n", "*", RowBox[{"IdentityMatrix", "[", "n", "]"}]}], "+", RowBox[{"Table", "[", RowBox[{ RowBox[{"Random", "[", "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "n"}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", "n"}], "}"}]}], "]"}]}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"b", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"Random", "[", "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "n"}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"x0", "=", RowBox[{"Table", "[", RowBox[{"0", ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "n"}], "}"}]}], "]"}]}], ";"}]}], "Input", CellChangeTimes->{{3.5287017031550627`*^9, 3.528701793482983*^9}, { 3.528701941940049*^9, 3.528701953122752*^9}, {3.528702497193514*^9, 3.5287024974814053`*^9}, {3.528702840597575*^9, 3.5287028414372463`*^9}, { 3.528710539979978*^9, 3.5287105400656633`*^9}, {3.528715115540905*^9, 3.5287151158094482`*^9}, {3.528715205241699*^9, 3.5287152052969522`*^9}, { 3.528715240326291*^9, 3.528715301460503*^9}, {3.52871536430822*^9, 3.5287153648742237`*^9}, {3.52871565602507*^9, 3.528715656096465*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"Timing", "[", RowBox[{"elim", "=", RowBox[{"ElimGauss", "[", RowBox[{"A", ",", "b"}], "]"}]}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Timing", "[", RowBox[{"jac", "=", RowBox[{"Jacobi", "[", RowBox[{"A", ",", "b", ",", "x0", ",", RowBox[{"2", "*", "n"}], ",", RowBox[{"10", "^", RowBox[{"(", RowBox[{"-", "12"}], ")"}]}]}], "]"}]}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Timing", "[", RowBox[{"gs", "=", RowBox[{"GaussSeidel", "[", RowBox[{"A", ",", "b", ",", "x0", ",", RowBox[{"2", "*", "n"}], ",", RowBox[{"10", "^", RowBox[{"(", RowBox[{"-", "12"}], ")"}]}]}], "]"}]}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}]}]], "Input", CellChangeTimes->{{3.5287019596162367`*^9, 3.528701987722529*^9}, { 3.5287023089924593`*^9, 3.528702309686777*^9}, {3.5287023793086777`*^9, 3.528702379787283*^9}, {3.528702514121634*^9, 3.5287025143599253`*^9}, { 3.528702866029448*^9, 3.5287028768830976`*^9}, {3.528715140168922*^9, 3.5287151595317507`*^9}}], Cell[BoxData["357.5823469999999`"], "Output", CellChangeTimes->{{3.52870198879663*^9, 3.528702013527977*^9}, 3.5287022304862423`*^9, 3.528702310691278*^9, 3.5287023810815363`*^9, { 3.528702503415715*^9, 3.528702520481776*^9}, {3.528702866258485*^9, 3.528702893646708*^9}, 3.528703184147678*^9, 3.52871039847589*^9, 3.528715162338359*^9, 3.528715209041319*^9, 3.5287152449764013`*^9, 3.5287152753142233`*^9, 3.528715314375984*^9, 3.528715423264422*^9, 3.5287160236253*^9}], Cell[BoxData[ InterpretationBox[ RowBox[{"\<\"Foram realizadas \"\>", "\[InvisibleSpace]", "29", "\[InvisibleSpace]", "\<\" itera\[CCedilla]\[OTilde]es\"\>"}], SequenceForm["Foram realizadas ", 29, " itera\[CCedilla]\[OTilde]es"], Editable->False]], "Print", CellChangeTimes->{{3.528701988795782*^9, 3.528702013526367*^9}, 3.528702230484613*^9, 3.528702310689041*^9, 3.52870238107922*^9, { 3.528702503409452*^9, 3.528702520479855*^9}, {3.5287028662571087`*^9, 3.528702893644368*^9}, 3.528703184145814*^9, 3.528710398472982*^9, 3.528715162372517*^9, 3.528715209282671*^9, 3.528715245606223*^9, 3.528715277770083*^9, 3.5287153287080927`*^9, 3.528715477356139*^9, 3.528716236194315*^9}], Cell[BoxData["209.9541519999998`"], "Output", CellChangeTimes->{{3.52870198879663*^9, 3.528702013527977*^9}, 3.5287022304862423`*^9, 3.528702310691278*^9, 3.5287023810815363`*^9, { 3.528702503415715*^9, 3.528702520481776*^9}, {3.528702866258485*^9, 3.528702893646708*^9}, 3.528703184147678*^9, 3.52871039847589*^9, 3.528715162338359*^9, 3.528715209041319*^9, 3.5287152449764013`*^9, 3.5287152753142233`*^9, 3.528715314375984*^9, 3.528715423264422*^9, 3.52871623619553*^9}], Cell[BoxData[ InterpretationBox[ RowBox[{"\<\"Foram realizadas \"\>", "\[InvisibleSpace]", "11", "\[InvisibleSpace]", "\<\" itera\[CCedilla]\[OTilde]es\"\>"}], SequenceForm["Foram realizadas ", 11, " itera\[CCedilla]\[OTilde]es"], Editable->False]], "Print", CellChangeTimes->{{3.528701988795782*^9, 3.528702013526367*^9}, 3.528702230484613*^9, 3.528702310689041*^9, 3.52870238107922*^9, { 3.528702503409452*^9, 3.528702520479855*^9}, {3.5287028662571087`*^9, 3.528702893644368*^9}, 3.528703184145814*^9, 3.528710398472982*^9, 3.528715162372517*^9, 3.528715209282671*^9, 3.528715245606223*^9, 3.528715277770083*^9, 3.5287153287080927`*^9, 3.528715477356139*^9, 3.528716316449409*^9}], Cell[BoxData["79.38299000000029`"], "Output", CellChangeTimes->{{3.52870198879663*^9, 3.528702013527977*^9}, 3.5287022304862423`*^9, 3.528702310691278*^9, 3.5287023810815363`*^9, { 3.528702503415715*^9, 3.528702520481776*^9}, {3.528702866258485*^9, 3.528702893646708*^9}, 3.528703184147678*^9, 3.52871039847589*^9, 3.528715162338359*^9, 3.528715209041319*^9, 3.5287152449764013`*^9, 3.5287152753142233`*^9, 3.528715314375984*^9, 3.528715423264422*^9, 3.528716316450406*^9}] }, Closed]], Cell[BoxData["\[IndentingNewLine]"], "Input", CellChangeTimes->{3.529755215787097*^9}] }, Open ]], Cell[CellGroupData[{ Cell["Exemplo Leontief", "Subtitle", CellChangeTimes->{{3.529755197991167*^9, 3.5297552036714993`*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{"leo", "=", RowBox[{ RowBox[{"Import", "[", RowBox[{ "\"\\"", ",", "\"\\""}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"n", "=", RowBox[{ RowBox[{"Dimensions", "[", "leo", "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"A", "=", RowBox[{ RowBox[{"IdentityMatrix", "[", "n", "]"}], "-", RowBox[{"Table", "[", RowBox[{ RowBox[{"leo", "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "n"}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", "n"}], "}"}]}], "]"}]}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"b", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"leo", "[", RowBox[{"[", RowBox[{"i", ",", RowBox[{"n", "+", "1"}]}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "n"}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"x0", "=", RowBox[{"Table", "[", RowBox[{"0", ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "n"}], "}"}]}], "]"}]}], ";"}]}], "Input", CellChangeTimes->{{3.5297543820705357`*^9, 3.529754392410973*^9}, { 3.529754439881157*^9, 3.5297544502169733`*^9}, {3.529754491826804*^9, 3.529754494264282*^9}, {3.529754549775401*^9, 3.529754601334691*^9}, { 3.529754665962335*^9, 3.529754677713406*^9}, {3.529755107791535*^9, 3.5297551191156673`*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"sol1", "=", RowBox[{"Jacobi", "[", RowBox[{"A", ",", "b", ",", "x0", ",", "1000", ",", RowBox[{"10", "^", RowBox[{"(", RowBox[{"-", "5"}], ")"}]}]}], "]"}]}]], "Input", CellChangeTimes->{{3.529754644992394*^9, 3.529754702544487*^9}, { 3.529754739903694*^9, 3.529754744223287*^9}, {3.529755133891904*^9, 3.5297551530494623`*^9}}], Cell[BoxData[ InterpretationBox[ RowBox[{"\<\"Foram realizadas \"\>", "\[InvisibleSpace]", "11", "\[InvisibleSpace]", "\<\" itera\[CCedilla]\[OTilde]es\"\>"}], SequenceForm["Foram realizadas ", 11, " itera\[CCedilla]\[OTilde]es"], Editable->False]], "Print", CellChangeTimes->{ 3.529754704052498*^9, {3.529754745153438*^9, 3.529754752212627*^9}, { 3.5297551243663073`*^9, 3.529755153302747*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ "44.26016988204326`", ",", "40.2998905623501`", ",", "9.840048228192984`", ",", "13.319701586441877`", ",", "6.000008212168476`", ",", "2.8900564577059265`", ",", "7.899725582823315`"}], "}"}]], "Output", CellChangeTimes->{ 3.529754704053321*^9, {3.52975474515422*^9, 3.5297547522156153`*^9}, { 3.5297551243681803`*^9, 3.529755153304665*^9}}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"sol2", "=", RowBox[{"GaussSeidel", "[", RowBox[{"A", ",", "b", ",", "x0", ",", "1000", ",", RowBox[{"10", "^", RowBox[{"(", RowBox[{"-", "6"}], ")"}]}]}], "]"}]}]], "Input", CellChangeTimes->{{3.529754764743761*^9, 3.529754768614442*^9}, { 3.5297551392665567`*^9, 3.529755139401965*^9}}], Cell[BoxData[ InterpretationBox[ RowBox[{"\<\"Foram realizadas \"\>", "\[InvisibleSpace]", "8", "\[InvisibleSpace]", "\<\" itera\[CCedilla]\[OTilde]es\"\>"}], SequenceForm["Foram realizadas ", 8, " itera\[CCedilla]\[OTilde]es"], Editable->False]], "Print", CellChangeTimes->{ 3.529754770251878*^9, {3.529755130124628*^9, 3.529755159589739*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ "44.26017112216656`", ",", "40.29989085667182`", ",", "9.840048266987878`", ",", "13.319701605026335`", ",", "6.000008246635513`", ",", "2.8900564583501005`", ",", "7.899725629478752`"}], "}"}]], "Output", CellChangeTimes->{ 3.529754770252738*^9, {3.529755130148582*^9, 3.529755159592266*^9}}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"sol3", "=", RowBox[{"ElimGauss", "[", RowBox[{"A", ",", "b"}], "]"}]}]], "Input", CellChangeTimes->{{3.529754775390409*^9, 3.529754791053342*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ "44.26017113076266`", ",", "40.299890857236946`", ",", "9.840048267119709`", ",", "13.319701605039674`", ",", "6.000008246687611`", ",", "2.8900564583503225`", ",", "7.899725629491248`"}], "}"}]], "Output", CellChangeTimes->{ 3.5297547919310217`*^9, {3.5297551421584997`*^9, 3.5297551619473457`*^9}}] }, Open ]] }, Open ]] }, WindowSize->{749, 730}, WindowMargins->{{84, Automatic}, {-12, Automatic}}, ShowSelection->True, FrontEndVersion->"7.0 for Mac OS X x86 (32-bit) (November 10, 2008)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[567, 22, 918, 14, 46, "Subtitle"], Cell[1488, 38, 4393, 98, 283, "Input"], Cell[CellGroupData[{ Cell[5906, 140, 98, 1, 24, "Subsubsection"], Cell[CellGroupData[{ Cell[6029, 145, 926, 25, 43, "Input"], Cell[6958, 172, 514, 9, 20, "Print"], Cell[7475, 183, 647, 11, 27, "Output"] }, Open ]] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[8183, 201, 166, 3, 46, "Subtitle"], Cell[8352, 206, 3740, 92, 298, "Input"], Cell[CellGroupData[{ Cell[12117, 302, 736, 22, 43, "Input"], Cell[12856, 326, 311, 6, 20, "Print"], Cell[13170, 334, 203, 5, 27, "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[13422, 345, 125, 1, 46, "Subtitle"], Cell[13550, 348, 5248, 111, 238, "Input"], Cell[18801, 461, 94, 1, 27, InheritFromParent], Cell[18898, 464, 1391, 36, 73, "Input"], Cell[CellGroupData[{ Cell[20314, 504, 1299, 33, 73, "Input"], Cell[21616, 539, 495, 7, 27, "Output"], Cell[22114, 548, 718, 12, 20, "Print"], Cell[22835, 562, 496, 7, 27, "Output"], Cell[23334, 571, 718, 12, 20, "Print"], Cell[24055, 585, 497, 7, 27, "Output"] }, Closed]], Cell[24567, 595, 87, 1, 37, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[24691, 601, 104, 1, 46, "Subtitle"], Cell[24798, 604, 1673, 49, 88, "Input"], Cell[CellGroupData[{ Cell[26496, 657, 383, 9, 27, "Input"], Cell[26882, 668, 412, 8, 20, "Print"], Cell[27297, 678, 398, 8, 27, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[27732, 691, 339, 8, 27, "Input"], Cell[28074, 701, 358, 7, 20, "Print"], Cell[28435, 710, 346, 7, 27, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[28818, 722, 178, 4, 27, "Input"], Cell[28999, 728, 353, 7, 27, "Output"] }, Open ]] }, Open ]] } ] *) (* End of internal cache information *)