(*********************************************************************** Mathematica-Compatible Notebook This notebook can be used on any computer system with Mathematica 3.0, MathReader 3.0, or any compatible application. The data for the notebook starts with the line of stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. ***********************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 5088, 134]*) (*NotebookOutlinePosition[ 6082, 168]*) (* CellTagsIndexPosition[ 6038, 164]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell[TextData["\nDiscrete waves "], "Title", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[ "\nThe plan is to solve F=ma for a bunch\nof masses connected by springs"], "Subtitle", Evaluatable->False, AspectRatioFixed->True], Cell[BoxData[{ \(\(n = 15; \)\), \(\(mass = Table[1., {i, n}]; \)\), \(\(stif = Table[1., {i, n}]; \)\), \(\(nt = 200; \)\)}], "Input", AspectRatioFixed->True], Cell[TextData[{ "\n", StyleBox[ "The following code is just a finite difference \nto the time derivative \ appearing in Newtons second\nlaw of motion. The details are unimportant, \ it's simply a way of handling the time derivatives.", FontSize->18] }], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[BoxData[{ \(\(x = Table[0., {i, nt}, {j, n}]; \)\), \(\(y = Table[0., {i, nt}, {j, n}]; \)\), \(\(x\[LeftDoubleBracket]1, 2\[RightDoubleBracket] = 1.; \)\), \(\(dt = .25; \)\), \(\(Do[ Do[x\[LeftDoubleBracket]2, i\[RightDoubleBracket] = x\[LeftDoubleBracket]1, i\[RightDoubleBracket]; \(y\[LeftDoubleBracket]2, i\[RightDoubleBracket] = dt\ \((\(-\(( stif\[LeftDoubleBracket]i + 1\[RightDoubleBracket] + stif\[LeftDoubleBracket]i\[RightDoubleBracket])\)\)\ x\[LeftDoubleBracket]1, i\[RightDoubleBracket] + stif\[LeftDoubleBracket]i\[RightDoubleBracket]\ x\[LeftDoubleBracket]1, i - 1\[RightDoubleBracket] + stif\[LeftDoubleBracket]i + 1\[RightDoubleBracket]\ x\[LeftDoubleBracket]1, i + 1\[RightDoubleBracket])\); \), {i, 2, n - 1}]; x\[LeftDoubleBracket]k, n\[RightDoubleBracket] = 0; x\[LeftDoubleBracket]k, 1\[RightDoubleBracket] = 0; Do[x\[LeftDoubleBracket]k + 1, i\[RightDoubleBracket] = dt\ y\[LeftDoubleBracket]k, i\[RightDoubleBracket] + x\[LeftDoubleBracket]k - 1, i\[RightDoubleBracket]; \(y\[LeftDoubleBracket]k + 1, i\[RightDoubleBracket] = dt\ \((\(-\((stif\[LeftDoubleBracket]i + 1\[RightDoubleBracket] + stif\[LeftDoubleBracket]i\[RightDoubleBracket]) \)\)\ x\[LeftDoubleBracket]k, i \[RightDoubleBracket] + stif\[LeftDoubleBracket]i\[RightDoubleBracket]\ x\[LeftDoubleBracket]k, i - 1\[RightDoubleBracket] + stif\[LeftDoubleBracket]i + 1\[RightDoubleBracket]\ x\[LeftDoubleBracket]k, i + 1\[RightDoubleBracket])\) + y\[LeftDoubleBracket]k - 1, i\[RightDoubleBracket]; \), {i, 2, n - 1}]; x\[LeftDoubleBracket]k, n\[RightDoubleBracket] = 0; \(x\[LeftDoubleBracket]k, 1\[RightDoubleBracket] = 0; \), {k, 2, nt - 1}]; \)\)}], "Input", AspectRatioFixed->True], Cell[TextData[ "\nNow plot all the snapshots (or change nt to something\nelse to plot some \ subset)"], "Text", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Times", FontSize->18], Cell[BoxData[ \(\(Do[ \(ListPlot[x\[LeftDoubleBracket]i\[RightDoubleBracket], PlotJoined \[Rule] True, PlotRange \[Rule] {{1, n}, {\(-1\), 1}}]; \), {i, 1, nt - 2}]; \)\)], "Input", AspectRatioFixed->True] }, Open ]] }, FrontEndVersion->"X 3.0", ScreenRectangle->{{0, 1600}, {0, 1200}}, WindowToolbars->{}, CellGrouping->Automatic, WindowSize->{520, 600}, WindowMargins->{{344, Automatic}, {Automatic, 126}}, PrintingPageRange->{Automatic, Automatic}, PrintingOptions->{"PaperSize"->{612, 792}, "PaperOrientation"->"Portrait", "Magnification"->1}, PrivateNotebookOptions->{"ColorPalette"->{RGBColor, 128}}, ShowCellLabel->True, ShowCellTags->False, RenderingOptions->{"ObjectDithering"->True, "RasterDithering"->False} ] (*********************************************************************** Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. ***********************************************************************) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[1731, 51, 92, 2, 154, "Title"], Cell[1826, 55, 153, 4, 112, "Subtitle"], Cell[1982, 61, 180, 5, 75, "Input"], Cell[2165, 68, 320, 9, 124, "Text"], Cell[2488, 79, 2147, 37, 235, "Input"], Cell[4638, 118, 198, 6, 83, "Text"], Cell[4839, 126, 233, 5, 59, "Input"] }, Open ]] } ] *) (*********************************************************************** End of Mathematica Notebook file. ***********************************************************************)