(* 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[ 10810, 335] NotebookOptionsPosition[ 9555, 284] NotebookOutlinePosition[ 9934, 301] CellTagsIndexPosition[ 9891, 298] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell["\<\ C\[AAcute]lculo de normas de vectores e matrizes\ \>", "Subsection", CellChangeTimes->{{3.5280962724434147`*^9, 3.528096302945957*^9}}], Cell[CellGroupData[{ Cell["Normas vectoriais", "Subsubsection", CellChangeTimes->{{3.52809630901287*^9, 3.528096320490118*^9}}], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"NormaVec", "[", RowBox[{"x_", ",", "norma_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"i", ",", "n"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ RowBox[{ RowBox[{"norma", " ", "euclideana"}], " ", "=", " ", "2"}], ",", " ", RowBox[{ RowBox[{"norma", " ", "1"}], " ", "=", " ", "1"}], ",", " ", RowBox[{ RowBox[{"norma", " ", "infinito"}], " ", "=", " ", "0"}]}], "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"n", "=", RowBox[{"Length", "[", "x", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Which", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"norma", "\[Equal]", "2"}], ",", "\[IndentingNewLine]", RowBox[{"Sqrt", "[", RowBox[{"Sum", "[", RowBox[{ RowBox[{ RowBox[{"x", "[", RowBox[{"[", "i", "]"}], "]"}], "^", "2"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "n"}], "}"}]}], "]"}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"norma", "\[Equal]", "1"}], ",", "\[IndentingNewLine]", RowBox[{"Sum", "[", RowBox[{ RowBox[{"Abs", "[", RowBox[{"x", "[", RowBox[{"[", "i", "]"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "n"}], "}"}]}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"norma", "\[Equal]", "0"}], ",", "\[IndentingNewLine]", RowBox[{"Max", "[", RowBox[{"Abs", "[", "x", "]"}], "]"}], ",", "\[IndentingNewLine]", "True", ",", RowBox[{"(*", " ", RowBox[{ RowBox[{ RowBox[{"se", " ", "'"}], RowBox[{"norma", "'"}], " ", "n\[ATilde]o", " ", "tiver", " ", "um", " ", "dos", " ", "valores", " ", "preistos"}], ",", " ", RowBox[{ "\[EAcute]", " ", "calculada", " ", "a", " ", "norma", " ", "euclideana"}]}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{"Sqrt", "[", RowBox[{"Sum", "[", RowBox[{ RowBox[{ RowBox[{"x", "[", RowBox[{"[", "i", "]"}], "]"}], "^", "2"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "n"}], "}"}]}], "]"}], "]"}]}], "\[IndentingNewLine]", "]"}]}]}], "\[IndentingNewLine]", "]"}]}], ";"}]], "Input", CellChangeTimes->{{3.527512155100624*^9, 3.5275122659388185`*^9}, 3.5275139306653376`*^9, {3.5275139979159513`*^9, 3.527514107254746*^9}, { 3.527514209663727*^9, 3.527514239014442*^9}, {3.5275142972077827`*^9, 3.5275143043112135`*^9}, {3.5280960035185623`*^9, 3.5280960106606073`*^9}, {3.528096114013969*^9, 3.5280962137694807`*^9}, 3.528096267786429*^9, 3.528096326346018*^9, 3.528096417013751*^9, { 3.5280964677901173`*^9, 3.528096485765684*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["Exemplos : ", "Subsubsection", CellChangeTimes->{{3.528096336348186*^9, 3.528096351195806*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"NormaVec", "[", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "2", ",", "3"}], "}"}], ",", "0"}], "]"}]], "Input", CellChangeTimes->{{3.527514121673732*^9, 3.527514146720504*^9}, { 3.528096225174659*^9, 3.528096246957889*^9}}], Cell[BoxData["3"], "Output", CellChangeTimes->{ 3.527514147916907*^9, 3.527514247451413*^9, 3.5275143085016146`*^9, { 3.528096222419362*^9, 3.528096247444743*^9}}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"NormaVec", "[", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "2", ",", "3"}], "}"}], ",", "2"}], "]"}]], "Input", CellChangeTimes->{{3.5275141569753857`*^9, 3.5275141572084513`*^9}}], Cell[BoxData[ SqrtBox["14"]], "Output", CellChangeTimes->{3.527514158063025*^9, 3.527514309373966*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"NormaVec", "[", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "2", ",", "3"}], "}"}], ",", "1"}], "]"}]], "Input", CellChangeTimes->{{3.5275141641538033`*^9, 3.527514164278105*^9}}], Cell[BoxData["6"], "Output", CellChangeTimes->{3.5275141647597733`*^9, 3.5275143109940467`*^9}] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Normas matriciais", "Subsubsection", CellChangeTimes->{{3.5280963657438917`*^9, 3.5280963767313347`*^9}}], Cell[BoxData[ RowBox[{"\[IndentingNewLine]", RowBox[{ RowBox[{"NormaMat", "[", RowBox[{"A_", ",", "norma_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"i", ",", "j", ",", "n"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ "Pressupomos", " ", "que", " ", "a", " ", "matriz", " ", "A", " ", "\[EAcute]", " ", "quadrada"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ RowBox[{ RowBox[{"norma", " ", "1"}], " ", "=", " ", "1"}], ",", " ", RowBox[{ RowBox[{"norma", " ", "infinito"}], " ", "=", " ", "0"}]}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ RowBox[{ "Se", " ", "for", " ", "indicado", " ", "um", " ", "valor", " ", "nao", " ", "previsto", " ", RowBox[{"para", " ", "'"}], RowBox[{"norma", "'"}]}], ",", " ", RowBox[{"calcula", " ", "a", " ", "norma", " ", "1"}]}], "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"n", "=", RowBox[{"Length", "[", "A", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Which", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"norma", "\[Equal]", "0"}], ",", "\[IndentingNewLine]", RowBox[{"Max", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"Sum", "[", RowBox[{ RowBox[{"Abs", "[", RowBox[{"A", "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", "n"}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "n"}], "}"}]}], "]"}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"norma", "\[Equal]", "1"}], ",", "\[IndentingNewLine]", RowBox[{"Max", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"Sum", "[", RowBox[{ RowBox[{"Abs", "[", RowBox[{"A", "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "n"}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", "n"}], "}"}]}], "]"}], "]"}], ",", "\[IndentingNewLine]", "True", ",", "\[IndentingNewLine]", RowBox[{"Max", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"Sum", "[", RowBox[{ RowBox[{"Abs", "[", RowBox[{"A", "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "n"}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", "n"}], "}"}]}], "]"}], "]"}]}], "\[IndentingNewLine]", "]"}]}]}], "\[IndentingNewLine]", "]"}]}]}]], "Input", CellChangeTimes->{{3.528096380957693*^9, 3.528096463516179*^9}, { 3.528096493956602*^9, 3.5280965726107273`*^9}, {3.528096720999529*^9, 3.528096873393529*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["Exemplos : ", "Subsubsection", CellChangeTimes->{{3.528097001297163*^9, 3.528097009293283*^9}}], Cell[CellGroupData[{ Cell[BoxData[{ RowBox[{ RowBox[{"A", "=", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "2", ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{"4", ",", "5", ",", "6"}], "}"}], ",", RowBox[{"{", RowBox[{"7", ",", "8", ",", "9"}], "}"}]}], "}"}]}], ";"}], "\[IndentingNewLine]", RowBox[{"NormaMat", "[", RowBox[{"A", ",", "0"}], "]"}]}], "Input", CellChangeTimes->{{3.528096885493917*^9, 3.528096946860071*^9}}], Cell[BoxData["24"], "Output", CellChangeTimes->{3.5280969480023518`*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"NormaMat", "[", RowBox[{"A", ",", "1"}], "]"}]], "Input", CellChangeTimes->{{3.528096954830147*^9, 3.528096954942665*^9}}], Cell[BoxData["18"], "Output", CellChangeTimes->{3.528096955150515*^9}] }, Open ]] }, Open ]] }, Open ]] }, WindowSize->{1262, 862}, WindowMargins->{{Automatic, 29}, {Automatic, 0}}, ShowSelection->True, Magnification->1.25, 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, 146, 3, 47, "Subsection"], Cell[CellGroupData[{ Cell[750, 29, 107, 1, 33, "Subsubsection"], Cell[860, 32, 2988, 71, 336, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[3885, 108, 102, 1, 33, "Subsubsection"], Cell[CellGroupData[{ Cell[4012, 113, 258, 6, 36, "Input"], Cell[4273, 121, 169, 3, 36, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[4479, 129, 213, 5, 36, "Input"], Cell[4695, 136, 104, 2, 40, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[4836, 143, 211, 5, 36, "Input"], Cell[5050, 150, 96, 1, 36, "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[5195, 157, 112, 1, 33, "Subsubsection"], Cell[5310, 160, 3233, 81, 359, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[8580, 246, 102, 1, 33, "Subsubsection"], Cell[CellGroupData[{ Cell[8707, 251, 471, 14, 60, "Input"], Cell[9181, 267, 73, 1, 36, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[9291, 273, 150, 3, 36, "Input"], Cell[9444, 278, 71, 1, 36, "Output"] }, Open ]] }, Open ]] }, Open ]] } ] *) (* End of internal cache information *)