(* Content-type: application/mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 6.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 145, 7] NotebookDataLength[ 52426, 1864] NotebookOptionsPosition[ 48138, 1732] NotebookOutlinePosition[ 48862, 1763] CellTagsIndexPosition[ 48766, 1757] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell["\<\ RESOLUCI\[CapitalOAcute]N DE SISTEMAS LINEALES. METODOS ITERATIVOS.\ \>", "Title", TextAlignment->Center, TextJustification->0, FontSize->18, Background->None], Cell[CellGroupData[{ Cell["Condicionamiento de un sistema lineal", "Section", CellChangeTimes->{{3.496409178875*^9, 3.49640918553125*^9}}], Cell[TextData[{ "Resolver el siguiente sistema lineal mediante el comando LinearSolve:\n", Cell[BoxData[ FormBox[ RowBox[{"(", GridBox[{ {"10", "7", "8", "7"}, {"7", "5", "6", "5"}, {"8", "6", "10", "9"}, {"7", "5", "9", "10"} }], ")"}], TraditionalForm]]], ".", Cell[BoxData[ FormBox[ RowBox[{"(", GridBox[{ { SubscriptBox["x", "1"]}, { SubscriptBox["x", "2"]}, { SubscriptBox["x", "3"]}, { SubscriptBox["x", "4"]} }], ")"}], TraditionalForm]]], " = ", Cell[BoxData[ FormBox[ RowBox[{"(", GridBox[{ {"32"}, {"23"}, {"33"}, {"31"} }], ")"}], TraditionalForm]]], "\nPerturbando ligeramente el t\[EAcute]rmino independiente se obtiene:\n", Cell[BoxData[ FormBox[ RowBox[{"(", GridBox[{ {"10", "7", "8", "7"}, {"7", "5", "6", "5"}, {"8", "6", "10", "9"}, {"7", "5", "9", "10"} }], ")"}], TraditionalForm]]], ".", Cell[BoxData[ FormBox[ RowBox[{"(", GridBox[{ { SubscriptBox["x", "1"]}, { SubscriptBox["x", "2"]}, { SubscriptBox["x", "3"]}, { SubscriptBox["x", "4"]} }], ")"}], TraditionalForm]]], " = ", Cell[BoxData[ FormBox[ RowBox[{"(", GridBox[{ {"32.1"}, {"22.9"}, {"33.1"}, {"30.9"} }], ")"}], TraditionalForm]]], ". Resolver este sistema utilizando el mismo comando.\nPerturbando \ ligeramente la matriz de coeficientes se obtiene:\n", Cell[BoxData[ FormBox[ RowBox[{"(", GridBox[{ {"10", "7", "8.1", "7.2"}, {"7.08", "5.04", "6", "5"}, {"8", "5.98", "9.89", "9"}, {"6.99", "4.99", "9", "9.98"} }], ")"}], TraditionalForm]]], ".", Cell[BoxData[ FormBox[ RowBox[{"(", GridBox[{ { SubscriptBox["x", "1"]}, { SubscriptBox["x", "2"]}, { SubscriptBox["x", "3"]}, { SubscriptBox["x", "4"]} }], ")"}], TraditionalForm]]], " = ", Cell[BoxData[ FormBox[ RowBox[{"(", GridBox[{ {"32"}, {"23"}, {"33"}, {"31"} }], ")"}], TraditionalForm]]], ". Resolver utilizando el mismo comando.\n\[DownQuestion]Qu\[EAcute] se \ puede decir a la vista de los tres resultados obtenidos?" }], "Text", CellChangeTimes->{{3.49640920325*^9, 3.49640921184375*^9}, { 3.496409241859375*^9, 3.496409589984375*^9}}], Cell[BoxData[ FormBox[ RowBox[{ RowBox[{"A", "=", RowBox[{"(", GridBox[{ {"10", "7", "8", "7"}, {"7", "5", "6", "5"}, {"8", "6", "10", "9"}, {"7", "5", "9", "10"} }], ")"}]}], ";", " ", RowBox[{"b", "=", " ", FormBox[ RowBox[{"(", GridBox[{ {"32"}, {"23"}, {"33"}, {"31"} }], ")"}], TraditionalForm]}], ";"}], TraditionalForm]], "Input", CellChangeTimes->{{3.496409606*^9, 3.496409639671875*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["\<\ Normas vectoriales y normas matriciales. N\[UAcute]mero de condici\[OAcute]n \ de una matriz.\ \>", "Section"], Cell[TextData[{ "Cuando se construye una sucesi\[OAcute]n de vectores aproximaci\[OAcute]n \ de la soluci\[OAcute]n de un sistema lineal, para estudiar la convergencia \ interesa medir la distancia entre las dos \[UAcute]ltimas aproximaciones, y \ para medir esta distancia es necesario utilizar el concepto de ", StyleBox["norma de un vector", FontWeight->"Bold"], " . Tanto en el estudio del condicionamiento de un sistema de ecuaciones \ lineales cuando se resuelve mediante m\[EAcute]todos directos, como en el \ estudio de la convergencia de los m\[EAcute]todos iterativos para la resoluci\ \[OAcute]n de sistemas lineales, es necesario el concepto de ", StyleBox["norma de una matriz", FontWeight->"Bold"], ". El comando ", StyleBox["Norm de ", FontWeight->"Bold"], StyleBox["Mathematica", FontSlant->"Italic"], " nos da la norma tanto en el caso de un vector como de una matriz", StyleBox[".", FontWeight->"Bold"], "\n\nPor otra parte, algunos sistemas son muy sensibles a los errores de \ redondeo y el vector soluci\[OAcute]n puede ser bastante inexacto. En este \ caso se dice que el sistema es ", StyleBox["inestable", FontSlant->"Italic"], " o que est\[AAcute] ", StyleBox["mal condicionado", FontSlant->"Italic"], ". En este tipo de sistemas lo que suele ocurrir es que peque\[NTilde]os \ cambios en los coeficientes o en los t\[EAcute]rminos independientes dan \ lugar a cambios apreciables en la soluci\[OAcute]n. El n\[UAcute]mero de \ condici\[OAcute]n de una matriz ", StyleBox["A", FontSlant->"Italic"], " se define como :\n\tK(A) = \[VerticalSeparator]\[VerticalSeparator]A\ \[VerticalSeparator]\[VerticalSeparator] . \[VerticalSeparator]\ \[VerticalSeparator]", Cell[BoxData[ FormBox[ SuperscriptBox["A", RowBox[{"-", "1"}]], TraditionalForm]]], "\[VerticalSeparator]\[VerticalSeparator]\ny sirve para tener una medida del \ condicionamiento de una matriz. " }], "Text", CellChangeTimes->{3.449239587765625*^9}], Cell[TextData[{ "Ejemplo 1\.ba.-\nSea el vector ", StyleBox["b ", FontWeight->"Bold"], "= ", Cell[BoxData[ InterpretationBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ { RowBox[{"-", "1.63`"}]}, {"7.23`"}, { RowBox[{"-", "3.38`"}]} }], "\[NoBreak]", ")"}], MatrixForm[{1.63, 7.23, 3.38}]]]], ", y la matriz : A = ", Cell[BoxData[ TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"3.02`", RowBox[{"-", "1.05`"}], "2.53`"}, {"4.33`", "0.56`", RowBox[{"-", "1.78`"}]}, { RowBox[{"-", "0.83`"}], RowBox[{"-", "0.54`"}], "1.47`"} }], "\[NoBreak]", ")"}], MatrixForm[#]& ]]], ". Hallar las tres normas vectoriales de ", StyleBox["b", FontWeight->"Bold"], ": ", Cell[BoxData[ FormBox[ SubscriptBox[ RowBox[{ "\[LeftDoubleBracketingBar]", "b", "\[RightDoubleBracketingBar]"}], "1"], TraditionalForm]]], ", ", Cell[BoxData[ FormBox[ SubscriptBox[ RowBox[{ "\[LeftDoubleBracketingBar]", "b", "\[RightDoubleBracketingBar]"}], "2"], TraditionalForm]]], " y ", Cell[BoxData[ FormBox[ SubscriptBox[ RowBox[{ "\[LeftDoubleBracketingBar]", "b", "\[RightDoubleBracketingBar]"}], "\[Infinity]"], TraditionalForm]]], ". Idem para la matriz A y para su inversa. Calcular el n\[UAcute]mero de \ condici\[OAcute]n de la matriz utilizando la norma del m\[AAcute]ximo." }], "Text"], Cell["\<\ A = {{3.02,-1.05,2.53}, {4.33,0.56,-1.78},{-0.83,-0.54,1.47}}; b={-1.63,7.23,-3.38};\ \>", "Input", CellChangeTimes->{3.44923961671875*^9}, CellTags->"S3.7.8"], Cell["Las tres normas del vector b:", "Text"], Cell[BoxData[ RowBox[{"euclideavect", "=", RowBox[{"Norm", "[", "b", "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"maxvect", "=", RowBox[{"Norm", "[", RowBox[{"b", ",", "\[Infinity]"}], "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"sumavect", "=", RowBox[{"Norm", "[", RowBox[{"b", ",", "1"}], "]"}]}]], "Input"], Cell["Las tres normas de la matriz A", "Text"], Cell[BoxData[ RowBox[{"euclideamat", "=", RowBox[{"Norm", "[", "A", "]"}]}]], "Input"], Cell[TextData[{ "Comprobamos que es igual a ", Cell[BoxData[ FormBox[ SqrtBox[ RowBox[{"\[Rho]", "(", RowBox[{"A", ".", SuperscriptBox["A", "t"]}], ")"}]], TraditionalForm]]] }], "Text"], Cell[BoxData[ RowBox[{ RowBox[{"Max", "[", RowBox[{"Eigenvalues", "[", RowBox[{"A", ".", RowBox[{"Transpose", "[", "A", "]"}]}], "]"}], "]"}], "^", ".5"}]], "Input"], Cell[BoxData[ RowBox[{"maxmat", "=", RowBox[{"Norm", "[", RowBox[{"A", ",", "\[Infinity]"}], "]"}]}]], "Input"], Cell["\<\ Comprobamos que es igual a la mayor de las sumas de los elementos de las \ filas en valor absoluto\ \>", "Text"], Cell[BoxData[ RowBox[{"Max", "[", RowBox[{"{", RowBox[{ RowBox[{ UnderoverscriptBox["\[Sum]", RowBox[{"j", "=", "1"}], "3"], RowBox[{"Abs", "[", RowBox[{"A", "[", RowBox[{"[", RowBox[{"1", ",", "j"}], "]"}], "]"}], "]"}]}], ",", RowBox[{ UnderoverscriptBox["\[Sum]", RowBox[{"j", "=", "1"}], "3"], RowBox[{"Abs", "[", RowBox[{"A", "[", RowBox[{"[", RowBox[{"2", ",", "j"}], "]"}], "]"}], "]"}]}], ",", RowBox[{ UnderoverscriptBox["\[Sum]", RowBox[{"j", "=", "1"}], "3"], RowBox[{"Abs", "[", RowBox[{"A", "[", RowBox[{"[", RowBox[{"3", ",", "j"}], "]"}], "]"}], "]"}]}]}], "}"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"sumamat", "=", RowBox[{"Norm", "[", RowBox[{"A", ",", "1"}], "]"}]}]], "Input"], Cell["\<\ Comprobamos que es igual a la mayor de las sumas de los elementos de las \ columnas en valor absoluto\ \>", "Text"], Cell[BoxData[ RowBox[{"Max", "[", RowBox[{"{", RowBox[{ RowBox[{ UnderoverscriptBox["\[Sum]", RowBox[{"i", "=", "1"}], "3"], RowBox[{"Abs", "[", RowBox[{"A", "[", RowBox[{"[", RowBox[{"i", ",", "1"}], "]"}], "]"}], "]"}]}], ",", RowBox[{ UnderoverscriptBox["\[Sum]", RowBox[{"i", "=", "1"}], "3"], RowBox[{"Abs", "[", RowBox[{"A", "[", RowBox[{"[", RowBox[{"i", ",", "2"}], "]"}], "]"}], "]"}]}], ",", RowBox[{ UnderoverscriptBox["\[Sum]", RowBox[{"i", "=", "1"}], "3"], RowBox[{"Abs", "[", RowBox[{"A", "[", RowBox[{"[", RowBox[{"i", ",", "3"}], "]"}], "]"}], "]"}]}]}], "}"}], "]"}]], "Input"], Cell["\<\ Repetimos el c\[AAcute]lculo de la norma para la inversa de A\ \>", "Text"], Cell[BoxData[ RowBox[{"euclideainv", "=", RowBox[{"Norm", "[", RowBox[{"Inverse", "[", "A", "]"}], "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"maxinv", "=", RowBox[{"Norm", "[", RowBox[{ RowBox[{"Inverse", "[", "A", "]"}], ",", "\[Infinity]"}], "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"sumainv", "=", RowBox[{"Norm", "[", RowBox[{ RowBox[{"Inverse", "[", "A", "]"}], ",", "1"}], "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"m", "=", RowBox[{"maxmat", "*", "maxinv"}]}]], "Input", CellChangeTimes->{3.449239713390625*^9}], Cell[TextData[{ "\nEjemplo 2\.ba.-\nSea el sistema A. x = b, siendo A y b la matriz y vector \ respectivamente del ejemplo anterior. Sea x = ", Cell[BoxData[ InterpretationBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"1"}, {"2"}, { RowBox[{"-", "1"}]} }], "\[NoBreak]", ")"}], MatrixForm[{1, 2, -1}]]]], " la soluci\[OAcute]n exacta y ", Cell[BoxData[ FormBox[ OverscriptBox["x", "~"], TraditionalForm]]], " = ", Cell[BoxData[ InterpretationBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"0.88`"}, { RowBox[{"-", "2.34`"}]}, { RowBox[{"-", "2.66`"}]} }], "\[NoBreak]", ")"}], MatrixForm[{0.88, -2.34, -2.66}]]]], "la soluci\[OAcute]n aproximada. Calcular el error relativo y el residuo \ relativo. Comprobar que el error relativo est\[AAcute] acotado superiormente \ por el producto del residuo relativo por el n\.ba de condici\[OAcute]n de la \ matriz, e inferiormente por el cociente del residuo relativo entre el n\.ba \ de condici\[OAcute]n de la matriz." }], "Text"], Cell[BoxData[ RowBox[{ RowBox[{"xe", "=", RowBox[{"{", RowBox[{"1.", ",", "2.", ",", RowBox[{"-", "1."}]}], "}"}]}], ";", RowBox[{"xa", "=", RowBox[{"{", RowBox[{".88", ",", RowBox[{"-", "2.34"}], ",", RowBox[{"-", "2.66"}]}], "}"}]}], ";", RowBox[{"e", "=", RowBox[{"xe", "-", "xa"}]}], ";", RowBox[{"errorel", "=", RowBox[{ RowBox[{"Norm", "[", "e", "]"}], "/", RowBox[{"Norm", "[", "xe", "]"}]}]}]}]], "Input"], Cell[BoxData[ RowBox[{ RowBox[{"resi", "=", RowBox[{"b", "-", RowBox[{"A", ".", "xa"}]}]}], ";", RowBox[{"resirelat", "=", RowBox[{ RowBox[{"Norm", "[", "resi", "]"}], "/", RowBox[{"Norm", "[", "b", "]"}]}]}]}]], "Input"], Cell[BoxData[{"errorel", "\[IndentingNewLine]", RowBox[{"m", "*", "resirelat"}]}], "Input"], Cell[BoxData[{"errorel", "\[IndentingNewLine]", RowBox[{"resirelat", "/", "m"}]}], "Input"], Cell[TextData[{ "Hallar el N\[UAcute]mero de Condici\[OAcute]n de la matriz :\n", Cell[BoxData[ FormBox[ RowBox[{"(", GridBox[{ {"10", "7", "8", "7"}, {"7", "5", "6", "5"}, {"8", "6", "10", "9"}, {"7", "5", "9", "10"} }], ")"}], TraditionalForm]]] }], "Text", CellChangeTimes->{{3.496409663890625*^9, 3.496409699078125*^9}}], Cell[BoxData["\[IndentingNewLine]"], "Input", CellChangeTimes->{3.496409701328125*^9}] }, Open ]], Cell[CellGroupData[{ Cell["El m\[EAcute]todo de Jacobi", "Section"], Cell[TextData[{ "Sea el sistema :\n\t", Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"(", "\[NegativeThinSpace]", GridBox[{ { SubscriptBox["a", "11"], SubscriptBox["a", "12"], "..", SubscriptBox["a", RowBox[{"1", "n"}]]}, { SubscriptBox["a", "21"], SubscriptBox["a", "22"], "..", SubscriptBox["a", RowBox[{"2", "n"}]]}, {"..", "..", "..", ".."}, { SubscriptBox["a", "n1"], SubscriptBox["a", "n2"], "..", SubscriptBox["a", "nn"]} }], "\[NegativeThinSpace]", ")"}], ".", RowBox[{"(", "\[NegativeThinSpace]", GridBox[{ { SubscriptBox["x", "1"]}, { SubscriptBox["x", "2"]}, {".."}, { SubscriptBox["x", "n"]} }], "\[NegativeThinSpace]", ")"}]}], "=", " ", RowBox[{"(", "\[NegativeThinSpace]", GridBox[{ { SubscriptBox["b", "1"]}, { SubscriptBox["b", "2"]}, {".."}, { SubscriptBox["b", "n"]} }], "\[NegativeThinSpace]", ")"}]}]]], "\nPara resolverlo mediante el m\[EAcute]todo de Jacobi se implementa el \ siguiente proceso iterativo:\n\t", Cell[BoxData[ RowBox[{ SubsuperscriptBox["x", "i", RowBox[{"(", "k", ")"}]], "=", RowBox[{ FractionBox["1", SubscriptBox["a", "ii"]], ".", RowBox[{"(", RowBox[{ SubscriptBox["b", "i"], "-", RowBox[{ UnderoverscriptBox["\[Sum]", RowBox[{"j", "=", "1"}], RowBox[{"i", "-", "1"}]], RowBox[{ SubscriptBox["a", "ij"], " ", SubsuperscriptBox["x", "j", RowBox[{"(", RowBox[{"k", "-", "1"}], ")"}]]}]}], "-", RowBox[{ UnderoverscriptBox["\[Sum]", RowBox[{"k", "=", RowBox[{"i", "+", "1"}]}], "n"], RowBox[{ SubscriptBox["a", "ij"], " ", SubsuperscriptBox["x", "j", RowBox[{"(", RowBox[{"k", "-", "1"}], ")"}]]}]}]}], ")"}]}]}]]], "\nEl super\[IAcute]ndice (k) correponde a la etapa de iteraci\[OAcute]n." }], "Text"], Cell[TextData[{ "Ejemplo 3\.ba. Consideremos el sistema de ecuaciones : A . x = b, siendo A \ = ", Cell[BoxData[ TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"4", RowBox[{"-", "1"}], "1"}, {"4", RowBox[{"-", "8"}], "1"}, { RowBox[{"-", "2"}], RowBox[{"-", "1"}], "5"} }], "\[NoBreak]", ")"}], MatrixForm[#]& ]]], ", y b = ", Cell[BoxData[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"7"}, { RowBox[{"-", "21"}]}, {"15"} }], "\[NoBreak]", ")"}]]], ". Realizar 5 iteraciones del mdo. de Jacobi partiendo de la aproximaci\ \[OAcute]n inicial : x0 = ", Cell[BoxData[ InterpretationBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"1"}, {"2"}, {"2"} }], "\[NoBreak]", ")"}], MatrixForm[{1, 2, 2}]]]], ".", "Calcular, en cada iteraci\[OAcute]n, el error absoluto y relativo." }], "Text"], Cell[BoxData[ RowBox[{ RowBox[{"A", "=", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"4", ",", RowBox[{"-", "1"}], ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"4", ",", RowBox[{"-", "8"}], ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "2"}], ",", RowBox[{"-", "1"}], ",", "5"}], "}"}]}], "}"}]}], ";"}]], "Input"], Cell[BoxData[ RowBox[{ RowBox[{"b", "=", RowBox[{"{", RowBox[{"7", ",", RowBox[{"-", "21"}], ",", "15"}], "}"}]}], ";", RowBox[{"x0", "=", RowBox[{"{", RowBox[{"1.", ",", "2", ",", "2"}], "}"}]}], ";", RowBox[{"xn", "=", "x0"}], ";"}]], "Input"], Cell[BoxData[ RowBox[{"Do", "[", RowBox[{ RowBox[{ RowBox[{"Do", "[", RowBox[{ RowBox[{ RowBox[{"xn", "[", RowBox[{"[", "i", "]"}], "]"}], "=", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"b", "[", RowBox[{"[", "i", "]"}], "]"}], "-", RowBox[{ UnderoverscriptBox["\[Sum]", RowBox[{"k", "=", "1"}], RowBox[{"i", "-", "1"}]], RowBox[{ RowBox[{"A", "[", RowBox[{"[", RowBox[{"i", ",", "k"}], "]"}], "]"}], "*", RowBox[{"x0", "[", RowBox[{"[", "k", "]"}], "]"}]}]}], "-", RowBox[{ UnderoverscriptBox["\[Sum]", RowBox[{"k", "=", RowBox[{"i", "+", "1"}]}], "3"], RowBox[{ RowBox[{"A", "[", RowBox[{"[", RowBox[{"i", ",", "k"}], "]"}], "]"}], "*", RowBox[{"x0", "[", RowBox[{"[", "k", "]"}], "]"}]}]}]}], ")"}], "/", RowBox[{"A", "[", RowBox[{"[", RowBox[{"i", ",", "i"}], "]"}], "]"}]}]}], ",", RowBox[{"{", RowBox[{"i", ",", "3"}], "}"}]}], "]"}], ";", RowBox[{"Print", "[", "xn", "]"}], ";", RowBox[{"erabs", "=", RowBox[{"Norm", "[", RowBox[{"xn", "-", "x0"}], "]"}]}], ";", RowBox[{"errel", "=", RowBox[{"erabs", "/", RowBox[{"Norm", "[", "xn", "]"}]}]}], ";", RowBox[{"Print", "[", RowBox[{"\"\\"", ",", "erabs"}], "]"}], ";", RowBox[{"Print", "[", RowBox[{"\"\\"", ",", "errel"}], "]"}], ";", RowBox[{"x0", "=", "xn"}]}], ",", RowBox[{"{", RowBox[{"iter", ",", "5"}], "}"}]}], "]"}]], "Input", CellChangeTimes->{{3.44923976465625*^9, 3.449239770421875*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["El m\[EAcute]todo de Gauss-Seidel", "Section", TextAlignment->Left, TextJustification->0], Cell[TextData[{ "Considerando el mismo sistema anterior:\n\t", Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"(", "\[NegativeThinSpace]", GridBox[{ { SubscriptBox["a", "11"], SubscriptBox["a", "12"], "..", SubscriptBox["a", RowBox[{"1", "n"}]]}, { SubscriptBox["a", "21"], SubscriptBox["a", "22"], "..", SubscriptBox["a", RowBox[{"2", "n"}]]}, {"..", "..", "..", ".."}, { SubscriptBox["a", "n1"], SubscriptBox["a", "n2"], "..", SubscriptBox["a", "nn"]} }], "\[NegativeThinSpace]", ")"}], ".", RowBox[{"(", "\[NegativeThinSpace]", GridBox[{ { SubscriptBox["x", "1"]}, { SubscriptBox["x", "2"]}, {".."}, { SubscriptBox["x", "n"]} }], "\[NegativeThinSpace]", ")"}]}], "=", " ", RowBox[{"(", "\[NegativeThinSpace]", GridBox[{ { SubscriptBox["b", "1"]}, { SubscriptBox["b", "2"]}, {".."}, { SubscriptBox["b", "n"]} }], "\[NegativeThinSpace]", ")"}]}]]], "\nPara resolverlo mediante el m\[EAcute]todo de Gauss-Seidel se implementa \ el siguiente proceso iterativo:\n\t", Cell[BoxData[ RowBox[{ SubsuperscriptBox["x", "i", RowBox[{"(", "k", ")"}]], "=", RowBox[{ FractionBox["1", SubscriptBox["a", "ii"]], ".", RowBox[{"(", RowBox[{ SubscriptBox["b", "i"], "-", RowBox[{ UnderoverscriptBox["\[Sum]", RowBox[{"j", "=", "1"}], RowBox[{"i", "-", "1"}]], RowBox[{ SubscriptBox["a", "ij"], " ", SubsuperscriptBox["x", "j", RowBox[{"(", "k", ")"}]]}]}], "-", RowBox[{ UnderoverscriptBox["\[Sum]", RowBox[{"k", "=", RowBox[{"i", "+", "1"}]}], "n"], RowBox[{ SubscriptBox["a", "ij"], " ", SubsuperscriptBox["x", "j", RowBox[{"(", RowBox[{"k", "-", "1"}], ")"}]]}]}]}], ")"}]}]}]]], "\nEl super\[IAcute]ndice (k) correponde a la etapa de iteraci\[OAcute]n.\n\n\ Ejemplo 4\.ba. Consideremos el sistema de ecuaciones del ejemplo anterior . \ Realizar 5 iteraciones del mdo. de Gauss-Seidel partiendo de la misma \ aproximaci\[OAcute]n inicial .Calcular el error absoluto y relativo." }], "Text"], Cell[BoxData[ RowBox[{ RowBox[{"A", "=", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"4", ",", RowBox[{"-", "1"}], ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"4", ",", RowBox[{"-", "8"}], ",", "1."}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "2"}], ",", RowBox[{"-", "1"}], ",", "5"}], "}"}]}], "}"}]}], ";"}]], "Input"], Cell[BoxData[ RowBox[{ RowBox[{"b", "=", RowBox[{"{", RowBox[{"7", ",", RowBox[{"-", "21"}], ",", "15"}], "}"}]}], ";", RowBox[{"x0", "=", RowBox[{"{", RowBox[{"1.", ",", "2", ",", "2"}], "}"}]}], ";", RowBox[{"xn", "=", "x0"}], ";"}]], "Input"], Cell[BoxData[ RowBox[{"Do", "[", RowBox[{ RowBox[{ RowBox[{"Do", "[", RowBox[{ RowBox[{ RowBox[{"xn", "[", RowBox[{"[", "i", "]"}], "]"}], "=", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"b", "[", RowBox[{"[", "i", "]"}], "]"}], "-", RowBox[{ UnderoverscriptBox["\[Sum]", RowBox[{"k", "=", "1"}], RowBox[{"i", "-", "1"}]], RowBox[{ RowBox[{"A", "[", RowBox[{"[", RowBox[{"i", ",", "k"}], "]"}], "]"}], "*", RowBox[{"xn", "[", RowBox[{"[", "k", "]"}], "]"}]}]}], "-", RowBox[{ UnderoverscriptBox["\[Sum]", RowBox[{"k", "=", RowBox[{"i", "+", "1"}]}], "3"], RowBox[{ RowBox[{"A", "[", RowBox[{"[", RowBox[{"i", ",", "k"}], "]"}], "]"}], "*", RowBox[{"x0", "[", RowBox[{"[", "k", "]"}], "]"}]}]}]}], ")"}], "/", RowBox[{"A", "[", RowBox[{"[", RowBox[{"i", ",", "i"}], "]"}], "]"}]}]}], ",", RowBox[{"{", RowBox[{"i", ",", "3"}], "}"}]}], "]"}], ";", RowBox[{"Print", "[", "xn", "]"}], ";", RowBox[{"erabs", "=", RowBox[{"Norm", "[", RowBox[{"xn", "-", "x0"}], "]"}]}], ";", RowBox[{"errel", "=", RowBox[{"erabs", "/", RowBox[{"Norm", "[", "xn", "]"}]}]}], ";", RowBox[{"Print", "[", RowBox[{"\"\\"", ",", "erabs"}], "]"}], ";", RowBox[{"Print", "[", RowBox[{"\"\\"", ",", "errel"}], "]"}], ";", RowBox[{"x0", "=", "xn"}]}], ",", RowBox[{"{", RowBox[{"iter", ",", "5"}], "}"}]}], "]"}]], "Input", CellChangeTimes->{{3.449239783359375*^9, 3.44923978884375*^9}}], Cell[TextData[{ "\nLa condici\[OAcute]n necesaria y suficiente para que un m\[EAcute]todo \ iterativo de resoluci\[OAcute]n de sistemas lineales sea convergente es que \ el radio espectral de la matriz de paso sea menor que la unidad. (Se recuerda \ que el radio espectral de una matriz es igual al mayor de los valores popios \ de la matriz en m\[OAcute]dulo o valor absoluto) con ", StyleBox["Mathematica", FontSlant->"Italic"], " resulta muy sencillo calcular el radio espectral de una matriz utilizando \ el comando Eigenvalues.\nSea el sistema :\n\t", Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"(", "\[NegativeThinSpace]", GridBox[{ { SubscriptBox["a", "11"], SubscriptBox["a", "12"], "..", SubscriptBox["a", RowBox[{"1", "n"}]]}, { SubscriptBox["a", "21"], SubscriptBox["a", "22"], "..", SubscriptBox["a", RowBox[{"2", "n"}]]}, {"..", "..", "..", ".."}, { SubscriptBox["a", "n1"], SubscriptBox["a", "n2"], "..", SubscriptBox["a", "nn"]} }], "\[NegativeThinSpace]", ")"}], ".", RowBox[{"(", "\[NegativeThinSpace]", GridBox[{ { SubscriptBox["x", "1"]}, { SubscriptBox["x", "2"]}, {".."}, { SubscriptBox["x", "n"]} }], "\[NegativeThinSpace]", ")"}]}], "=", " ", RowBox[{"(", "\[NegativeThinSpace]", GridBox[{ { SubscriptBox["b", "1"]}, { SubscriptBox["b", "2"]}, {".."}, { SubscriptBox["b", "n"]} }], "\[NegativeThinSpace]", ")"}]}]]], ", siendo A = ", Cell[BoxData[ RowBox[{"(", "\[NegativeThinSpace]", GridBox[{ { SubscriptBox["a", "11"], SubscriptBox["a", "12"], "..", SubscriptBox["a", RowBox[{"1", "n"}]]}, { SubscriptBox["a", "21"], SubscriptBox["a", "22"], "..", SubscriptBox["a", RowBox[{"2", "n"}]]}, {"..", "..", "..", ".."}, { SubscriptBox["a", "n1"], SubscriptBox["a", "n2"], "..", SubscriptBox["a", "nn"]} }], "\[NegativeThinSpace]", ")"}]]], ".\n\nDefinamos las matrices :\n\tD= ", Cell[BoxData[ RowBox[{"(", "\[NegativeThinSpace]", GridBox[{ { SubscriptBox["a", "11"], "0", "..", "0"}, {"0", SubscriptBox["a", "22"], "..", "0"}, {"..", "..", "..", ".."}, {"0", "0", "..", SubscriptBox["a", "nn"]} }], "\[NegativeThinSpace]", ")"}]]], ", \tL = ", Cell[BoxData[ RowBox[{"(", "\[NegativeThinSpace]", GridBox[{ {"0", "0", "..", "0"}, { RowBox[{"-", SubscriptBox["a", "21"]}], "0", "..", "0"}, {"..", "..", "..", ".."}, { RowBox[{"-", SubscriptBox["a", "n1"]}], RowBox[{"-", SubscriptBox["a", "n2"]}], "..", "0"} }], "\[NegativeThinSpace]", ")"}]]], " \ty \n\t\n\tU = ", Cell[BoxData[ RowBox[{"(", "\[NegativeThinSpace]", GridBox[{ {"0", RowBox[{"-", SubscriptBox["a", "12"]}], "..", RowBox[{"-", SubscriptBox["a", RowBox[{"1", "n"}]]}]}, {"0", "0", "..", RowBox[{"-", SubscriptBox["a", RowBox[{"2", "n"}]]}]}, {"..", "..", "..", ".."}, {"0", "0", "..", "0"} }], "\[NegativeThinSpace]", ")"}]]], ".\nEntonces la matriz de paso del m\[EAcute]todo de Jacobi es :\n\t", Cell[BoxData[ FormBox[ SubscriptBox["T", RowBox[{"j", " "}]], TraditionalForm]]], " = ", Cell[BoxData[ FormBox[ RowBox[{ SuperscriptBox["D", RowBox[{"-", "1"}]], ".", RowBox[{"(", RowBox[{"L", "+", "U"}], ")"}]}], TraditionalForm]]], "\ny la del m\[EAcute]todo de Gauss-Seidel :\n\t", Cell[BoxData[ FormBox[ SubscriptBox["T", "G"], TraditionalForm]]], " = ", Cell[BoxData[ FormBox[ SuperscriptBox[ RowBox[{"(", RowBox[{"D", " ", "-", " ", "L"}], ")"}], RowBox[{"-", "1"}]], TraditionalForm]]], ".U" }], "Text"], Cell["\<\ Ejemplo 5\.ba.Calcular las matrices de paso de los m\[EAcute]todos de Jacobi \ y Gauss-Seidel de los ejemplos anteriores,y sus respectivos radios \ espectrales,comprobando que son menores que la unidad.\ \>", "Text"], Cell[BoxData[ RowBox[{ RowBox[{"d", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"A", "[", RowBox[{"[", RowBox[{"i", ",", "i"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "3"}], "}"}]}], "]"}]}], ";", RowBox[{"diag", "=", RowBox[{"DiagonalMatrix", "[", "d", "]"}]}]}]], "Input"], Cell[BoxData[ RowBox[{ RowBox[{"L", "=", RowBox[{"-", "A"}]}], ";", RowBox[{"Do", "[", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"j", "\[GreaterEqual]", "i"}], ",", RowBox[{ RowBox[{"L", "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}], "=", "0"}]}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", "3"}], "}"}]}], "]"}], ";", RowBox[{"MatrixForm", "[", "L", "]"}]}]], "Input"], Cell[BoxData[ RowBox[{ RowBox[{"U", "=", RowBox[{"-", "A"}]}], ";", RowBox[{"Do", "[", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"j", "<=", "i"}], ",", RowBox[{ RowBox[{"U", "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}], "=", "0"}]}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", "3"}], "}"}]}], "]"}], ";", RowBox[{"MatrixForm", "[", "U", "]"}]}]], "Input"], Cell[TextData[{ "Para el m\[EAcute]todo de Jacobi T = ", Cell[BoxData[ FormBox[ RowBox[{ SuperscriptBox["D", RowBox[{"-", "1"}]], ".", RowBox[{"(", RowBox[{"L", "+", "U"}], ")"}]}], TraditionalForm]]], ":" }], "Text"], Cell[BoxData[ RowBox[{ RowBox[{"Tj", "=", RowBox[{ RowBox[{"Inverse", "[", "diag", "]"}], ".", RowBox[{"(", RowBox[{"L", "+", "U"}], ")"}]}]}], ";", RowBox[{"MatrixForm", "[", "Tj", "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"Max", "[", RowBox[{"Abs", "[", RowBox[{"Eigenvalues", "[", "Tj", "]"}], "]"}], "]"}]], "Input"], Cell[TextData[{ "Para el m\[EAcute]todo de Gauss-Seidel T = ", Cell[BoxData[ FormBox[ RowBox[{ SuperscriptBox[ RowBox[{"(", RowBox[{"D", "-", "L"}], ")"}], RowBox[{"-", "1"}]], ".", "U"}], TraditionalForm]]], ":" }], "Text"], Cell[BoxData[ RowBox[{ RowBox[{"Tg", "=", RowBox[{ RowBox[{"Inverse", "[", RowBox[{"diag", "-", "L"}], "]"}], ".", "U"}]}], ";", RowBox[{"MatrixForm", "[", "Tg", "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"Max", "[", RowBox[{"Abs", "[", RowBox[{"Eigenvalues", "[", "Tg", "]"}], "]"}], "]"}]], "Input"] }, Open ]], Cell[CellGroupData[{ Cell["\<\ Resoluci\[OAcute]n de sistemas no lineales. El m\[EAcute]todo de Newton. El \ comando FindRoot.\ \>", "Section"], Cell[TextData[{ "Sea el sistema ", Cell[BoxData[ FormBox[ TagBox[ StyleBox[ RowBox[{"{", StyleBox[GridBox[{ { RowBox[{ RowBox[{"f1", "(", RowBox[{"x", ",", "y"}], ")"}], " ", "=", " ", "0"}]}, { RowBox[{ RowBox[{"f2", "(", RowBox[{"x", ",", "y"}], ")"}], " ", "=", " ", "0"}]} }], ShowAutoStyles->True]}], ShowAutoStyles->False], #& ], TraditionalForm]]], " , y sea J(x,y) la matriz Jacobiana de f1 y f2 respecto a x e y. Sea ", Cell[BoxData[ FormBox[ RowBox[{ SubscriptBox["P", "k"], " ", RowBox[{"(", RowBox[{ SubscriptBox["x", "k"], ",", " ", SubscriptBox["y", "k"]}], ")"}]}], TraditionalForm]]], " la aproximaci\[OAcute]n de la soluci\[OAcute]n correspondiente a la etapa \ k. Los pasos correspondientes a la siguiente etapa son:\n1\.ba.- Evaluar F(", Cell[BoxData[ FormBox[ SubscriptBox["P", "k"], TraditionalForm]]], ") = ", Cell[BoxData[ FormBox[ RowBox[{"(", "\[NegativeThinSpace]", GridBox[{ { RowBox[{"f1", "(", SubscriptBox["P", "k"], ")"}]}, { RowBox[{"f2", "(", SubscriptBox["P", "k"], ")"}]} }], "\[NegativeThinSpace]", ")"}], TraditionalForm]]], ".\n2\.ba.- Calcular la matriz jacobiana en ", Cell[BoxData[ FormBox[ FormBox[ SubscriptBox["P", "k"], TraditionalForm], TraditionalForm]]], ", J(", Cell[BoxData[ FormBox[ FormBox[ SubscriptBox["P", "k"], TraditionalForm], TraditionalForm]]], ").\n3\.ba.- Resolver el sistema lineal : J(", Cell[BoxData[ FormBox[ FormBox[ SubscriptBox["P", "k"], TraditionalForm], TraditionalForm]]], ").\[CapitalDelta]p = - F( J(", Cell[BoxData[ FormBox[ FormBox[ SubscriptBox["P", "k"], TraditionalForm], TraditionalForm]]], ").)\n4\.ba.- Calcular la siguiente aproximaci\[OAcute]n : ", Cell[BoxData[ FormBox[ SubscriptBox["P", RowBox[{"k", "+", "1"}]], TraditionalForm]]], " = ", Cell[BoxData[ FormBox[ FormBox[ SubscriptBox["P", "k"], TraditionalForm], TraditionalForm]]], " + \[CapitalDelta]p .\n\nEjemplo 6\.ba : Sea el sistema : \n\t", Cell[BoxData[ FormBox[ TagBox[ StyleBox[ RowBox[{"{", StyleBox[GridBox[{ { RowBox[{ RowBox[{ SuperscriptBox["x", "2"], " ", "-", " ", "y"}], " ", "=", " ", "0.2"}]}, { RowBox[{ RowBox[{ SuperscriptBox["y", "2"], " ", "-", " ", "x"}], " ", "=", " ", "0.3"}]} }], ShowAutoStyles->True]}], ShowAutoStyles->False], #& ], TraditionalForm]]], " , \nRepresentar gr\[AAcute]ficamente para obtener la aproximaci\[OAcute]n \ inicial correspondiente a la raiz del primer cuadrante, y calcular 3 \ iteraciones del m\[EAcute]todo de Newton ." }], "Text"], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"f", "[", RowBox[{"x_", ",", "y_"}], "]"}], "=", RowBox[{ RowBox[{"x", "^", "2"}], "-", "y", "-", ".2"}]}], ";", RowBox[{ RowBox[{"g", "[", RowBox[{"x_", ",", "y_"}], "]"}], "=", RowBox[{ RowBox[{"y", "^", "2"}], "-", "x", "-", ".3"}]}], ";"}]], "Input"], Cell[BoxData[ RowBox[{"graf1", "=", RowBox[{"ContourPlot", "[", RowBox[{ RowBox[{ RowBox[{"f", "[", RowBox[{"x", ",", "y"}], "]"}], "\[Equal]", "0"}], ",", RowBox[{"{", RowBox[{"x", ",", RowBox[{"-", "2"}], ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"y", ",", RowBox[{"-", "2"}], ",", "2"}], "}"}]}], "]"}]}]], "Input", CellChangeTimes->{{3.449239841984375*^9, 3.449239853125*^9}}], Cell[BoxData[ RowBox[{"graf2", "=", RowBox[{"ContourPlot", "[", RowBox[{ RowBox[{ RowBox[{"g", "[", RowBox[{"x", ",", "y"}], "]"}], "\[Equal]", "0"}], ",", RowBox[{"{", RowBox[{"x", ",", RowBox[{"-", "2"}], ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"y", ",", RowBox[{"-", "2"}], ",", "2"}], "}"}]}], "]"}]}]], "Input", CellChangeTimes->{{3.449239869359375*^9, 3.44923987940625*^9}}], Cell[BoxData[ RowBox[{"Show", "[", RowBox[{"graf1", ",", "graf2"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"jacob", "[", RowBox[{"x_", ",", "y_"}], "]"}], "=", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{ SubscriptBox["\[PartialD]", "x"], " ", RowBox[{"f", "[", RowBox[{"x", ",", "y"}], "]"}]}], ",", RowBox[{ SubscriptBox["\[PartialD]", "y"], " ", RowBox[{"f", "[", RowBox[{"x", ",", "y"}], "]"}]}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{ SubscriptBox["\[PartialD]", "x"], " ", RowBox[{"g", "[", RowBox[{"x", ",", "y"}], "]"}]}], ",", RowBox[{ SubscriptBox["\[PartialD]", "y"], " ", RowBox[{"g", "[", RowBox[{"x", ",", "y"}], "]"}]}]}], "}"}]}], "}"}]}], ";", RowBox[{ RowBox[{"indep", "[", RowBox[{"x_", ",", "y_"}], "]"}], "=", RowBox[{"{", RowBox[{ RowBox[{"-", RowBox[{"f", "[", RowBox[{"x", ",", "y"}], "]"}]}], ",", RowBox[{"-", RowBox[{"g", "[", RowBox[{"x", ",", "y"}], "]"}]}]}], "}"}]}], ";"}]], "Input"], Cell[BoxData[ RowBox[{"Print", "[", RowBox[{ RowBox[{"MatrixForm", "[", RowBox[{"jacob", "[", RowBox[{"x", ",", "y"}], "]"}], "]"}], ",", "\"\< \>\"", ",", " ", RowBox[{"MatrixForm", "[", RowBox[{"indep", "[", RowBox[{"x", ",", "y"}], "]"}], "]"}]}], "]"}]], "Input"], Cell[BoxData[ RowBox[{ RowBox[{"x0", "=", "1.2"}], ";", RowBox[{"y0", "=", "1.2"}], ";", RowBox[{"itermax", "=", "3"}], ";"}]], "Input"], Cell[BoxData[ RowBox[{"Do", "[", RowBox[{ RowBox[{ RowBox[{"Print", "[", RowBox[{"\"\\"", ",", RowBox[{"MatrixForm", "[", RowBox[{"jacob", "[", RowBox[{"x0", ",", "y0"}], "]"}], "]"}], ",", "\"\< \>\"", ",", "\"\\"", ",", RowBox[{"MatrixForm", "[", RowBox[{"indep", "[", RowBox[{"x0", ",", "y0"}], "]"}], "]"}]}], "]"}], ";", RowBox[{"sol", "=", RowBox[{"LinearSolve", "[", RowBox[{ RowBox[{"jacob", "[", RowBox[{"x0", ",", "y0"}], "]"}], ",", RowBox[{"indep", "[", RowBox[{"x0", ",", "y0"}], "]"}]}], "]"}]}], ";", RowBox[{"Print", "[", RowBox[{"\"\\"", ",", RowBox[{"MatrixForm", "[", "sol", "]"}]}], "]"}], ";", RowBox[{"dx", "=", RowBox[{"sol", "[", RowBox[{"[", "1", "]"}], "]"}]}], ";", RowBox[{"dy", "=", RowBox[{"sol", "[", RowBox[{"[", "2", "]"}], "]"}]}], ";", RowBox[{"x0", "=", RowBox[{"x0", "+", "dx"}]}], ";", RowBox[{"y0", "=", RowBox[{"y0", "+", "dy"}]}], ";", RowBox[{"Print", "[", RowBox[{ "\"\\"", ",", "k", ",", "\"\< x= \>\"", ",", "x0", ",", "\"\< y= \>\"", ",", "y0"}], "]"}]}], ",", RowBox[{"{", RowBox[{"k", ",", "itermax"}], "}"}]}], "]"}]], "Input"], Cell[CellGroupData[{ Cell["El comando FindRoot", "Subsection"], Cell["\<\ Como en el caso de una sola ec. no lineal, el comando FindRoot nos permite \ obtener una soluci\[OAcute]n num\[EAcute]rica (aproximada) de un sistema de \ ecuaciones no lineales partiendo de una aproximaci\[OAcute]n inicial. Una de \ sus ociones nos permite especificar el n\.ba m\[AAcute]ximo de iteraciones a \ realizar. Si se alcanza el n\.ba m\[AAcute]ximo de iteraciones sin haber \ obtenido la soluci\[OAcute]n el comando FindRoot nos devuelve la aproximaci\ \[OAcute]n calculada en la \[UAcute]ltima etapa que se puede utilizar como \ aproximaci\[OAcute]n inicial de un nuevo comando FindRoot. Es conveniente realizar una representaci\[OAcute]n gr\[AAcute]fica, cuando \ sea posible, para obtener una buena aproximaci\[OAcute]n inicial. El comando FindRoot puede resolver ec. no lineales en variable compleja. Para \ ello solo es preciso incluir la unidad imaginaria I en la \ aproximaci\[OAcute]n inicial. Por ejemplo:\ \>", "Text"], Cell["FindRoot[Sin[x] == 2, {x, 1}]", "Input", CellTags->"S3.9.6"], Cell["FindRoot[Sin[x] == 2, {x, I}]", "Input", CellTags->"S3.9.6"], Cell["\<\ Para resolver el sistema anterior utilizando el comando FindRoot:\ \>", "Text"], Cell[BoxData[ RowBox[{"FindRoot", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"f", "[", RowBox[{"x", ",", "y"}], "]"}], "\[Equal]", "0"}], ",", RowBox[{ RowBox[{"g", "[", RowBox[{"x", ",", "y"}], "]"}], "\[Equal]", "0"}]}], "}"}], ",", RowBox[{"{", RowBox[{"x", ",", "1.2"}], "}"}], ",", RowBox[{"{", RowBox[{"y", ",", "1.2"}], "}"}]}], "]"}]], "Input"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Ejercicios", "Section", CellChangeTimes->{3.5063452041875*^9}, Background->None], Cell[TextData[{ "1\.ba.- El sistema lineal :\n0.04 x1 + 0.01 x2 - 0.01 x3 = 0.06\n0.20 x1 + \ 0.50 x2 - 0.20 x3 = 0.30\n x1 + 2 x2 + 4 x3 = 11\ntiene como \ soluci\[OAcute]n exacta ", StyleBox["xe", FontWeight->"Bold"], " = ", Cell[BoxData[ FormBox[ RowBox[{"{", RowBox[{"1.827586", ",", "0.6551724", ",", "1.965517"}], "}"}], TraditionalForm]]], " y como soluci\[OAcute]n aproximada ", StyleBox["xa", FontWeight->"Bold"], " = ", Cell[BoxData[ FormBox[ RowBox[{"{", RowBox[{"1.8", ",", "0.64", ",", " ", "1.9"}], "}"}], TraditionalForm]]], ". Calcular , para las normas ", Cell[BoxData[ FormBox[ SubscriptBox["l", "1"], TraditionalForm]]], ", ", Cell[BoxData[ FormBox[ SubscriptBox["l", "2"], TraditionalForm]]], " y ", Cell[BoxData[ FormBox[ SubscriptBox["l", "\[Infinity]"], TraditionalForm]]], " : \n\ta) la norma del vector error absoluto y del vector residuo. \n\tb) \ el error relativo y el residuo relativo.\n\tc) la norma y el n\[UAcute]mero \ de condici\[OAcute]n de la matriz de coeficientes, comprobando que cualquiera \ de las normas es mayor que el radio espectral de la matriz." }], "Text", CellChangeTimes->{3.5063452041875*^9}], Cell[BoxData[ RowBox[{"\[IndentingNewLine]", RowBox[{ RowBox[{"mat", "=", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{".04", ",", ".01", ",", RowBox[{"-", ".01"}]}], "}"}], ",", RowBox[{"{", RowBox[{".2", ",", ".5", ",", RowBox[{"-", ".2"}]}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "2", ",", "4"}], "}"}]}], "}"}]}], ";", RowBox[{"b", "=", RowBox[{"{", RowBox[{".06", ",", ".3", ",", "11"}], "}"}]}], ";", RowBox[{"xe", "=", RowBox[{"{", RowBox[{"1.827586", ",", "0.6551724", ",", "1.965517"}], "}"}]}], ";", RowBox[{"xa", "=", RowBox[{"{", RowBox[{"1.8", ",", ".64", ",", "1.9"}], "}"}]}], ";"}]}]], "Input", CellChangeTimes->{3.5063452041875*^9}], Cell["a)", "Text", CellChangeTimes->{3.5063452041875*^9}], Cell["b)", "Text", CellChangeTimes->{3.5063452041875*^9}], Cell["c)", "Text", CellChangeTimes->{{3.506345181375*^9, 3.5063452041875*^9}}], Cell[TextData[{ "2\.ba.- Resolver el sistema : \n", Cell[BoxData[ TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ { RowBox[{"-", "1"}], "11", RowBox[{"-", "1"}], "3"}, {"2", RowBox[{"-", "1"}], "10", RowBox[{"-", "1"}]}, {"10", RowBox[{"-", "1"}], "2", "0"}, {"0", "3", RowBox[{"-", "1"}], "8"} }], "\[NoBreak]", ")"}], MatrixForm[#]& ]]], ". ", Cell[BoxData[ InterpretationBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"x"}, {"y"}, {"z"}, {"t"} }], "\[NoBreak]", ")"}], MatrixForm[{x, y, z, t}]]]], "= ", Cell[BoxData[ InterpretationBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"25"}, { RowBox[{"-", "11"}]}, {"6"}, {"15"} }], "\[NoBreak]", ")"}], MatrixForm[{25, -11, 6, 15}]]]], " , partiendo de la aproximaci\[OAcute]n inicial x0=", Cell[BoxData[ InterpretationBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"0"}, {"0"}, {"0"}, {"0"} }], "\[NoBreak]", ")"}], MatrixForm[{0, 0, 0, 0}]]]], "y\nutilizando el m\[EAcute]todo de Jacobi y con un error absoluto menor que \ ", Cell[BoxData[ FormBox[ RowBox[{ SuperscriptBox["10", RowBox[{"-", "3"}]], "."}], TraditionalForm]]] }], "Text", CellChangeTimes->{3.5063452041875*^9}], Cell[TextData[{ "Reordenando el sistema para que la matriz de los coeficientes sea \ estrictamente diagonal dominante: ", Cell[BoxData[ TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"10.`", RowBox[{"-", "1"}], "2", "0"}, { RowBox[{"-", "1"}], "11", RowBox[{"-", "1"}], "3"}, {"2", RowBox[{"-", "1"}], "10", RowBox[{"-", "1"}]}, {"0", "3", RowBox[{"-", "1"}], "8"} }], "\[NoBreak]", ")"}], MatrixForm[#]& ]]], ".", Cell[BoxData[ InterpretationBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"x"}, {"y"}, {"z"}, {"t"} }], "\[NoBreak]", ")"}], MatrixForm[{x, y, z, t}]]]], "=", Cell[BoxData[ InterpretationBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"6"}, {"25"}, { RowBox[{"-", "11"}]}, {"15"} }], "\[NoBreak]", ")"}], MatrixForm[{6, 25, -11, 15}]]]], ", y, partiendo de la aproximaci\[OAcute]n inicial x0=", Cell[BoxData[ InterpretationBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"0"}, {"0"}, {"0"}, {"0"} }], "\[NoBreak]", ")"}], MatrixForm[{0, 0, 0, 0}]]]], "con el m\[EAcute]todo de Jacobi y con un error absoluto menor que ", Cell[BoxData[ FormBox[ RowBox[{ SuperscriptBox["10", RowBox[{"-", "3"}]], "."}], TraditionalForm]]] }], "Text", CellChangeTimes->{3.5063452041875*^9}], Cell[TextData[{ "\n3\.ba.-Resolver el siguiente sistema :\n", Cell[BoxData[ RowBox[{"(", "\[NoBreak]", GridBox[{ { RowBox[{"-", "2"}], "1", "0", "0"}, {"1", RowBox[{"-", "2"}], "1", "0"}, {"0", "1", RowBox[{"-", "2"}], "1"}, {"0", "0", "1", RowBox[{"-", "2"}]} }], "\[NoBreak]", ")"}]]], ".", Cell[BoxData[ InterpretationBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"x"}, {"y"}, {"z"}, {"t"} }], "\[NoBreak]", ")"}], MatrixForm[{x, y, z, t}]]]], " = ", Cell[BoxData[ InterpretationBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"1"}, {"0"}, {"0"}, {"0"} }], "\[NoBreak]", ")"}], MatrixForm[{1, 0, 0, 0}]]]], "\nmediante el m\[EAcute]todo de Gauss-Seidel partiendo de la aproximaci\ \[OAcute]n inicial : ", Cell[BoxData[ InterpretationBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"0.7`"}, {"0.5`"}, {"0.3`"}, {"0.1`"} }], "\[NoBreak]", ")"}], MatrixForm[{0.7, 0.5, 0.3, 0.1}]]]], ". Comprobar la convergencia del m\[EAcute]todo." }], "Text", CellChangeTimes->{3.5063452041875*^9}], Cell[TextData[{ "4\.ba- Resolver el siguiente sistema mediante los m\[EAcute]todos de Jacobi \ y Gauss-Seidel para n=10, 50 y 100. Obtener las soluciones con un error menor \ que ", Cell[BoxData[ FormBox[ SuperscriptBox["10", RowBox[{"-", "3"}]], TraditionalForm]]], " utilizando la norma del m\[AAcute]ximo. Comparar el n\.ba de iteraciones \ requeridos por cada m\[EAcute]todo." }], "Text", CellChangeTimes->{3.506345204203125*^9}], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"(", GridBox[{ {"1", RowBox[{"-", FractionBox["1", "2"]}], "0", "0", ".", ".", "0"}, { RowBox[{"-", FractionBox["1", "2"]}], "1", RowBox[{"-", FractionBox["1", "2"]}], "0", ".", ".", "0"}, {"0", RowBox[{"-", FractionBox["1", "2"]}], "1", RowBox[{"-", FractionBox["1", "2"]}], "0", ".", "0"}, {".", ".", ".", ".", ".", ".", "."}, {".", ".", ".", ".", ".", ".", "."}, {"0", ".", ".", "0", RowBox[{"-", FractionBox["1", "2"]}], "1", RowBox[{"-", FractionBox["1", "2"]}]}, {"0", ".", ".", ".", "0", RowBox[{"-", FractionBox["1", "2"]}], "1"} }], ")"}], ".", RowBox[{"(", GridBox[{ { SubscriptBox["x", "1"]}, { SubscriptBox["x", "2"]}, { SubscriptBox["x", "3"]}, {"."}, {"."}, {"."}, {"."}, { SubscriptBox["x", RowBox[{"n", "-", "1"}]]}, { SubscriptBox["x", "n"]} }], ")"}]}], "=", " ", RowBox[{"(", GridBox[{ { FractionBox["1", "2"]}, {"0"}, {"0"}, {"."}, {"."}, {"."}, {"."}, {"0"}, {"0"} }], ")"}]}]], "Text", CellChangeTimes->{3.506345204203125*^9}], Cell["a) Jacobi", "Text", CellChangeTimes->{3.506345204203125*^9}], Cell["b) Gauss-Seidel", "Text", CellChangeTimes->{3.506345204203125*^9}] }, Open ]] }, Open ]] }, WindowToolbars->"EditBar", WindowSize->{1672, 933}, WindowMargins->{{0, Automatic}, {Automatic, 0}}, PrintingCopies->1, PrintingPageRange->{Automatic, Automatic}, Magnification->1.5, FrontEndVersion->"8.0 for Microsoft Windows (32-bit) (November 7, 2010)", StyleDefinitions->"Report.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{ "S3.7.8"->{ Cell[7360, 268, 171, 5, 69, "Input", CellTags->"S3.7.8"]}, "S3.9.6"->{ Cell[39268, 1381, 67, 1, 46, "Input", CellTags->"S3.9.6"], Cell[39338, 1384, 67, 1, 46, "Input", CellTags->"S3.9.6"]} } *) (*CellTagsIndex CellTagsIndex->{ {"S3.7.8", 48537, 1746}, {"S3.9.6", 48614, 1749} } *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[567, 22, 174, 6, 71, "Title"], Cell[CellGroupData[{ Cell[766, 32, 118, 1, 98, "Section"], Cell[887, 35, 2397, 99, 389, "Text"], Cell[3287, 136, 500, 19, 112, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[3824, 160, 120, 3, 98, "Section"], Cell[3947, 165, 1977, 45, 247, "Text"], Cell[5927, 212, 1430, 54, 122, "Text"], Cell[7360, 268, 171, 5, 69, "Input", CellTags->"S3.7.8"], Cell[7534, 275, 45, 0, 38, "Text"], Cell[7582, 277, 91, 2, 46, "Input"], Cell[7676, 281, 120, 3, 46, "Input"], Cell[7799, 286, 111, 3, 46, "Input"], Cell[7913, 291, 46, 0, 38, "Text"], Cell[7962, 293, 90, 2, 46, "Input"], Cell[8055, 297, 210, 8, 51, "Text"], Cell[8268, 307, 186, 6, 46, "Input"], Cell[8457, 315, 119, 3, 46, "Input"], Cell[8579, 320, 122, 3, 38, "Text"], Cell[8704, 325, 746, 25, 87, "Input"], Cell[9453, 352, 110, 3, 46, "Input"], Cell[9566, 357, 125, 3, 38, "Text"], Cell[9694, 362, 746, 25, 84, "Input"], Cell[10443, 389, 85, 2, 38, "Text"], Cell[10531, 393, 125, 3, 46, "Input"], Cell[10659, 398, 159, 5, 46, "Input"], Cell[10821, 405, 146, 4, 46, "Input"], Cell[10970, 411, 124, 3, 46, "Input"], Cell[11097, 416, 1060, 32, 168, "Text"], Cell[12160, 450, 478, 16, 46, "Input"], Cell[12641, 468, 249, 8, 46, "Input"], Cell[12893, 478, 93, 1, 74, "Input"], Cell[12989, 481, 93, 1, 74, "Input"], Cell[13085, 484, 361, 11, 129, "Text"], Cell[13449, 497, 87, 1, 74, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[13573, 503, 46, 0, 98, "Section"], Cell[13622, 505, 2099, 71, 209, "Text"], Cell[15724, 578, 898, 35, 99, "Text"], Cell[16625, 615, 407, 14, 46, "Input"], Cell[17035, 631, 278, 9, 46, "Input"], Cell[17316, 642, 1869, 53, 125, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[19222, 700, 97, 2, 98, "Section"], Cell[19322, 704, 2321, 73, 255, "Text"], Cell[21646, 779, 408, 14, 46, "Input"], Cell[22057, 795, 278, 9, 46, "Input"], Cell[22338, 806, 1869, 53, 125, "Input"], Cell[24210, 861, 3937, 133, 549, "Text"], Cell[28150, 996, 227, 5, 61, "Text"], Cell[28380, 1003, 337, 11, 46, "Input"], Cell[28720, 1016, 520, 17, 46, "Input"], Cell[29243, 1035, 507, 17, 46, "Input"], Cell[29753, 1054, 246, 10, 40, "Text"], Cell[30002, 1066, 225, 7, 46, "Input"], Cell[30230, 1075, 126, 3, 46, "Input"], Cell[30359, 1080, 254, 10, 40, "Text"], Cell[30616, 1092, 200, 6, 46, "Input"], Cell[30819, 1100, 126, 3, 46, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[30982, 1108, 122, 3, 98, "Section"], Cell[31107, 1113, 2904, 104, 322, "Text"], Cell[34014, 1219, 332, 11, 46, "Input"], Cell[34349, 1232, 444, 13, 46, "Input"], Cell[34796, 1247, 446, 13, 46, "Input"], Cell[35245, 1262, 88, 2, 46, "Input"], Cell[35336, 1266, 1106, 37, 49, "Input"], Cell[36445, 1305, 303, 8, 46, "Input"], Cell[36751, 1315, 145, 4, 46, "Input"], Cell[36899, 1321, 1347, 38, 101, "Input"], Cell[CellGroupData[{ Cell[38271, 1363, 41, 0, 57, "Subsection"], Cell[38315, 1365, 950, 14, 130, "Text"], Cell[39268, 1381, 67, 1, 46, "Input", CellTags->"S3.9.6"], Cell[39338, 1384, 67, 1, 46, "Input", CellTags->"S3.9.6"], Cell[39408, 1387, 89, 2, 38, "Text"], Cell[39500, 1391, 431, 14, 46, "Input"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[39980, 1411, 88, 2, 98, "Section"], Cell[40071, 1415, 1219, 37, 199, "Text"], Cell[41293, 1454, 778, 23, 101, "Input"], Cell[42074, 1479, 58, 1, 38, "Text"], Cell[42135, 1482, 58, 1, 38, "Text"], Cell[42196, 1485, 79, 1, 38, "Text"], Cell[42278, 1488, 1340, 56, 145, "Text"], Cell[43621, 1546, 1400, 56, 122, "Text"], Cell[45024, 1604, 1145, 46, 225, "Text"], Cell[46172, 1652, 447, 11, 63, "Text"], Cell[46622, 1665, 1342, 57, 235, "Text"], Cell[47967, 1724, 67, 1, 38, "Text"], Cell[48037, 1727, 73, 1, 38, "Text"] }, Open ]] }, Open ]] } ] *) (* End of internal cache information *)