(* 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[ 5687, 162] NotebookOptionsPosition[ 5149, 138] NotebookOutlinePosition[ 5486, 153] CellTagsIndexPosition[ 5443, 150] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell["\<\ Implementa\[CCedilla]\[ATilde]o do M\[EAcute]todo do ponto fixo para equa\ \[CCedilla]\[OTilde]es n\[ATilde]o lineares\ \>", "Subsection", CellChangeTimes->{{3.5280971269586143`*^9, 3.5280971524012403`*^9}}], Cell[TextData[{ "O m\[EAcute]todo do ponto fixo destina - se a a resolver numericamente \ equa\[CCedilla]\[OTilde]es escritas na forma ", StyleBox["g (x) = x.\n", "DisplayFormulaNumbered"], " O m\[EAcute]todo nem sempre converge (ver slides das aulas).\n \n Par\ \[AHat]metros de entrada:\n \n* g,x : Fun\[CCedilla]\[ATilde]o g e seu \ argumento\n* x0 : Aproxima\[CCedilla]\[ATilde]o inicial\n* tol : Erro m\ \[AAcute]ximo desejado, medido como a diferen\[CCedilla]a entre as duas \ \[UAcute]ltimas itera\[CCedilla]\[OTilde]es\n* nmax : n\[UAcute]mero m\ \[AAcute]ximo de itera\[CCedilla]\[OTilde]es a realizar.\n\nPar\[AHat]metros \ de sa\[IAcute]da:\n\n* Aproxima\[CCedilla]\[ATilde]o da solu\[CCedilla]\ \[ATilde]o, dada pela \[UAcute]ltima itera\[CCedilla]\[ATilde]o realizada.\n* \ mensagem de erro, caso tenha sido atingido o n\[UAcute]mero m\[AAcute]ximo de \ itera\[CCedilla]", "\[OTilde]es.", " " }], "Text", CellChangeTimes->{{3.5280971575171413`*^9, 3.528097179583929*^9}, { 3.528097217016068*^9, 3.528097284109893*^9}, {3.528097315916985*^9, 3.528097508156584*^9}}], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{ RowBox[{"PontoFixo", "[", RowBox[{"gs_", ",", "x_", ",", "x0_", ",", "tol_", ",", "nmax_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"g", ",", "sol"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"g", "[", "s_", "]"}], ":=", RowBox[{"gs", "/.", RowBox[{"x", "\[Rule]", "s"}]}]}], ";", "\[IndentingNewLine]", RowBox[{"sol", "=", "x0"}], ";", "\[IndentingNewLine]", RowBox[{"iter", "=", "0"}], ";", " ", RowBox[{"(*", " ", RowBox[{ "contador", " ", "do", " ", "numero", " ", "de", " ", "itera\[CCedilla]\[OTilde]es"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{"oldsol", "=", RowBox[{"x0", "+", RowBox[{"2", "*", "tol"}]}]}], ";", " ", RowBox[{"(*", RowBox[{ "para", " ", "garantir", " ", "que", " ", "entramos", " ", "no", " ", "ciclo"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{"While", "[", RowBox[{ RowBox[{"And", "[", RowBox[{ RowBox[{"iter", "\[LessEqual]", "nmax"}], ",", RowBox[{ RowBox[{"Abs", "[", RowBox[{"sol", "-", "oldsol"}], "]"}], ">", "tol"}]}], "]"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"oldsol", " ", "=", " ", "sol"}], ";", "\[IndentingNewLine]", RowBox[{"sol", "=", RowBox[{"g", "[", "sol", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"iter", "++"}]}]}], "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"iter", ">=", "nmax"}], ",", RowBox[{ "Print", "[", "\"\\"", "]"}]}], "]"}], ";", "\[IndentingNewLine]", "sol"}]}], "\[IndentingNewLine]", "]"}]}], ";"}], "\[IndentingNewLine]"}]], "Input", CellChangeTimes->{{3.5280975115417223`*^9, 3.5280976067120934`*^9}, { 3.5280976439924726`*^9, 3.528097786413918*^9}, {3.528097821119996*^9, 3.528097871573038*^9}, {3.528100890667371*^9, 3.5281009145005817`*^9}}], Cell[CellGroupData[{ Cell["\<\ Exemplo : aplica\[CCedilla]\[ATilde]o \[AGrave] resolu\[CCedilla]\[ATilde]o \ da eq. cos (x) = x.\ \>", "Subsubsection", CellChangeTimes->{{3.5281009408922787`*^9, 3.528100963960394*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"PontoFixo", "[", RowBox[{ RowBox[{"Cos", "[", "x", "]"}], ",", "x", ",", "0.5", ",", RowBox[{"10", "^", RowBox[{"(", RowBox[{"-", "8"}], ")"}]}], ",", "100"}], "]"}]], "Input", CellChangeTimes->{{3.5280977887930326`*^9, 3.5280978183956223`*^9}, { 3.528097876787705*^9, 3.528097891540093*^9}, {3.528100848026949*^9, 3.528100927675557*^9}}], Cell[BoxData["0.7390851372357778`"], "Output", CellChangeTimes->{ 3.528097812301606*^9, {3.528097873921077*^9, 3.5280978924405107`*^9}, { 3.5281008486386003`*^9, 3.5281009279330997`*^9}}] }, Open ]] }, Open ]] }, Open ]] }, WindowSize->{740, 599}, WindowMargins->{{140, Automatic}, {4, 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, 218, 4, 39, "Subsection"], Cell[800, 28, 1091, 19, 277, "Text"], Cell[1894, 49, 2382, 58, 335, "Input"], Cell[CellGroupData[{ Cell[4301, 111, 198, 4, 28, "Subsubsection"], Cell[CellGroupData[{ Cell[4524, 119, 389, 9, 30, "Input"], Cell[4916, 130, 193, 3, 30, "Output"] }, Open ]] }, Open ]] }, Open ]] } ] *) (* End of internal cache information *)