(*^ ::[ 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, L3, e8, 24, "New York"; fontset = subtitle, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, L2, e6, 18, "New York"; fontset = subsubtitle, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, L2, e6, 14, "New York"; fontset = section, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, grayBox, M22, bold, L2, a20, 14, "New York"; fontset = subsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, blackBox, M19, bold, L2, a15, 12, "New York"; fontset = subsubsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, whiteBox, M18, bold, L2, a12, 10, "New York"; fontset = text, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L2, 12, "New York"; fontset = smalltext, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L2, 10, "New York"; fontset = input, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeInput, M42, N23, bold, L2, 12, "Courier"; fontset = output, output, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L2, 12, "Courier"; fontset = message, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, R32768, L2, 12, "Courier"; fontset = print, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L2, 12, "Courier"; fontset = info, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L2, 12, "Courier"; fontset = postscript, PostScript, formatAsPostScript, output, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeGraphics, M7, l34, w282, h287, L2, 12, "Courier"; fontset = name, inactive, nowordwrap, nohscroll, noKeepOnOnePage, preserveAspect, M7, italic, B32768, L2, 10, "Geneva"; fontset = header, inactive, noKeepOnOnePage, preserveAspect, M7, L2, 10, "Times"; fontset = leftheader, inactive, L2, 10, "Times"; fontset = footer, inactive, noKeepOnOnePage, preserveAspect, center, M7, L2, 12, "Times"; fontset = leftfooter, inactive, center, L2, 12, "Times"; fontset = help, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L2, 10, "Geneva"; fontset = clipboard, inactive, noKeepOnOnePage, preserveAspect, M7, L2, 12, "New York"; fontset = completions, inactive, nowordwrap, noKeepOnOnePage, preserveAspect, M7, L2, 12, "New York"; fontset = special1, inactive, nowordwrap, noKeepOnOnePage, preserveAspect, M7, L2, 12, "New York"; fontset = special2, inactive, nowordwrap, noKeepOnOnePage, preserveAspect, center, M7, L2, 12, "New York"; fontset = special3, inactive, nowordwrap, noKeepOnOnePage, preserveAspect, right, M7, L2, 12, "New York"; fontset = special4, inactive, nowordwrap, noKeepOnOnePage, preserveAspect, M7, L2, 12, "New York"; fontset = special5, inactive, nowordwrap, noKeepOnOnePage, preserveAspect, M7, L2, 12, "New York"; paletteColors = 128; currentKernel; ] :[font = subtitle; inactive; preserveAspect; fontSize = 19; fontName = "Times"; startGroup] Linear Methods of Applied Mathematics Selected Solutions :[font = text; inactive; preserveAspect; plain; bold; fontName = "Times"] (c) Copyright 1994-1997 by Evans M. Harrell II and James V. Herod. All rights reserved. :[font = text; inactive; Cclosed; preserveAspect; plain; bold; fontSize = 13; fontName = "Times"; startGroup] Notes for the instructor. :[font = text; inactive; preserveAspect; fontSize = 13; fontName = "Times"; endGroup] This contains calculations and examples which correlate with chapter 4 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; fontSize = 11; fontName = "Times"; startGroup] Instructions :[font = text; inactive; preserveAspect; fontSize = 13; fontName = "Times"; 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] 11:0,0;19,1;30,0;96,1;133,0;181,1;192,0;315,1;326,0;538,1;549,0;721,-1; 2:6,15,10,Times,0,13,0,0,0;5,15,10,Times,2,13,0,0,0; :[font = text; inactive; preserveAspect; fontSize = 14; fontName = "Times"] A useful substitution, which we shall often make, is: :[font = input; preserveAspect] TrigId = {Cos[Pi n_] -> (-1)^n, Sin[Pi n_] -> 0}; :[font = input; preserveAspect] ExpId = {E^(I Pi k) -> (-1)^k,E^(-I Pi k) -> (-1)^k}; :[font = section; inactive; Cclosed; preserveAspect; startGroup] Exercise III.1. (Find some Fourier series) :[font = text; inactive; preserveAspect; fontName = "Times"] Find the Fourier (sine and cosine) series Fourier sine series Fourier cosine series Fourier exponential series on the interval 0 < x < L for the function f(x) = x for 0 < x < L/2, otherwise 0. Discuss what happens if the series is evaluated outside the interval 0 < x < L. We may as well suppose that L = 1; otherwise, simply replace x in what follows by x/L and then multiply the whole series by L. We call on some formulae from the notebook for Chapter 4. Because of the dual definition of f(x), it is best to modify those formulae rather than use them directly: ;[s] 1:0,1;585,-1; 2:0,14,9,Times,0,12,0,0,0;1,17,12,Times,0,14,0,0,0; :[font = subsection; inactive; Cclosed; preserveAspect; fontSize = 16; fontName = "Times"; startGroup] The full Fourier series :[font = input; preserveAspect; startGroup] A0 = Integrate[x, {x,0,1/2}] :[font = output; output; inactive; preserveAspect; endGroup] 1/8 ;[o] 1 - 8 :[font = input; preserveAspect; startGroup] A[m_] = 2 Integrate[x Cos[2 m Pi x], {x,0,1/2}] /. TrigId :[font = output; output; inactive; preserveAspect; endGroup] 2*(-1/(4*m^2*Pi^2) + (-1)^m/(4*m^2*Pi^2)) ;[o] m -1 (-1) 2 (-------- + --------) 2 2 2 2 4 m Pi 4 m Pi :[font = text; inactive; preserveAspect] Notice that these are 0 when m is even, and otherwise -1/(m Pi)^2 . :[font = input; dontPreserveAspect; startGroup] B[n_] = 2 Integrate[x Sin[2 n Pi x], {x,0,1/2}] /. TrigId :[font = output; output; inactive; preserveAspect; endGroup] -(-1)^n/(2*n*Pi) ;[o] n -(-1) ------ 2 n Pi :[font = input; preserveAspect] FullSeries[x_,infinity_] := 1/8 - \ Sum[(1/(m Pi)^2) Cos[2 m Pi x], {m,1,infinity,2}] + \ Sum[((-1)^(n+1) /(2 n Pi)) Sin[2 n Pi x], {n,1,infinity}] :[font = input; preserveAspect] Plot[FullSeries[x,5], {x,0,1}] :[font = text; inactive; preserveAspect] On a larger interval, we have: :[font = input; preserveAspect; endGroup] Plot[FullSeries[x,5], {x,-2,2}] :[font = subsection; inactive; Cclosed; preserveAspect; fontSize = 16; fontName = "Times"; startGroup] The Fourier sine series :[font = text; inactive; preserveAspect] There are only b terms, and the difference between these b's and the previous ones is that more frequencies are admitted: :[font = input; preserveAspect] Clear[B] :[font = input; dontPreserveAspect; startGroup] B[n_] = 2 Integrate[x Sin[n Pi x], {x,0,1/2}] :[font = output; output; inactive; preserveAspect; endGroup] (2*(-(n*Pi*Cos[(n*Pi)/2])/2 + Sin[(n*Pi)/2]))/(n^2*Pi^2) ;[o] n Pi -(n Pi Cos[----]) 2 n Pi 2 (----------------- + Sin[----]) 2 2 --------------------------------- 2 2 n Pi :[font = text; inactive; preserveAspect] When n is odd, these cosine functions vanish, and the sine functions alternate in sign. When n is even, the sine terms functions and the cosine functions alternate in sign. :[font = input; preserveAspect] SinSeries[x_,infinity_] := Sum[(2 (-1)^(m/2-1/2)/(m Pi)^2) Sin[m Pi x], {m,1,infinity,2}]+ \ Sum[((-1)^(1+n/2)/(n Pi)) Sin[n Pi x] , {n,2,infinity,2}] :[font = input; preserveAspect] Plot[SinSeries[x,5], {x,0,1}] :[font = text; inactive; preserveAspect] On a larger interval, we have: :[font = input; preserveAspect; endGroup] Plot[SinSeries[x,5], {x,-2,2}] :[font = subsection; inactive; Cclosed; preserveAspect; fontSize = 16; fontName = "Times"; startGroup] The Fourier cosine series :[font = text; inactive; preserveAspect] There are only a terms, and the difference between these a's and the ones for the full Fourier series is that more frequencies are admitted: :[font = input; preserveAspect; startGroup] A0 = Integrate[x, {x,0,1/2}] :[font = output; output; inactive; preserveAspect; endGroup] 1/8 ;[o] 1 - 8 :[font = input; preserveAspect] Clear[A] :[font = input; preserveAspect; startGroup] A[m_] = 2 Integrate[x Cos[m Pi x], {x,0,1/2}] :[font = output; output; inactive; preserveAspect; endGroup] 2*(-(1/(m^2*Pi^2)) + (Cos[(m*Pi)/2] + (m*Pi*Sin[(m*Pi)/2])/2)/ (m^2*Pi^2)) ;[o] m Pi m Pi Sin[----] m Pi 2 Cos[----] + -------------- 1 2 2 2 (-(------) + --------------------------) 2 2 2 2 m Pi m Pi :[font = text; inactive; preserveAspect] When n is odd, these cosine functions vanish, and the sine functions alternate in sign. When n is even, the sine functions vanish and the cosine functions alternate in sign. :[font = input; preserveAspect] CosSeries[x_,infinity_] := 1/8 + \ Sum[(-2 /(m1 Pi)^2) Cos[m1 Pi x], {m1,1,infinity}]+ \ Sum[(2 (-1)^(1+m2/2)/(m2 Pi)^2) Cos[m2 Pi x] , {m2,2,infinity,2}] + \ Sum[((-1)^(m3/2-1/2)/(m3 Pi)) Cos[m3 Pi x] , {m3,1,infinity,2}] :[font = input; preserveAspect; startGroup] Plot[CosSeries[x,5], {x,0,1}] :[font = output; output; inactive; preserveAspect; endGroup] Graphics["<<>>"] ;[o] -Graphics- :[font = text; inactive; preserveAspect] On a larger interval, we have: :[font = input; preserveAspect; endGroup] Plot[CosSeries[x,5], {x,-2,2}] :[font = subsection; inactive; Cclosed; preserveAspect; fontSize = 16; fontName = "Times"; startGroup] The complex exponential Fourier series :[font = text; inactive; preserveAspect] This is the same series as the full Fourier series, except for the complex notation and the way the terms are grouped. If we wish to calculate the coefficients directly, we may do it with: :[font = input; dontPreserveAspect; startGroup] CC[k_] = Integrate[x Exp[2 I k Pi x], {x,0,1/2}] /. TrigId :[font = output; output; inactive; preserveAspect; endGroup; endGroup; endGroup; endGroup] -1/(4*k^2*Pi^2) + (E^(I*k*Pi)*(1 - I*k*Pi))/(4*k^2*Pi^2) ;[o] I k Pi -1 E (1 - I k Pi) -------- + -------------------- 2 2 2 2 4 k Pi 4 k Pi :[font = section; inactive; Cclosed; preserveAspect; startGroup] Exercise IV.1. If f is a real-valued function, the coefficients am and bn are real-valued. What do you conclude from (4.8) about the coefficients ck in this case? What can you conclude about the ck if f is an even function? if f is an odd function? Answer: ;[s] 5:0,0;149,1;150,0;199,1;200,0;262,-1; 2:3,19,14,New York,1,14,0,0,0;2,27,18,New York,65,14,0,0,0; :[font = text; inactive; preserveAspect; endGroup] If f is an even, real-valued function, then ck is real and even in k (that is, c-k = ck). If f is an odd, real-valued function, then ck is imaginary and odd in k (that is, c-k = -ck). ;[s] 13:0,0;45,1;46,0;80,1;82,0;86,1;87,0;135,1;136,0;174,1;176,0;181,1;182,0;185,-1; 2:7,17,12,New York,0,12,0,0,0;6,25,16,New York,64,12,0,0,0; :[font = section; inactive; Cclosed; preserveAspect; startGroup] Exercise IV.2. Calculate the Fourier series for the saw-tooth function you get as the periodic extension of f(x) := 1 - |x| from the basic interval [-1,1]. Differentiate the series term by term and compare with the Fourier series for the derivative of f(x). Notice that the Fourier series is not bothered by the corners in the function at -1,0, and 1. :[font = text; inactive; preserveAspect] Since the saw-tooth function is even, this series is the same as the Fourier cosine series for the function 1 - x on the interval [0,1]: :[font = subsection; inactive; preserveAspect; fontSize = 16; fontName = "Times"; startGroup] Fourier cosine series :[font = text; inactive; preserveAspect; fontSize = 14; fontName = "Times"] Here we set up some Mathematica commands to compute the Fourier cosine series. ;[s] 3:0,0;20,1;31,0;82,-1; 2:2,17,12,Times,0,14,0,0,0;1,17,12,Times,2,14,0,0,0; :[font = input; dontPreserveAspect] Ave[f_, {a_,b_}] := (1/(b-a)) Integrate[(f /. x -> intvar1), \ {intvar1, a, b}] AC[f_,m_, {a_,b_}] := (2/(b-a)) Integrate[ \ (Cos[m Pi intvar2/(b-a)] f /. x -> intvar2), \ {intvar2, a, b}] /. TrigId :[font = input; preserveAspect; endGroup] CosSeries[f_, NN_, {x_,a_,b_}] := Ave[f,{a,b}] + \ Sum[AC[f,m,{a,b}] Cos[m Pi x/(b-a)], {m, 1, NN}] :[font = input; preserveAspect; startGroup] CosSeries[1 - x, 5, {x,0,1}] :[font = output; output; inactive; preserveAspect; endGroup] 1/2 + (4*Cos[Pi*x])/Pi^2 + (4*Cos[3*Pi*x])/(9*Pi^2) + (4*Cos[5*Pi*x])/(25*Pi^2) ;[o] 1 4 Cos[Pi x] 4 Cos[3 Pi x] 4 Cos[5 Pi x] - + ----------- + ------------- + ------------- 2 2 2 2 Pi 9 Pi 25 Pi :[font = text; inactive; preserveAspect; endGroup] If we differentiate this term by term, we indeed get the Fourier sine series for -1, which you may think of as a square pulse, when it is extended outside this interval. :[font = section; inactive; Cclosed; preserveAspect; startGroup] Exercise V.2. What series do you obtain by differentiating the Fourier series for the square pulse (cf. model problem IV.1)? If you know about the Dirac delta function, comment on the relationship between the series you get for the square pulse and the one for the delta function d(x-a) (periodically extended). Answer: ;[s] 3:0,0;282,1;283,0;323,-1; 2:2,19,14,New York,1,14,0,0,0;1,17,12,Symbol,1,14,0,0,0; :[font = text; inactive; preserveAspect] We get the series :[font = input; preserveAspect] DiffSeries[x_,infinity_] := 4 Sum[Cos[2 n Pi x], {n,1,infinity,2}] :[font = text; inactive; preserveAspect] This sum includes odd terms only. Although the derivative of the square pulse is 0 for almost every x, and this sum is divergent, it still makes sense as an approximation to a differentiable function with a steep slope at 1/2: :[font = input; preserveAspect; endGroup] Plot[DiffSeries[x,12], {x,0,1}] :[font = section; inactive; Cclosed; preserveAspect; startGroup] Exercise V.3. Consider what happens when a Legendre series is differentiated term by term. Is the result a Legendre series? Does the result converge to the derivative of the original function? :[font = text; inactive; preserveAspect; endGroup] The result is still a polynomial series, but it is not written in the form of a Legendre series. It will be equivalent to the Legendre series for the derivative whenever the function and its derivative are continuous. ^*)