PHYSICS 3/MATH 355 HOMEWORK #8 Solutions Question # We consider the integral : where m and n are both integers. We can evaluate this integral : Integrate@Cos@m xd Cos@n xd, 8x, π, π<d m Cos@n πd Sin@m πd n Cos@m πd Sin@n πd m n - cos HmxL cos HnxL dx If m n, it is easy to show that this fraction equals zero since the numerator is zero and the denominator is non-zero. However, if m=n (and both are integers), then both the numerator and denominator are zero and we have an indeterminate form. You learned in first semester calculus that you can often find the iting value of an indeterminate form by using L'Hoital's rule. The familiar statement of L'Hoital's rule is that if the it of: x-x f HxL g HxL is indeterminate as x Ø x, then: f HxL xø x g HxL = xø x f' HxL g' HxL As an examle, if we wish to find the it as x Ø of sin x/x, we have an indeterminate form since both sin x and x go to zero as x Ø. However, we can aeal to L'Hoital and find: Let' s aly L' Hoital' s rule to our result : xø sin x x = x Ø d Hsin xl dx = d HxL dx cos x = m Cos@n D Sin@m D - n Cos@m D Sin@n D m - n
hys3-8hw8s.nb as m aroaches n. In this case, we treat m as the variable that is aroaching the constant value of n, and therefore we differentiate the numerator and denominator with resect to m. Thus we have : mø n m Ø n m Ø n m Cos@n D Sin@m D - n Cos@m D Sin@n D m - n = d @ m cos Hn L sin Hm L - n cos Hm L sin Hn LD dm d dm Im - n M @ cos Hn L sin Hm L + mcos Hn L cos Hm L + n sin Hm L sin Hn LD m Remember, in alying L' Hoital' s rule we differentiate the numerator with resect to m, and then searately differentiate the denominator with resect to m. Recognizing that both n and m are integers, we realize that all terms involving sin(n ) or sin(m ) go to zero. Remembering this and also that m Ø n, eq. () simlifies to: m Ø n m cos Hn L cos Hm L =cos Hn L m The value of cos(n ) is + if n is even and - if n is odd (or, H-L n ). Thus, cos Hn L always has the value of, so that our it has the value of, which we know to be the value of the original integral if m=nœintegers. = () () Question # We wish to find the Fourier series for the function defined as : - H+xL, - x < H-xL, x < (3) We know that the general form of any Fourier series is : where we need to find the coefficients defined as : a + S 8an cos HnxL + b n sin HnxL< n= a = f HxL dx - a n = f HxL cos HnxLdx - b n = f HxL sin HnxL dx - (4) (5) (6) (7) For this roblem, f (x) is defined in eq. (3) above. As we discussed in class, we should try to be mindful to make use of symmetry
hys3-8hw8s.nb 3 whenever ossible, so let' s see if our function is either even or odd. We can lot this function : Clear@fD f@x_d := Which@ π < x <, ê Hπ +xl, < x <π,ê Hπ xld; Plot@f@xD, 8x, π, π<d.5..5 -.5 -. -.5 And we see that this is clearly an odd function. We could have just as easily recognized that f (x) = -f (-x) for all x in the interval. (If you are not familiar with the "Which" command, read about it either in my classnote "Using Functions in Mathematica" (. 8-9) and/or in the Mathematica documentation center.) Knowing that f (x) is odd, we exect that only odd terms will aear in its Fourier series. In other words, the Fourier series of this articular f (x) will consist of only sin terms. Thus, we can determine without any direct integration that a and a n are zero. Of course, direct integration will verify this: Integrate@8f@xD, f@xd Cos@n xd<, 8x, π, π<, Assumtions Element@n, IntegersDD 8, < Now we need to find the coefficients as defined in eq. (7) to substitute into our general Fourier series in eq.(4) to comlete this roblem. To find these coefficients, we roceed : - b n = f HxL sin HnxLdx = - - H+xL sin HnxLdx + H-xLsin HnxLdx (8) and this generates four searate integrals : - sin HnxLdx - x - sin HnxLdx + - sin HnxLdx - x sin HnxLdx (9) We comute these in turn : - sin HnxLdx = - - n ÿ H-cos HnxLL = @H - cos H-n LF = - n n @ - H-Ln D where in the last ste we take advantage of the fact that cos is an even function, so that cos(-n ) = cos(n L = H-L n. () We integrate the second integral on the right side of (9) by arts (see the recent classnote if you need a refresher in integration by arts) :
4 hys3-8hw8s.nb - x sin HnxLdx = - - B - n cos HnxLx - - cos HnxLdxF = - - n n B8 - H-L H-Ln < + n sin HnxL F = H-Ln n - And we recognize that the integral of cos (n x) vanishes because the integral of cos is sin, and sin is zero at all integer multilies of. We will make use of this in evaluating the fourth integral in (9). The third integral in (9) is : sin HnxLdx = ÿb - n cos HnxL F = - n @H-Ln - D () The final integral becomes : - x sin HnxLdx = - B - n cos HnxLx + F = n @ H-Ln - D = H-L n We know from the second integral that the Ÿv du ortion of this integration by arts is zero. Combining our four integral results, we have: And our Fourier series is simly : n b n = n @ - H-Ln D + H-L n n - n @H-Ln - D + H-L n n = n sin Hn xl S = sin x + n= n Verifying our result by lotting the first terms of the Fourier series : Plot@Sum@Sin@n xdên, 8n,, <D, 8x, π, π<d sin HxL sin H3xL + +... 3 (3) (4) (5).5..5 -.5 -. -.5 And we reroduce the function as exected.
hys3-8hw8s.nb 5 Question #3 Find the Fourier series for : x, - x < (6) This is clearly an even function, so we know all the b n coefficients are zero. We solve for a and a n : a = x dx = - 3 Ax3 F = 3-3 = 3 fl a = 3 a n = x cos HnxLdx = - (7) H ê πl Integrate@x^ Cos@n xd, 8x, π, π<, Assumtions Element@n, IntegersDD 4 H L n n Notice that the term H-L n alternates; it is ositive for even n and negative for odd n. Thus, our Fourier series is: 3 + 4 S H-L n cos HnxL n= n (8) and the first three terms are : 3-4Bcos HxL - cos HxL 4 + cos H3 xl +...F 9 (9) And we lot the first terms of this series : Plot@π ^ê 3 + 4 Sum@H L ^n Cos@n xd ê n^, 8n,, <D, 8x, π, π<, Eilog 8Red, Point@88, 4<, 83, 9<, 8.5,.5<<D<D 8 6 4 For further verification, I use the Eilog feature to lot three oints (in red) that we know fit on the curve y = x.
6 hys3-8hw8s.nb Question #4 Find the Fourier series for the function :, - x < sin x, x < () Finding coefficients : a = H ê πl Integrate@Sin@xD, 8x,, π<d π So we have that a =. a n = H ê πl Integrate@Sin@xD Cos@n xd, 8x,, π<, Assumtions Element@n, IntegersDD + H Ln I + n M π The a n coefficients are zero when n is odd and are equal to - ë AIIn - ME for n even. We need to be a little careful in our calculation of the b n coefficients. We know these are calculated as: b n = sin HxL sin HnxL dx () Since sin is an odd function, this integrand is the roduct of two odd functions, so the integral is even. Since the integral is even, we know its value from to is just / of its value from - to, or we can write this integral as: b n = sin HxL sin HnxLdx = sin HxL sin HnxLdx - () We are very familiar with integrals of the form of (). We encountered them when we studied the orthogonality of the sine function. Thus, we know that the integral in () is zero for any value of n not equal to one : b n = H ê πl Integrate@Sin@xD Sin@n xd, 8x,, π<, Assumtions Element@n, IntegersDD But, when n =, the integral in () becomes : b = sin xdx = (3) H ê πl Integrate@Sin@xD^, 8x,, π<d
hys3-8hw8s.nb 7 so that the only b coefficient that is non zero is b = ê. Our Fourier series is then : - cos H nxl S n=,4,6... In - M + sin x (4) Plot@H ê πl + H ê L Sin@xD H ê πl Sum@ Cos@n xdêhn^ L, 8n,,, <D, 8x, π, π<d..8.6.4. The most common errors student make on this roblem is to assume there are no b coefficients, forgetting that the sin (x) term survives. Question #5 Find the Fourier series for : e x, - x < (5) a = H ê πl Integrate@Ex@xD, 8x, π, π<d π + π π If we remember the definition of sinh x, we realize that we can write this coefficient as ( sinh )/ so that the first term in the Fourier series, a ê will be (sinh )/. a n = H ê πl Integrate@Cos@n xd Ex@xD, 8x, π, π<, Assumtions Element@n, IntegersDD H L n Sinh@πD I + n M π b n = H ê πl Integrate@Sin@n xd Ex@xD, 8x, π, π<, Assumtions Element@n, IntegersDD H Ln n Sinh@πD I + n M π We can write our Fourier series now. Factoring out a common term of (sinh )/, we get:
8 hys3-8hw8s.nb sinh B + S H-L n cos HnxL n= In + M - S n= sinh B - cos x cos H xl cos H3 xl + - +... 5 + sin x 4 sin HxL 6 sin H3 xl - + -...F 5 H-L n n sin HnxL F = In + M We lot the first terms of this series and suerimose 3 oints to verify this is the correct curve : (6) Plot@HSinh@πD ê πl H + Sum@HH L^n Cos@n xd H L^n n Sin@n xdl ê Hn^ + L, 8n,, <DL, 8x, π, π<, Eilog 8Red, Point@88, Ex@D<, 83, Ex@3D<, 8, Ex@ D<<D<D 5 5 5 Question #6 Find the Fourier series for the function : -x, - x < x, x < Plotting this function shows clearly it is an even function :
hys3-8hw8s.nb 9 Clear@fD f@x_d := Which@ π < x <, x, < x <π,xd; Plot@f@xD, 8x, π, π<d 3..5..5..5 And we know we need not calculate any of the b n coefficients. a = H ê πl Integrate@f@xD, 8x, π, π<d π a n = H ê πl Integrate@f@xD Cos@n xd, 8x, π, π<, Assumtions Element@n, IntegersDD I + H L n M n π The a n coefficients will be zero when n is even, and have a value of -4 ë n when n is odd. Our Fourier series is then: Writing out the first several terms : - 4 S cos HnxL n=,3,5 n - 4 cos H3 xl Bcos x + + 9 cos H5 xl +...F 5 And lotting the first terms, with several oints suerimosed on the grah for verification : (7) (8)
hys3-8hw8s.nb Plot@π ê H4 ê πl Sum@Cos@n xd ê n^, 8n,,, <D, 8x, π, π<, Eilog 8Red, Point@88, <, 83, 3<, 8.5,.5<<D<D 3..5..5..5 For sulementary information, I will introduce you to one of the ways you can suerimose two different grahs on one lot : Plot@8f@xD, π ê H4 ê πl Sum@Cos@n xdê n^, 8n,,, <D<, 8x, π, π<, PlotStyle 88Darker@RedD<, 88Green, Dashed<<<D 3..5..5..5 I adding the PlotStyle feature to hel show that two different curves are lotted and are clearly coincident with each other, showing in fact the equality of our original f (x) with our Fourier series. The original function is lotted in red, and the comuted Fourier series is lotted in dashed green.without much exlanatory comment, I will show how we can define grahics functions and lot them with the "Show" command (remember that a semi - colon at the end of a command suresses that outut. This way we will see only one grah and not all 3) :
hys3-8hw8s.nb g = Plot@f@xD, 8x, π, π<, PlotStyle Darker@RedDD; g = Plot@π ê H4 ê πl Sum@Cos@n xdên^, 8n,,, <D, 8x, π, π<, PlotStyle 8Green, Dashed<D; Show@g, gd 3..5..5..5