(*^ ::[ Information = "This is a Mathematica Notebook file. It contains ASCII text, and can be transferred by email, ftp, or other text-file transfer utility. It should be read or edited using a copy of Mathematica or MathReader. If you received this as email, use your mail application or copy/paste to save everything from the line containing (*^ down to the line containing ^*) into a plain text file. On some systems you may have to give the file a name ending with ".ma" to allow Mathematica to recognize it as a Notebook. The line below identifies what version of Mathematica created this file, but it can be opened using any other version as well."; FrontEndVersion = "Macintosh Mathematica Notebook Front End Version 2.2"; MacintoshStandardFontEncoding; fontset = title, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, e8, 24, "Times"; fontset = subtitle, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, e6, 18, "Times"; fontset = subsubtitle, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, italic, e6, 14, "Times"; fontset = section, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, grayBox, M22, bold, a20, 18, "Times"; fontset = subsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, blackBox, M19, bold, a15, 14, "Times"; fontset = subsubsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, whiteBox, M18, bold, a12, 12, "Times"; fontset = text, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; fontset = smalltext, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 10, "Times"; fontset = input, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeInput, M42, N23, bold, L-1, 12, "Courier"; fontset = output, output, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L-1, 12, "Courier"; fontset = message, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, R32768, L-1, 12, "Courier"; fontset = print, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L-1, 12, "Courier"; fontset = info, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, B32768, L-1, 12, "Courier"; fontset = postscript, PostScript, formatAsPostScript, output, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeGraphics, M7, l34, w282, h287, 12, "Courier"; fontset = name, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, italic, 10, "Geneva"; fontset = header, inactive, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; fontset = leftheader, inactive, L2, 12, "Times"; fontset = footer, inactive, noKeepOnOnePage, preserveAspect, center, M7, 12, "Times"; fontset = leftfooter, inactive, L2, 12, "Times"; fontset = help, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 10, "Times"; fontset = clipboard, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; fontset = completions, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; fontset = special1, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; fontset = special2, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; fontset = special3, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; fontset = special4, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; fontset = special5, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; paletteColors = 128; currentKernel; ] :[font = title; inactive; preserveAspect] Linear Methods of Applied Mathematics Linear Equations and Linear Operators ;[s] 3:0,1;38,2;39,1;77,-1; 3:0,25,18,Times,1,24,0,0,0;2,24,17,Times,1,23,0,0,0;1,12,8,Times,1,11,0,0,0; :[font = text; inactive; preserveAspect; plain; bold] (c) Copyright 1994-1997 by Evans M. Harrell II and James V. Herod. All rights reserved. :[font = text; inactive; Cclosed; preserveAspect; plain; bold; startGroup] Notes for the instructor. ;[s] 2:0,1;25,0;26,-1; 2:1,13,9,Times,1,12,0,0,0;1,11,8,Times,1,9,0,0,0; :[font = text; inactive; preserveAspect; fontSize = 14; endGroup] This contains calculations and examples which correlate with chapter 6 of the WWW text by Harrell and Herod. Students can be encouraged to cut and paste from this notebook to do homework. :[font = subsubsection; inactive; Cclosed; preserveAspect; startGroup] Instructions :[font = text; inactive; preserveAspect; endGroup] This notebook uses Mathematica to perform calculations for Harrell and Herod's hypertext book, Linear Methods of Applied Mathematics. The student needs only a basic knowledge of Mathematica to use the notebook, which is designed both to show how to work problems in the text and to provide a template for using Mathematica to work other problems of the student's own design. Calculations will be performed when the reader presses enter in a given calculation cell (bold print). It is best to activate the cells in order, so that Mathematica will be able to call on operators and functions defined in earlier cells. Red color coding is used to warn the reader when a given calculation relies on an earlier one. ;[s] 13:0,0;19,1;30,0;96,1;133,0;181,1;192,0;315,1;326,0;538,1;549,0;626,2;642,0;721,-1; 3:7,13,9,Times,0,12,0,0,0;5,13,9,Times,2,12,0,0,0;1,13,9,Times,0,12,65535,0,0; :[font = section; inactive; Cclosed; preserveAspect; startGroup] Defining differential operators with Mathematica. ;[s] 3:0,0;37,1;48,0;50,-1; 2:2,19,14,Times,1,18,0,0,0;1,19,14,Times,3,18,0,0,0; :[font = text; inactive; preserveAspect; fontSize = 14] A convenient way to set up differential operators in Mathematica is to define them with the variable being a function name - without the variable [x]. When the operator is applied, be sure to apply it to u[x] with the variable written explicitly. The operator of eq. (1.1) can be defined as follows: :[font = input; preserveAspect] A[u_] := D[u,{x,2}] + D[u,x] + 2 u :[font = text; inactive; preserveAspect; fontSize = 14] To test it, activate the following cell: :[font = input; preserveAspect; endGroup] A[u[x]] ;[s] 2:0,1;1,0;8,-1; 2:1,12,10,Courier,1,12,0,0,0;1,12,10,Courier,1,12,65535,0,0; :[font = section; inactive; Cclosed; preserveAspect; startGroup] Linear operators and matrices :[font = text; inactive; Cclosed; preserveAspect; fontSize = 14; startGroup] In the text, we make an analogy between linear operators and matrices. Open these cells to review the notion of a null space of a matrix :[font = text; inactive; preserveAspect; fontSize = 14] Mathematica defines a vector as a list of numbers, enclosed in braces {...}. A matrix, like the one of eq. (1.2), is a list of lists. Since lists are enclosed in braces, there are two layers of braces: ;[s] 3:0,0;1,1;12,0;205,-1; 2:2,16,12,Times,0,14,0,0,0;1,16,12,Times,2,14,0,0,0; :[font = input; preserveAspect] MM := {{1,-2,1},{1,-2,1},{1,-2,1}} :[font = input; preserveAspect] v := {x,y,z} :[font = text; inactive; preserveAspect; fontSize = 14] The null space of a matrix is the set of vectors which the matrix sends to 0. To solve for the null space, we can use the Solve command: ;[s] 3:0,0;123,1;128,0;139,-1; 2:2,16,12,Times,0,14,0,0,0;1,15,11,Courier,0,14,0,0,0; :[font = input; preserveAspect] Solve[MM.v == {0,0,0}, v] ;[s] 3:0,0;6,1;10,0;26,-1; 2:2,12,10,Courier,1,12,0,0,0;1,12,10,Courier,1,12,65535,0,0; :[font = text; inactive; preserveAspect; fontSize = 14] Alternatively, there is a built-in command for finding the null space: :[font = input; preserveAspect] NullSpace[MM] ;[s] 3:0,0;10,1;12,0;14,-1; 2:2,12,10,Courier,1,12,0,0,0;1,12,10,Courier,1,12,65535,0,0; :[font = text; inactive; preserveAspect; fontSize = 14] Notice that Solve gives a relationship among the components of a vector in the null space, but NullSpace produces something else, namely a basis for the previous output. In order to check, we use the following syntax, where % refers to the previous calculation and you need [[...]] to select an entry in a double list {{...}}. ;[s] 6:0,0;12,2;17,0;95,1;96,2;105,0;331,-1; 3:3,16,12,Times,0,14,0,0,0;1,16,12,Times,1,14,0,0,0;2,15,11,Courier,1,14,0,0,0; :[font = input; preserveAspect] %[[1,1]] == 2 %[[1,2]] - %[[1,3]] ;[s] 6:0,1;1,0;14,1;15,0;25,1;26,0;35,-1; 2:3,12,10,Courier,1,12,0,0,0;3,12,10,Courier,1,12,65535,0,0; :[font = input; preserveAspect; endGroup] %%[[2,1]] ==2 %%[[2,2]] - %%[[2,3]] ;[s] 6:0,1;2,0;14,1;16,0;26,1;28,0;36,-1; 2:3,12,10,Courier,1,12,0,0,0;3,12,10,Courier,1,12,65535,0,0; :[font = text; inactive; Cclosed; preserveAspect; fontSize = 14; startGroup] Model problem I.9 is to solve the differential equation A[u] = 0. This linear, homogeneous problem is equivalent to finding the null space of the differential operator A. :[font = text; inactive; preserveAspect; fontSize = 14] The equation could be solved with the command DSolve (see below), but to understand it in detail let's do it by making a guess at the form of a solution, u = exp(m x). We then apply A to the guess: :[font = input; preserveAspect] A[E^(m x)] ;[s] 2:0,1;1,0;11,-1; 2:1,12,10,Courier,1,12,0,0,0;1,12,10,Courier,1,12,65535,0,0; :[font = input; preserveAspect] Solve[% == 0, m] ;[s] 3:0,0;6,1;7,0;17,-1; 2:2,12,10,Courier,1,12,0,0,0;1,12,10,Courier,1,12,65535,0,0; :[font = text; inactive; preserveAspect; fontSize = 14; endGroup] Thus two independent solutions, in complex form, are exp(-x/2 ± i Sqrt[7] x/2). They form a basis of the null space. :[font = text; inactive; Cclosed; preserveAspect; fontSize = 14; startGroup] Model Problem I.10 is an inhomogeneous matrix problem, using the matrix defined above. :[font = text; inactive; preserveAspect; fontSize = 14] The syntax for solving the problem with Mathematica is straightforward: ;[s] 3:0,0;40,1;51,0;73,-1; 2:2,16,12,Times,0,14,0,0,0;1,16,12,Times,2,14,0,0,0; :[font = input; preserveAspect; endGroup] Solve[MM.v == {1,1,1}, v] ;[s] 3:0,0;6,1;8,0;26,-1; 2:2,12,10,Courier,1,12,0,0,0;1,12,10,Courier,1,12,65535,0,0; :[font = text; inactive; Cclosed; preserveAspect; fontSize = 14; startGroup] Analogously, Model Problem I.11 is an inhomogeneous ordinary differential equation, which can be solved with the command DSolve: ;[s] 3:0,0;121,1;127,0;129,-1; 2:2,16,12,Times,0,14,0,0,0;1,15,11,Courier,0,14,0,0,0; :[font = input; preserveAspect; endGroup; endGroup] DSolve[A[u[x]] == E^(2 x), u[x],x] ;[s] 3:0,0;7,1;8,0;35,-1; 2:2,12,10,Courier,1,12,0,0,0;1,12,10,Courier,1,12,65535,0,0; ^*)