(* 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[ 7414, 209] NotebookOptionsPosition[ 6876, 186] NotebookOutlinePosition[ 7214, 201] CellTagsIndexPosition[ 7171, 198] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell["M\[EAcute]todo do Ponto Fixo em Rn", "Subsection", CellChangeTimes->{{3.528102010438264*^9, 3.528102022640826*^9}}], Cell["\<\ Implementa\[CCedilla]\[ATilde]o do m\[EAcute]todo do ponto fixo em Rn, para \ resolu\[CCedilla]\[ATilde]o de sistemas de equa\[CCedilla]\[OTilde]es n\ \[ATilde]o lineares da forma G (X) = X, em que X = (x_ 1, ... , x_n) e G = \ (g_ 1, ... , g_n). A converg\[EHat]ncia do m\[EAcute]todo \[EAcute] \ condicional e tipicamente de primeira ordem. Par\[AHat]metros de entrada: * G, X : a fun\[CCedilla]\[ATilde]o vectorial G e o seu argumento X * X0 : vector que d\[AAcute] a aproxima\[CCedilla]\[ATilde]o inicial * tol : erro maximo desejado, medido com base da dist\[AHat]ncia entre \ as duas \[UAcute]ltimas iteradas. * nmax : n\[UAcute]mero m\[AAcute]ximo de itera\[CCedilla]\[OTilde]es Par\[AHat]metros de sa\[IAcute]da: * vector num\[EAcute]rico com a solu\[CCedilla]\[ATilde]o do problema, \ correspondendo \[AGrave] \[UAcute]ltima itera\[CCedilla]\[ATilde]o calculada. \ Se o n\[UAcute]mero m\[AAcute]ximo de itera\[CCedilla]\[OTilde]es for \ atingido \[EAcute] emitida mensagem de erro. \ \>", "Text", CellChangeTimes->{{3.5281020288055887`*^9, 3.5281021217860813`*^9}, { 3.52810215403401*^9, 3.528102312691771*^9}}], Cell[BoxData[ RowBox[{"\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"PontoFixo", "[", RowBox[{"Gs_", ",", "X_", ",", "X0_", ",", "tol_", ",", "nmax_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{ "G", ",", "sol", ",", "oldsol", ",", "iter", ",", "n", ",", "i"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ "Gs", " ", "e", " ", "X", " ", "devem", " ", "ser", " ", "vectores", " ", "da", " ", "mesma", " ", "dimens\[ATilde]o"}], " ", "*)"}], " ", "\[IndentingNewLine]", RowBox[{ RowBox[{"n", "=", RowBox[{"Length", "[", "X", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"G", "[", "s_", "]"}], ":=", RowBox[{"Gs", "/.", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"X", "[", RowBox[{"[", "i", "]"}], "]"}], "\[Rule]", RowBox[{"s", "[", RowBox[{"[", "i", "]"}], "]"}]}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "n"}], "}"}]}], "]"}]}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"NormaInf", "[", "s_", "]"}], ":=", RowBox[{"Max", "[", RowBox[{"Abs", "[", "s", "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"sol", "=", "X0"}], ";", "\[IndentingNewLine]", RowBox[{"oldsol", "=", RowBox[{"sol", "+", RowBox[{"2", "*", "tol"}]}]}], ";", "\[IndentingNewLine]", RowBox[{"iter", "=", "0"}], ";", "\[IndentingNewLine]", RowBox[{"While", "[", RowBox[{ RowBox[{"And", "[", RowBox[{ RowBox[{"iter", "\[LessEqual]", "nmax"}], ",", " ", RowBox[{ RowBox[{"NormaInf", "[", RowBox[{"sol", "-", "oldsol"}], "]"}], ">", "tol"}]}], "]"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"oldsol", "=", "sol"}], ";", "\[IndentingNewLine]", RowBox[{"sol", " ", "=", " ", RowBox[{"G", "[", "sol", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"iter", "++"}]}]}], "]"}], ";", "\[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.528102335099949*^9, 3.5281023600697927`*^9}, { 3.528102464087284*^9, 3.528102670193475*^9}, {3.5281027392302637`*^9, 3.528102766812441*^9}, {3.528103103467539*^9, 3.528103103588254*^9}, { 3.528103191142323*^9, 3.5281031913338957`*^9}, {3.5281032642889557`*^9, 3.528103297030409*^9}, {3.528103339353856*^9, 3.528103346352332*^9}, { 3.5281034218648653`*^9, 3.528103485161414*^9}}], Cell[BoxData[ RowBox[{"Exemplo", ":", " "}]], "Input", CellChangeTimes->{{3.528102779246876*^9, 3.5281027813005733`*^9}}], Cell[CellGroupData[{ Cell[BoxData[{ RowBox[{ RowBox[{"G", "=", RowBox[{"{", RowBox[{ RowBox[{"Cos", "[", RowBox[{"0.5", "*", "y"}], "]"}], ",", RowBox[{"Sin", "[", RowBox[{"0.3", "*", "x"}], "]"}]}], "}"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"X", "=", RowBox[{"{", RowBox[{"x", ",", "y"}], "}"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"X0", "=", RowBox[{"{", RowBox[{"0", ",", "0"}], "}"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"nmax", "=", "1000"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"tol", "=", RowBox[{"10", "^", RowBox[{"(", RowBox[{"-", "6"}], ")"}]}]}], ";"}], "\[IndentingNewLine]", RowBox[{"PontoFixo", "[", RowBox[{"G", ",", "X", ",", "X0", ",", "tol", ",", "nmax"}], "]"}]}], "Input", CellChangeTimes->{{3.5281028670686197`*^9, 3.528102936222103*^9}, { 3.528103045374734*^9, 3.5281030730875473`*^9}}], Cell[BoxData[ InterpretationBox[ RowBox[{"\<\"Foram realizadas \"\>", "\[InvisibleSpace]", "9", "\[InvisibleSpace]", "\<\" itera\[CCedilla]\[OTilde]es\"\>"}], SequenceForm["Foram realizadas ", 9, " itera\[CCedilla]\[OTilde]es"], Editable->False]], "Print", CellChangeTimes->{3.5281034874939623`*^9}], Cell[BoxData[ RowBox[{"{", RowBox[{"0.9893274388315207`", ",", "0.2924599023466555`"}], "}"}]], "Output", CellChangeTimes->{ 3.528103074350605*^9, 3.528103110684782*^9, 3.528103194863462*^9, { 3.52810327256966*^9, 3.528103300620596*^9}, 3.528103349208734*^9, { 3.528103434438221*^9, 3.528103453534562*^9}, 3.528103487507534*^9}] }, Open ]] }, Open ]] }, WindowSize->{703, 601}, WindowMargins->{{269, Automatic}, {33, Automatic}}, FrontEndVersion->"8.0 for Linux x86 (64-bit) (February 23, 2011)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[579, 22, 122, 1, 39, "Subsection"], Cell[704, 25, 1148, 24, 315, "Text"], Cell[1855, 51, 3242, 77, 392, "Input"], Cell[5100, 130, 123, 2, 30, "Input"], Cell[CellGroupData[{ Cell[5248, 136, 939, 29, 126, "Input"], Cell[6190, 167, 311, 6, 23, "Print"], Cell[6504, 175, 344, 7, 30, "Output"] }, Open ]] }, Open ]] } ] *) (* End of internal cache information *)