(* Content-type: application/vnd.wolfram.mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 10.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 158, 7] NotebookDataLength[ 35081, 941] NotebookOptionsPosition[ 33087, 874] NotebookOutlinePosition[ 33445, 890] CellTagsIndexPosition[ 33402, 887] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell["Homework 1", "Section", CellChangeTimes->{{3.618884780257655*^9, 3.618884795191327*^9}, { 3.619013741815179*^9, 3.619013742915434*^9}}], Cell[CellGroupData[{ Cell[TextData[StyleBox["Problem 1.1", "Subsection"]], "Section", CellChangeTimes->{{3.6188834205755587`*^9, 3.618883429719199*^9}, { 3.618884597065878*^9, 3.618884597215721*^9}, {3.619056954579022*^9, 3.619056955327201*^9}, {3.69516226211022*^9, 3.6951622623406067`*^9}}], Cell[TextData[{ "In this exercise we will explore a simple application of the Plot[..] \ function. Consider four functions: \n", Cell[BoxData[ FormBox[ RowBox[{"sin", "(", "x", ")"}], TraditionalForm]]], ", ", Cell[BoxData[ FormBox[ RowBox[{"sin", "(", RowBox[{"x", "+", FractionBox["\[DoubledPi]", "5"]}], ")"}], TraditionalForm]], FormatType->"TraditionalForm"], ", ", Cell[BoxData[ FormBox[ RowBox[{"sin", "(", RowBox[{"x", "+", FractionBox[ RowBox[{"2", "\[DoubledPi]"}], "5"]}], ")"}], TraditionalForm]]], ", ", Cell[BoxData[ FormBox[ RowBox[{"sin", "(", RowBox[{"x", "+", FractionBox[ RowBox[{"3", "\[DoubledPi]"}], "5"]}], ")"}], TraditionalForm]]], " defined on the interval [0,6\[DoubledPi]]." }], "Text", CellChangeTimes->{ 3.618884689235755*^9, {3.6189578925440702`*^9, 3.6189578957037983`*^9}, { 3.694841137943267*^9, 3.6948412264856367`*^9}, {3.69516111711823*^9, 3.6951613312678328`*^9}, {3.695161398120516*^9, 3.6951614423734217`*^9}, { 3.695161562417849*^9, 3.695161698997789*^9}, {3.695162155855624*^9, 3.695162164504661*^9}, {3.695166169820051*^9, 3.695166192436297*^9}, { 3.6951735083830833`*^9, 3.6951735142766447`*^9}}, TextJustification->1.], Cell[CellGroupData[{ Cell[TextData[{ "Plot these functions together in the same plot, using the options ", StyleBox["PlotTheme\[RightArrow]\[CloseCurlyDoubleQuote]Business\ \[CloseCurlyDoubleQuote]", FontWeight->"Bold"], ", ", StyleBox["PlotLegends\[RightArrow]\[CloseCurlyDoubleQuote]Expressions\ \[CloseCurlyDoubleQuote]", FontWeight->"Bold"], ", and ", StyleBox["PlotLabel\[Rule]\[CloseCurlyDoubleQuote]Graph of the sin(x) \ function and its translates\[CloseCurlyDoubleQuote]", FontWeight->"Bold"], ". " }], "ItemNumbered", CellChangeTimes->{{3.695161719949911*^9, 3.695161791606864*^9}, { 3.695162170792368*^9, 3.695162194905374*^9}, {3.695182732562208*^9, 3.6951827568915253`*^9}}, FontSize->14], Cell[TextData[{ "Do a second plot of these functions, but this time choose your own styling \ options so that the even translations ", Cell[BoxData[ FormBox[ RowBox[{"sin", "(", RowBox[{"x", "+", RowBox[{"k", FractionBox["\[DoubledPi]", "5"]}]}], ")"}], TraditionalForm]]], ", k=0,2 are plotted in Black color, Thick lines, whereas the odd \ translations k=1,3 are plotted in Blue color, and Dashed lines. Include some \ appropriate PlotLegends as well." }], "ItemNumbered", CellChangeTimes->{{3.695161719949911*^9, 3.69516175537051*^9}, { 3.6951617952630253`*^9, 3.695161819219377*^9}, {3.6951619582907867`*^9, 3.695162132487656*^9}, {3.69516220446703*^9, 3.6951622054593477`*^9}, { 3.695166400792563*^9, 3.6951664259851007`*^9}}, FontSize->14] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[TextData[StyleBox["Problem 1.2", "Subsection"]], "Section", CellChangeTimes->{{3.61895751446417*^9, 3.61895752344552*^9}, { 3.695162274045678*^9, 3.6951622748535967`*^9}, {3.695175753680698*^9, 3.695175754142099*^9}, {3.69518267402122*^9, 3.695182674171712*^9}}], Cell[TextData[{ "In this exercise, we will explore 3D plots and Export options. Consider the \ curve in the plane defined parametrically by the following two equations: \n\ ", Cell[BoxData[ FormBox[ RowBox[{ RowBox[{ TagBox[GridBox[{ {"\[Piecewise]", GridBox[{ { RowBox[{ RowBox[{"x", "(", "t", ")"}], "=", RowBox[{"t", "+", RowBox[{"\[Alpha]", " ", RowBox[{"sin", "(", "t", ")"}]}]}]}], " "}, { RowBox[{ RowBox[{"y", "(", "t", ")"}], "=", RowBox[{ RowBox[{"-", "t"}], "-", RowBox[{"sin", "(", "t", ")"}]}]}], " "} }, AllowedDimensions->{2, Automatic}, Editable->True, GridBoxAlignment->{ "Columns" -> {{Left}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}}, GridBoxItemSize->{ "Columns" -> {{Automatic}}, "ColumnsIndexed" -> {}, "Rows" -> {{1.}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.84]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.4]}, Offset[0.2]}, "RowsIndexed" -> {}}, Selectable->True]} }, GridBoxAlignment->{ "Columns" -> {{Left}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}}, GridBoxItemSize->{ "Columns" -> {{Automatic}}, "ColumnsIndexed" -> {}, "Rows" -> {{1.}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.35]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.4]}, Offset[0.2]}, "RowsIndexed" -> {}}], "Piecewise", DeleteWithContents->True, Editable->False, SelectWithContents->True, Selectable->False], "t"}], "\[Element]", RowBox[{"[", RowBox[{ RowBox[{"-", "2"}], ",", "2"}], "]"}]}], TraditionalForm]], FormatType->"TraditionalForm"], ". The parameter \[Alpha] is an integer number between -5 and 3. " }], "Text", CellChangeTimes->CompressedData[" 1:eJxTTMoPSmViYGAQBmIQ/WJBadTcb68cb2y7UwqiJ+74VAmiXfnW1YBoHwZD l21Aeu306WD6a9pyXxBdsWlbAIg+sFQpCUT/CVFIBtEz/v04cxpIc+lUngXR u0pOqp0D0l23ObVBdFFO0vILQPpk+IZtIPrMrBU1x9tfO7YU3WsG0a86cnpB dM4WCF1y1nwiiH78Xmc6iD6y+d52EL3xINMOEH3lWsFlEL3SPu8miH6RLv0c RFuIKjKdANKPBFrYQLTcqhoeEK23/aD6HSB9+FiEJohu+7syAUS/YLRPBdGP +OLKvgFph8klVSB6h6dvBUPHa8dntwKqQDQA/Wi0JA== "]], Cell[CellGroupData[{ Cell[TextData[{ StyleBox["Consider first \[Alpha]=-5. Use ", "ItemNumbered", FontSize->14], StyleBox["RevolutionPlot3D[..]", "ItemNumbered", FontSize->14, FontWeight->"Bold"], StyleBox[", with the option ", "ItemNumbered", FontSize->14], StyleBox["RevolutionAxis\[RightArrow]{1,0,0}", "ItemNumbered", FontSize->14, FontWeight->"Bold"], StyleBox[", to plot the surface of revolution that results when the curve is \ rotated about the x-axis", "ItemNumbered", FontSize->14], StyleBox[".", "ItemNumbered", FontSize->14, FontWeight->"Bold"], StyleBox[" Use some extra options of ", "ItemNumbered", FontSize->14], StyleBox["RevolutionPlot3D[..] ", "ItemNumbered", FontSize->14, FontWeight->"Bold"], StyleBox[" like Axes, Boxed, ColorFunction, ImageSize, to hide the \ coordinate axes and the 3D bounding box, to set the ImageSize to 375x375 and \ choose a nice Color scheme. Use ", "ItemNumbered", FontSize->14], StyleBox["Export[..]", "ItemNumbered", FontSize->14, FontWeight->"Bold"], StyleBox[" to save the result 3D graphics as a ", "ItemNumbered", FontSize->14], StyleBox[".gif", "ItemNumbered", FontSize->14, FontWeight->"Bold", FontColor->RGBColor[0, 0, 1]], StyleBox[" file.", "ItemNumbered", FontSize->14] }], "ItemNumbered", CellChangeTimes->{{3.618957694098545*^9, 3.618957696151496*^9}, { 3.61895777225432*^9, 3.618957791835393*^9}, {3.618958746384242*^9, 3.618958746388254*^9}, {3.695067940632044*^9, 3.695067958008572*^9}, { 3.6950683030357103`*^9, 3.695068333411419*^9}, {3.695068364621194*^9, 3.6950685333234653`*^9}, {3.6950685836647167`*^9, 3.695068714493334*^9}, { 3.695069149111147*^9, 3.6950691928872023`*^9}, 3.6951066076402597`*^9, { 3.695107519480056*^9, 3.695107520070919*^9}, {3.695108239446127*^9, 3.6951082404131613`*^9}, {3.695108271849201*^9, 3.695108315986539*^9}, { 3.695108360148223*^9, 3.695108362075032*^9}, {3.695109990816869*^9, 3.695109990817284*^9}, {3.695110044924008*^9, 3.695110080276971*^9}, { 3.6951102800840273`*^9, 3.6951103560506363`*^9}, {3.6951104674723454`*^9, 3.6951104678709383`*^9}, {3.695162341543333*^9, 3.6951623981486073`*^9}, { 3.695542523128777*^9, 3.695542529638525*^9}}, TextJustification->1., FontSize->14], Cell[TextData[{ StyleBox["Take the picture obtained and include it in the Word document ", "ItemNumbered", FontSize->14], StyleBox["graphics.doc", "ItemNumbered", FontSize->14, FontColor->RGBColor[1, 0, 0]], StyleBox[" given in the archive ", "ItemNumbered", FontSize->14], StyleBox["HW1-Files.zip", "ItemNumbered", FontSize->14, FontWeight->"Bold"], StyleBox[".", "ItemNumbered", FontSize->14] }], "Subitem", CellChangeTimes->{{3.618957694098545*^9, 3.618957696151496*^9}, { 3.61895777225432*^9, 3.618957791835393*^9}, {3.618958746384242*^9, 3.618958746388254*^9}, {3.695067940632044*^9, 3.695067958008572*^9}, { 3.6950683030357103`*^9, 3.695068333411419*^9}, {3.695068364621194*^9, 3.6950685333234653`*^9}, {3.6950685836647167`*^9, 3.695068714493334*^9}, { 3.695069149111147*^9, 3.6950691928872023`*^9}, 3.6951066076402597`*^9, { 3.695107519480056*^9, 3.695107520070919*^9}, {3.695108239446127*^9, 3.6951082404131613`*^9}, {3.695108271849201*^9, 3.695108315986539*^9}, { 3.695108360148223*^9, 3.695108362075032*^9}, {3.695110036116486*^9, 3.695110038180256*^9}, {3.695110087180282*^9, 3.695110128909181*^9}, { 3.695110169862174*^9, 3.695110180582809*^9}, {3.695162424744953*^9, 3.695162425833111*^9}, {3.6951869199264803`*^9, 3.695186921460577*^9}, { 3.695186969398307*^9, 3.695187005485999*^9}, {3.695191080965488*^9, 3.695191087139063*^9}, {3.695192306728054*^9, 3.695192321214692*^9}, { 3.6951924107511387`*^9, 3.695192417991588*^9}, 3.6951936559518843`*^9}, TextJustification->1.], Cell[TextData[{ StyleBox["Use the command ", "ItemNumbered", FontSize->14], StyleBox["Table[...]", "ItemNumbered", FontSize->14, FontWeight->"Bold"], StyleBox[" and ", "ItemNumbered", FontSize->14], StyleBox["RevolutionPlot3D[..]", "ItemNumbered", FontSize->14, FontWeight->"Bold"], StyleBox[" to generate a list with the 3D plots corresponding to all integer \ values of the parameter \[Alpha] between -5 and 3. Use the ", "ItemNumbered", FontSize->14], StyleBox["Export[...]", "ItemNumbered", FontSize->14, FontWeight->"Bold"], StyleBox[" command to export the list to a", "ItemNumbered", FontSize->14], StyleBox[" .gif", "ItemNumbered", FontSize->14, FontWeight->"Bold", FontColor->RGBColor[0.5, 0, 0.5]], StyleBox[" file. You will obtain an animated gif, just as in the Lecture \ Notes.", "ItemNumbered", FontSize->14] }], "ItemNumbered", CellChangeTimes->{{3.618957694098545*^9, 3.618957696151496*^9}, { 3.61895777225432*^9, 3.618957791835393*^9}, {3.618958746384242*^9, 3.618958746388254*^9}, {3.695067940632044*^9, 3.695067958008572*^9}, { 3.6950683030357103`*^9, 3.695068333411419*^9}, {3.695068364621194*^9, 3.6950685333234653`*^9}, {3.6950685836647167`*^9, 3.695068714493334*^9}, { 3.695069149111147*^9, 3.6950691928872023`*^9}, 3.6951066076402597`*^9, { 3.695107519480056*^9, 3.695107520070919*^9}, {3.695108379821353*^9, 3.695108401549735*^9}, {3.695108464474568*^9, 3.695108483451542*^9}, { 3.6951085482821817`*^9, 3.695108854685652*^9}, {3.6951089173151817`*^9, 3.695108984095257*^9}, {3.6951102160970592`*^9, 3.6951102188323107`*^9}, { 3.6951755532910557`*^9, 3.6951755603374434`*^9}, {3.6951828466901703`*^9, 3.695182868217162*^9}, {3.695182956467147*^9, 3.6951829878105373`*^9}, { 3.695192447466861*^9, 3.695192459760851*^9}}, TextJustification->1.], Cell[TextData[{ StyleBox["Take the picture obtained in part 1 and the animated gif obtained \ in part 2 and include them in the HTML file ", "ItemNumbered", FontSize->14], StyleBox["webpage.html", "ItemNumbered", FontSize->14, FontColor->RGBColor[1, 0, 0]], StyleBox[" provided in the archive.", "ItemNumbered", FontSize->14] }], "Subitem", CellChangeTimes->{{3.618957694098545*^9, 3.618957696151496*^9}, { 3.61895777225432*^9, 3.618957791835393*^9}, {3.618958746384242*^9, 3.618958746388254*^9}, {3.695067940632044*^9, 3.695067958008572*^9}, { 3.6950683030357103`*^9, 3.695068333411419*^9}, {3.695068364621194*^9, 3.6950685333234653`*^9}, {3.6950685836647167`*^9, 3.695068714493334*^9}, { 3.695069149111147*^9, 3.6950691928872023`*^9}, 3.6951066076402597`*^9, { 3.695107519480056*^9, 3.695107520070919*^9}, {3.695108239446127*^9, 3.6951082404131613`*^9}, {3.695108271849201*^9, 3.695108315986539*^9}, { 3.695108360148223*^9, 3.695108362075032*^9}, {3.695110036116486*^9, 3.695110038180256*^9}, {3.695110087180282*^9, 3.695110164414012*^9}, { 3.695187022766471*^9, 3.695187031055971*^9}, {3.6951923642721653`*^9, 3.695192389918388*^9}, {3.6951924871667337`*^9, 3.6951924940850077`*^9}, 3.695193643846381*^9}] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[TextData[StyleBox["Problem 1.3", "Subsection"]], "Section", CellChangeTimes->{{3.6188834205755587`*^9, 3.618883429719199*^9}, { 3.618884597065878*^9, 3.618884597215721*^9}, {3.619056954579022*^9, 3.619056955327201*^9}, {3.69516226211022*^9, 3.6951622623406067`*^9}, { 3.695173429817556*^9, 3.6951734303123426`*^9}, {3.695182677811944*^9, 3.6951826781799803`*^9}}], Cell[TextData[{ "In this exercise we will approximate a periodic function of period 2\ \[DoubledPi] with a trigonometric series in terms of sin(nx) and cos(nx), \ called a Fourier Series. Some details on Fourier series are given in the \ auxiliary file ", StyleBox["fourier.pdf", FontColor->RGBColor[1, 0, 0]], ". We will not discuss the mathematical basis of Fourier Series, as this \ is/will be discussed in depth in other math and physics classes, but for the \ purpose of this homework we assume that we can write\nf(x)=", Cell[BoxData[ FormBox[ FractionBox[ StyleBox[ SubscriptBox["a", "0"], FontSize->12], StyleBox["2", FontSize->12]], TraditionalForm]]], "+", Cell[BoxData[ FormBox[ RowBox[{ RowBox[{ StyleBox[ UnderoverscriptBox[ RowBox[{" ", "\[Sum]"}], RowBox[{" ", RowBox[{"n", "=", "1"}]}], StyleBox[ RowBox[{" ", "\[Infinity]"}], FontSize->12]], FontSize->18], StyleBox[" ", FontSize->18], StyleBox[ SubscriptBox["a", "n"], FontSize->14], StyleBox[ RowBox[{"cos", "(", "nx", ")"}], FontSize->14]}], StyleBox[" ", FontSize->14], StyleBox["+", FontSize->14], StyleBox[" ", FontSize->14], RowBox[{ StyleBox[ SubscriptBox["b", "n"], FontSize->14], StyleBox[ RowBox[{"sin", "(", "nx", ")"}], FontSize->14], StyleBox[" ", FontSize->16]}]}], TraditionalForm]], FormatType->"TraditionalForm"], "\n =", Cell[BoxData[ FormBox[ RowBox[{ RowBox[{ FractionBox[ StyleBox[ SubscriptBox["a", "0"], FontSize->12], StyleBox["2", FontSize->12]], " ", "+", " ", RowBox[{ SubscriptBox["a", "1"], RowBox[{"cos", "(", "x", ")"}]}], " ", "+", " ", RowBox[{ SubscriptBox["b", "1"], RowBox[{"sin", "(", "x", ")"}]}], " ", "+", RowBox[{ SubscriptBox["a", "2"], RowBox[{"cos", "(", RowBox[{"2", "x"}], ")"}]}], " ", "+", RowBox[{ SubscriptBox["b", "2"], RowBox[{"sin", "(", RowBox[{"2", "x"}], ")"}]}], " ", "+", " ", RowBox[{ SubscriptBox["a", "3"], RowBox[{"cos", "(", RowBox[{"3", "x"}], ")"}]}], " ", "+", " ", RowBox[{ SubscriptBox["b", "3"], RowBox[{"sin", "(", RowBox[{"3", "x"}], ")"}]}], "+"}], " ", "..."}], TraditionalForm]]], "\nand that the coefficients are given by the formulas\n", Cell[BoxData[ FormBox[ RowBox[{ SubscriptBox["a", "n"], " ", "=", " ", RowBox[{ StyleBox[ FractionBox["1", "\[Pi]"], FontSize->16], RowBox[{ SubsuperscriptBox["\[Integral]", RowBox[{"-", "\[Pi]"}], "\[Pi]"], RowBox[{ RowBox[{"f", "(", "x", ")"}], RowBox[{"cos", "(", "nx", ")"}], RowBox[{"\[DifferentialD]", "x"}]}]}]}]}], TraditionalForm]]], "\n", Cell[BoxData[ FormBox[ RowBox[{ SubscriptBox["b", "n"], " ", "=", " ", RowBox[{ StyleBox[ FractionBox["1", "\[Pi]"], FontSize->16], RowBox[{ SubsuperscriptBox["\[Integral]", RowBox[{"-", "\[Pi]"}], "\[Pi]"], RowBox[{ RowBox[{"f", "(", "x", ")"}], RowBox[{"sin", "(", "nx", ")"}], RowBox[{"\[DifferentialD]", "x"}]}]}]}]}], TraditionalForm]]], "\nThis approximation is valid in the range ", StyleBox["[-\[Pi] , \[Pi]", FontSize->12], "]. " }], "Text", CellChangeTimes->{{3.695173535858871*^9, 3.695173681933921*^9}, { 3.6951737430489483`*^9, 3.6951738179038486`*^9}, {3.695173967330347*^9, 3.695174007271933*^9}, {3.695174365137442*^9, 3.695174610387104*^9}, 3.695174757130855*^9, 3.6951756096566887`*^9, {3.695175675442919*^9, 3.695175733580065*^9}, {3.695179798908803*^9, 3.695179824274747*^9}, { 3.695182551984232*^9, 3.695182556903696*^9}, {3.695188277983436*^9, 3.6951882824287453`*^9}, {3.695189608978565*^9, 3.695189730039653*^9}, { 3.6951898384243526`*^9, 3.695189843479906*^9}, {3.695192536085279*^9, 3.695192536925743*^9}}, TextJustification->1.], Cell[TextData[{ "Define the coefficients ", Cell[BoxData[ FormBox[ SubscriptBox["a", "n"], TraditionalForm]]], " and ", Cell[BoxData[ FormBox[ SubscriptBox["b", "n"], TraditionalForm]]], " as functions of f and n, so that you can use the coefficients later \ several times. For your convenience, the definition of ", Cell[BoxData[ FormBox[ SubscriptBox["a", "n"], TraditionalForm]]], " is already given below, as a model." }], "ItemNumbered", CellChangeTimes->{{3.6951746399146547`*^9, 3.695174684768199*^9}, { 3.695175792295216*^9, 3.695175835334158*^9}, {3.695179840586649*^9, 3.695179850098699*^9}, {3.695194036266981*^9, 3.695194050827203*^9}}, FontSize->14], Cell[BoxData[{ RowBox[{ RowBox[{"Clear", "[", RowBox[{"x", ",", "t", ",", " ", "n", ",", "f", ",", "a", ",", "b"}], "]"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"a", "[", RowBox[{"n_", ",", "f_"}], "]"}], ":=", RowBox[{ RowBox[{"1", "/", "\[Pi]"}], "*", RowBox[{"Integrate", "[", RowBox[{ RowBox[{ RowBox[{"f", "[", "t", "]"}], "*", RowBox[{"Cos", "[", RowBox[{"n", " ", "t"}], "]"}]}], ",", RowBox[{"{", RowBox[{"t", ",", RowBox[{"-", "\[Pi]"}], ",", "\[Pi]"}], "}"}]}], "]"}]}]}]}], "Input", CellChangeTimes->{{3.695175331224265*^9, 3.695175365547555*^9}, { 3.695179856756995*^9, 3.6951798639008217`*^9}}, Background->GrayLevel[0.85]], Cell[CellGroupData[{ Cell[TextData[{ "Next declare a function ", StyleBox["myFourierApprox[n_, f_, x_ ]", FontWeight->"Bold"], " of the arguments n, f and x, which constructs the Fourier series \ approximation of the function f[x] up to and including the terms in ", Cell[BoxData[ FormBox[ RowBox[{ SubscriptBox["a", "n"], RowBox[{"cos", "(", "nx", ")"}]}], TraditionalForm]]], " and ", Cell[BoxData[ FormBox[ RowBox[{ SubscriptBox["b", "n"], RowBox[{"sin", "(", "nx", ")"}]}], TraditionalForm]]], ". Use your favorite Loop Sequence (Do While, For), or use Sum to add the \ first n terms of the Fourier series." }], "ItemNumbered", CellChangeTimes->{{3.6951746399146547`*^9, 3.6951747381386137`*^9}, { 3.695175072643417*^9, 3.695175153710937*^9}, {3.695175427425753*^9, 3.695175447842461*^9}, {3.695175880454298*^9, 3.695175978697241*^9}, { 3.695182527075514*^9, 3.6951825346702337`*^9}, {3.695193943954899*^9, 3.695193984375428*^9}, {3.6951940249893103`*^9, 3.695194028308633*^9}, { 3.695194070182457*^9, 3.695194097540036*^9}}, TextJustification->1., FontSize->14], Cell[TextData[{ "Then plot the function ", StyleBox["Sinh[x]", FontWeight->"Bold"], " and its Fourier Series with 20 and 50 terms in different colors in the \ range -\[Pi] \[LessEqual] x \[LessEqual] \[Pi]. When using the Plot function \ with the usual syntax, Plot[{f1[x],...f3[x]}, {x,-\[Pi],\[Pi]},...], you may \ need to use ", StyleBox["Evaluate[..", FontWeight->"Bold"], "] in the first argument, Plot[Evaluate[{f1[x],...f3[x]}], \ {x,-\[Pi],\[Pi]},...], so that you force the evaluation of the user-defined \ functions in the list before the sampling for the variable x takes place. \ Observe that the series with more terms is a better approximation but also \ oscillates wildly toward the end of the region." }], "ItemNumbered", CellChangeTimes->{{3.6951746399146547`*^9, 3.695174766618162*^9}, { 3.695174897378489*^9, 3.695174968745904*^9}, {3.695175648941044*^9, 3.6951756531496077`*^9}, {3.69517988831842*^9, 3.6951798969064817`*^9}, { 3.69517992929161*^9, 3.695179933954919*^9}, {3.695179967285425*^9, 3.6951802153062067`*^9}, {3.6951823034980593`*^9, 3.6951823594269457`*^9}, { 3.695182434817587*^9, 3.695182445057646*^9}, {3.69518305445789*^9, 3.695183060447382*^9}, {3.695183504420957*^9, 3.695183518183585*^9}}, TextJustification->1., FontSize->14], Cell[TextData[{ "Consider the piecewise function ", StyleBox["h[x] =", FontWeight->"Bold"], " 1 when 0\[LessEqual]x<\[Pi], and -1 when -\[Pi]{{3.6951746399146547`*^9, 3.695174766618162*^9}, { 3.695174897378489*^9, 3.695175055954554*^9}, {3.695175189572022*^9, 3.6951752263628893`*^9}, {3.69518238834391*^9, 3.6951824216649027`*^9}, { 3.6951830704316587`*^9, 3.69518308825597*^9}, {3.6951831227063417`*^9, 3.6951831388099003`*^9}, {3.695184605528886*^9, 3.695184609029996*^9}, { 3.6951941380126457`*^9, 3.69519415378865*^9}}, TextJustification->1., FontSize->14] }, Open ]], Cell[BoxData[ RowBox[{ RowBox[{"h", "[", "x_", "]"}], ":=", RowBox[{"If", "[", RowBox[{ RowBox[{"0", "<", "x", "\[LessEqual]", "Pi"}], ",", "1", ",", RowBox[{"-", "1"}]}], "]"}]}]], "Input", Background->GrayLevel[0.85]], Cell[TextData[{ "Save your pictures as ", StyleBox["pdf or eps", FontWeight->"Bold", FontColor->RGBColor[0, 0, 1]], " using ", StyleBox["Export[...]", FontWeight->"Bold"], " and include them in the ", Cell[BoxData[ FormBox[ StyleBox[ RowBox[{"L", StyleBox[ AdjustmentBox["A", BoxBaselineShift->-0.4, BoxMargins->{{-0.5, -0.3}, {0, 0}}], FontSize->Smaller], "T", AdjustmentBox["E", BoxBaselineShift->0.5, BoxMargins->{{-0.3, 0}, {0, 0}}], "X"}], SingleLetterItalics->False], TraditionalForm]]], " source file ", StyleBox["fourier.tex", FontColor->RGBColor[1, 0, 0]], " provided in the archive. Compile the source file with pdflatex to obtain a \ new pdf file, ", StyleBox["fourier.pdf", FontColor->RGBColor[1, 0, 0]], StyleBox[", which contains your pictures.", FontColor->GrayLevel[0]] }], "ItemNumbered", CellChangeTimes->{{3.6951746399146547`*^9, 3.695174766618162*^9}, { 3.695174897378489*^9, 3.695175055954554*^9}, {3.695175189572022*^9, 3.695175273729538*^9}, {3.6951870646018457`*^9, 3.695187069551649*^9}, { 3.695189862393515*^9, 3.695189938331333*^9}, {3.6951909401830587`*^9, 3.695190990503866*^9}, {3.6951911033858232`*^9, 3.695191110255679*^9}, { 3.695191161969615*^9, 3.695191178493559*^9}, {3.69519258979327*^9, 3.6951925929195833`*^9}, 3.695543012558694*^9}, FontSize->14] }, Open ]], Cell[CellGroupData[{ Cell[TextData[StyleBox["Problem 1.4", "Subsection"]], "Section", CellChangeTimes->{{3.6188834372387037`*^9, 3.618883440270814*^9}, { 3.618884618760844*^9, 3.618884619110783*^9}, {3.6189486900451593`*^9, 3.618948692316845*^9}, 3.6189488450714417`*^9, {3.619056958023197*^9, 3.6190569585670424`*^9}, {3.695175758206256*^9, 3.695175759046248*^9}}], Cell[CellGroupData[{ Cell[TextData[{ StyleBox["Demonstrate that two matrices do not commute in general, i.e. that \ AB \[NotEqual] BA, by defining two 5x5 random matrices using the function \ Table, computing both sides (AB and BA) and comparing the outputs using the \ function TrueQ[...] in ", FontSize->14], StyleBox["Mathematica", FontSize->14, FontSlant->"Italic"], StyleBox[". Of course, there exist matrices which do commute so you will \ have to choose your examples well. This means that you may have to generate \ several random 5x5 matrices, before you hit a pair for which AB \[NotEqual] \ BA", FontSize->14], StyleBox[".", FontSize->14, FontWeight->"Bold"] }], "ItemNumbered", CellChangeTimes->{{3.618957694098545*^9, 3.6189577044342546`*^9}, { 3.618958869513474*^9, 3.618958871180994*^9}, {3.619060647504238*^9, 3.6190606587274837`*^9}, {3.695111184412084*^9, 3.6951111951713676`*^9}, { 3.695162480152185*^9, 3.695162494518682*^9}, {3.695162603030859*^9, 3.6951626690784492`*^9}, 3.6951826267289267`*^9}, TextJustification->1.], Cell[TextData[{ StyleBox["Use free-form input to find some ", "ItemNumbered", FontSize->14], StyleBox["Mathematica", "ItemNumbered", FontSize->14, FontSlant->"Italic"], StyleBox[" functions which help you find the dimensions of a matrix which is \ not necessarily square (that is, the number of columns and rows).", "ItemNumbered", FontSize->14] }], "ItemNumbered", CellChangeTimes->{{3.618957694098545*^9, 3.618957696151496*^9}, { 3.61895777225432*^9, 3.618957791835393*^9}, {3.618958746384242*^9, 3.618958746388254*^9}, {3.695111368956594*^9, 3.6951113797638474`*^9}}, TextJustification->1.], Cell[TextData[StyleBox["Write a function g[A_,B_] that takes as input two \ matrices A and B (not necessarily square) and checks whether the number of \ columns of A is the same as the number of rows of B. If the dimensions match, \ then the function returns the product AB, otherwise it returns the message \ \[OpenCurlyDoubleQuote]Error, the matrices cannot be multiplied\ \[CloseCurlyDoubleQuote]. Test your function on a couple of matrices.", \ "ItemNumbered", FontSize->14]], "ItemNumbered", CellChangeTimes->{{3.618957694098545*^9, 3.6189577044342546`*^9}, { 3.618958869513474*^9, 3.618958871180994*^9}, {3.619060647504238*^9, 3.6190606587274837`*^9}, {3.695111184412084*^9, 3.6951111951713676`*^9}, { 3.695162480152185*^9, 3.695162494518682*^9}, {3.6951625799733753`*^9, 3.695162579973868*^9}}, TextJustification->1.] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[TextData[StyleBox["Problem 1.5", "Subsection"]], "Section", CellChangeTimes->{{3.6188834470493517`*^9, 3.618883458254191*^9}, { 3.6188841737965927`*^9, 3.618884177712782*^9}, {3.6188846295181627`*^9, 3.6188846297983932`*^9}, {3.619056965231044*^9, 3.619056965742797*^9}, { 3.69517576175065*^9, 3.695175762230324*^9}}], Cell[TextData[{ "Mathematica has built-in routines for finding the eigenvalues and \ eigenvectors (Real and Complex) of a numerical square matrix. If A is an n \ \[Times] n matrix, then the number \[Lambda] is an eigenvalue of A if there \ exists a non-zero vector x such that ", StyleBox["Ax=\[Lambda]x, ", FontWeight->"Bold"], "where \[Lambda] is a given Real or Complex number is called the eigenvalue, \ and x is called an eigenvector of A with corresponding eigenvalue \[Lambda]. \ There are at most n distinct eigenvalues of the matrix A, and at most n \ linearly independent eigenvectors with Real or Complex entries. " }], "Text", CellChangeTimes->{{3.6190083437795057`*^9, 3.619008619778887*^9}, { 3.6190086997717037`*^9, 3.619008742318366*^9}, {3.61900877337542*^9, 3.619008846690468*^9}}, TextJustification->1.], Cell[CellGroupData[{ Cell[TextData[{ "The function ", StyleBox["Eigenvalues[A]", FontWeight->"Bold"], " returns a list with the eigenvalues of the square matrix A." }], "SubitemNumbered", CellChangeTimes->{{3.6190088013472652`*^9, 3.619008812270844*^9}}], Cell[TextData[{ "Sometimes it is necessary to know the eigenvectors as well. This can be \ done using the function ", StyleBox["Eigensystem[A]", FontWeight->"Bold"], ", which finds both eigenvalues and a complete linearly independent set of \ eigenvectors for each eigenvalue. The output is given in the form: { list of \ eigenvalues, list of eigenvectors }" }], "SubitemNumbered", CellChangeTimes->{{3.6190088013472652`*^9, 3.6190088040492783`*^9}, { 3.619008890514189*^9, 3.619008903031351*^9}, {3.619009206270689*^9, 3.619009206278051*^9}, {3.695183205239089*^9, 3.69518326247499*^9}}, TextJustification->1.] }, Open ]], Cell[CellGroupData[{ Cell[TextData[{ "Generate a square nxn matrix ", Cell[BoxData[ FormBox["M", TraditionalForm]]], ", whose diagonal elements ", Cell[BoxData[ FormBox[ SubscriptBox["M", "ii"], TraditionalForm]]], "are equal to n-1 and the other elements ", Cell[BoxData[ FormBox[ SubscriptBox["M", "ij"], TraditionalForm]]], " i\[NotEqual]j are equal to 1. Test it for n=10." }], "ItemNumbered", CellChangeTimes->{{3.618958035675892*^9, 3.61895825489732*^9}, { 3.61895828758503*^9, 3.618958309439242*^9}, {3.6190090575312862`*^9, 3.619009060737265*^9}, {3.619009133231318*^9, 3.6190091577092857`*^9}, { 3.619009297082733*^9, 3.619009305010374*^9}, {3.6190531597810783`*^9, 3.619053163786626*^9}, {3.619057974295499*^9, 3.619058008308049*^9}, { 3.619063099075738*^9, 3.619063221510716*^9}, {3.695164650060021*^9, 3.695164653331562*^9}, {3.695183318867518*^9, 3.695183363369521*^9}, 3.6951846625751762`*^9}, FontSize->14], Cell["\<\ Use the function Eigensystem[...] to find the eigenvalues and a set of \ linearly independent eigenvectors for the matrix M that you defined in part \ I. \ \>", "ItemNumbered", CellChangeTimes->{{3.6190088013472652`*^9, 3.6190088040492783`*^9}, { 3.619008890514189*^9, 3.619008903031351*^9}, {3.619009206270689*^9, 3.619009290887557*^9}, {3.619009332446886*^9, 3.619009375283103*^9}, { 3.619058025603527*^9, 3.619058055890036*^9}, {3.695164712401284*^9, 3.6951647206804523`*^9}}, TextJustification->1., FontSize->14], Cell[TextData[{ "Define a matrix ", Cell[BoxData[ FormBox["P", TraditionalForm]]], " whose columns are the eigenvectors returned by the function \ Eigensystem[...]." }], "ItemNumbered", CellChangeTimes->{{3.6190088013472652`*^9, 3.6190088040492783`*^9}, { 3.619008890514189*^9, 3.619008903031351*^9}, {3.619009206270689*^9, 3.619009290887557*^9}, {3.619009332446886*^9, 3.6190093752761583`*^9}, { 3.6190095184372463`*^9, 3.619009590875495*^9}, {3.619011514672359*^9, 3.619011517866494*^9}, {3.6190571317603607`*^9, 3.6190571321278687`*^9}, { 3.6951639500851316`*^9, 3.695163968545232*^9}}, FontSize->14], Cell[TextData[{ "Compute the product ", Cell[BoxData[ FormBox[ RowBox[{ SuperscriptBox["P", RowBox[{"-", "1"}]], "M", " ", "P"}], TraditionalForm]]], " where ", Cell[BoxData[ FormBox[ SuperscriptBox["P", RowBox[{"-", "1"}]], TraditionalForm]]], "is the inverse of the matrix ", Cell[BoxData[ FormBox["P", TraditionalForm]]], ". What do you observe? Compare it to the Jordan canonical form obtained by \ using ", StyleBox["JordanDecomposition[M]", FontWeight->"Bold"], "." }], "ItemNumbered", CellChangeTimes->{{3.6190088013472652`*^9, 3.6190088040492783`*^9}, { 3.619008890514189*^9, 3.619008903031351*^9}, {3.619009206270689*^9, 3.619009290887557*^9}, {3.619009332446886*^9, 3.6190093752761583`*^9}, { 3.6190095184372463`*^9, 3.6190095998350067`*^9}, {3.619011430452867*^9, 3.619011453896764*^9}, {3.6190114879165707`*^9, 3.6190115066051693`*^9}, { 3.6190118498956423`*^9, 3.619011895903263*^9}, {3.619060390546603*^9, 3.619060390560342*^9}, {3.695163900514538*^9, 3.695163920912499*^9}, { 3.6951647294181757`*^9, 3.6951647688755293`*^9}, {3.69518339789431*^9, 3.695183401012624*^9}}, TextJustification->1., FontSize->14] }, Open ]] }, Open ]] }, WindowSize->{1267, 632}, WindowMargins->{{Automatic, 0}, {Automatic, 4}}, FrontEndVersion->"11.0 for Mac OS X x86 (32-bit, 64-bit Kernel) (September \ 21, 2016)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[558, 20, 144, 2, 64, "Section"], Cell[CellGroupData[{ Cell[727, 26, 277, 3, 41, "Section"], Cell[1007, 31, 1260, 36, 59, "Text"], Cell[CellGroupData[{ Cell[2292, 71, 700, 18, 45, "ItemNumbered"], Cell[2995, 91, 780, 17, 55, "ItemNumbered"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[3824, 114, 273, 3, 55, "Section"], Cell[4100, 119, 2769, 73, 71, "Text"], Cell[CellGroupData[{ Cell[6894, 196, 2260, 52, 62, "ItemNumbered"], Cell[9157, 250, 1558, 30, 26, "Subitem"], Cell[10718, 282, 1850, 41, 45, "ItemNumbered"], Cell[12571, 325, 1262, 22, 26, "Subitem"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[13882, 353, 379, 5, 55, "Section"], Cell[14264, 360, 4135, 135, 237, "Text"], Cell[18402, 497, 691, 19, 47, "ItemNumbered"], Cell[19096, 518, 730, 21, 70, "Input"], Cell[CellGroupData[{ Cell[19851, 543, 1097, 27, 47, "ItemNumbered"], Cell[20951, 572, 1292, 24, 79, "ItemNumbered"], Cell[22246, 598, 791, 15, 45, "ItemNumbered"] }, Open ]], Cell[23052, 616, 239, 7, 48, "Input"], Cell[23294, 625, 1395, 39, 48, "ItemNumbered"] }, Open ]], Cell[CellGroupData[{ Cell[24726, 669, 356, 4, 55, "Section"], Cell[CellGroupData[{ Cell[25107, 677, 1052, 23, 62, "ItemNumbered"], Cell[26162, 702, 614, 14, 29, "ItemNumbered"], Cell[26779, 718, 838, 13, 45, "ItemNumbered"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[27666, 737, 330, 4, 55, "Section"], Cell[27999, 743, 834, 15, 68, "Text"], Cell[CellGroupData[{ Cell[28858, 762, 239, 6, 24, "SubitemNumbered"], Cell[29100, 770, 623, 12, 41, "SubitemNumbered"] }, Open ]], Cell[CellGroupData[{ Cell[29760, 787, 946, 22, 32, "ItemNumbered"], Cell[30709, 811, 539, 11, 28, "ItemNumbered"], Cell[31251, 824, 622, 13, 29, "ItemNumbered"], Cell[31876, 839, 1183, 31, 30, "ItemNumbered"] }, Open ]] }, Open ]] } ] *)