CH-05 (523174), страница 3
Текст из файла (страница 3)
That is,the trapezoidal rule has been applied twice, one in x-direction and another in ydirection. When M and N stations are employed in x- and y-directions, respectively.we may therefore define two weighting coefficient vectors© 2001 by CRC Press LLC{w } = [12 2 … 2 2 2]T(10){w } = [12 2 … 2 2 1]T(11)t xandt yIt should be noted that the subscripts x and y are added to indicate their association with the x- and y-axes, respectively, and that the orders of these two vectorsare M and N, respectively, and that the beginning and ending components in bothvectors are equal to one and the other components are equal to two. Having defined{wt}x and {wt}y, it is now easy to show that Equation 9 can be simply written as:V=T∆x{wt }x [Z]{wt }y ∆2y2(12)where [Z] is a matrix of order M by N having zi,j as its elements.
Since {wt}x is avector of order M by one, its transpose is of order one by M and {wt}y is of orderN by one, the matrix multiplication of the three matrices can be carried out and theresult does agree with the requirement on wi,j spelled out in Equation 9.Use of weighting coefficient vectors has the advantage of extending the numerical evaluation of double integrals from trapezoidal rule to Simpson’s rule wherethree adjacent heights are parabolically fitted (referring to program NuIntgra formore details).
To illustrate this point, let us first introduce a weighting coefficientvector for Simpson’s rule as:{w } = [1s4 2 … repeat of 4 and 2 … 4 1]T(13)If we wish to integrate by application of Simpson’s rule in both x- and ydirections and using M and N (both must be odd) stations, the formula for the volumeis simply:V=T∆x{ws}x [Z]{ws}y ∆3y3(14)If for some reason one wants to integrate using Simpson’s rule along x-directionby adopting M (odd) stations, and using trapezoidal rule along y-direction by adopting N (no restriction whether odd or even) stations, then:V=T∆x{ws}x [Z]{wt }y ∆2y3(15)Let us present a numerical example to further clarify the above concept ofnumerical volume integration.
Consider the problem of estimating the volume© 2001 by CRC Press LLCbetween the surface z(x,y) = 2x + 3y2 + 4 and the plane z = 0 for 0≤x≤2 and 1≤y≤2by application of trapezoidal rule along the x direction using an increment of 0.5,and Simpson’s rule along y direction using also an increment of 0.5.
The incrementsof o.5 in both x- and y-directions make M = 5 and N = 3. First, we calculate theelements of [Z] which is of order 5 by 3:Next, the volume is calculated to be:Program Volume has been developed for interactive specification of the integrand function z(x,y), the integration limits xL, xU, yL, and yU, the method(s) ofintegration (i.e., , trapezoidal or Simpson’s rule) and number of stations in both xand y-direction. The integrand function z(x,y) needs to be individually compiled.Both QuickBASIC and FORTRAN versions are made available. Listings are provided below along with sample applications.FORTRAN VERSION© 2001 by CRC Press LLC© 2001 by CRC Press LLCSample ApplicationThe FUNCTION Z(X,Y) listed above is for finding the volume under the surfacez(x,y) = (x2 + y2–4).5 over the region 0≤x≤2 and 0≤y≤2.
The exact solution isvolume = 4.1889. For a sample run of the program Volume using trapezoidal ruleand 21 stations along both x- and y-directions, the screen display of interactivecommunication through keyboard input and the calculated result is:QUICKBASIC VERSION© 2001 by CRC Press LLCSample ApplicationsThe same calculation of one-eighth of a sphere of radius equal to 2 as in theFORTRAN version is run but here using Simpson’s rule. The screen display is:We have presented earlier the manual calculation of the double integration forz(x,y) = 2x + 3y2 + 4, program Volume can be applied to have the results displayedon the monitor screen as below.
The answer is exactly the same as from manualcomputation.MATLAB APPLICATIONA Volume.m file can be created and added to MATLAB m files to calculate adouble integral when the integrand function is specified by another m file. Forintegrating a function Z(X,Y) over the region X1≤X≤X2 and Y1≤Y≤Y2 by eitherTrapezoidal or Simpson’s rules (designated as rule 1 or 2) and with NX and NYstations along the X and Y directions, respectively, this file may be written asfollowed:© 2001 by CRC Press LLCFor each problem, the integrand function Z(X,Y) needs to be prepared as a mfile.
In case that a hemisphere of radius 2 and centered at X = 0 and Y = 0, we maywrite:In case of Z(X,Y) = 2X + 3Y2 + 4, we may write a new file as:Once the files Volume.m, FuncZ.m, and FuncZnew.m, the following MATLAB executions can be achieved:© 2001 by CRC Press LLCNotice the first and second integrations of the hemisphere use Trapezoidal andSimpson’s rule in both X and Y, respectively. Both use 21 stations in X and Ydirections. The third integration of Z = 2X + 3Y2 + 4 over the region 0≤X≤2 and1≤Y≤2 is carried out using Trapezoidal rule along X direction with 5 stations andSimpson’s rule along Y direction with 3 stations.MATLAB has a mesh plot capability of generating three-dimensional hiddenline surface.
For example, when the function FuncZ is used to generate a hemispherical surface of radius equal to 2 described by a square matrix [Z], a plot shown inFigure 6 can be obtained by entering MATLAB commands as follows:We observe from Figure 6 that the hidden-line feature is apparent but the hemisphere appears like a semiellipsoid.
This is due to the aspect ratios of the displaymonitor and/or of the printer. mesh is the option of specifying different scale factorsfor the X-, Y-, and Z-axes. To make the three-dimensional surface to appear as aperfect hemisphere, user has to experiment with different scale factors for the threeaxes. This is left as a homework problem.
Also, mesh has option for displaying thesurface by viewing it from different angles, user is again urged to try generation ofdifferent 3D hidden-line views.MATHEMATICA APPLICATIONSMathematica has a three-dimensional plot function called Plot3d which can beapplied for drawing the hemispherical surface. Figure 7 is the result of entering thestatement:© 2001 by CRC Press LLCFIGURE 6.FIGURE 7.© 2001 by CRC Press LLCInput]: = Sphere = Plot3D[If[4X^2Y^2>0, Sqrt[4X^2Y^2],0,{X,–2,2},{Y,–2,2},PlotPoints->{60,60}]The If command tests the first expression inside the brackets, it the conditionis true then the statement which follows is implemented and other the last statementinside the bracket is implemented. In this case, the surface only rises over the basecircle of radius equal to 2.
The PlotPoints command specifies how many gird pointsalong X- and Y-directions should be taken to plot the surface. The default numberof point is 15 in both directions. The greater the number of grid points, the smootherthe surface looks.The same result can be obtained by first defining a surface function, say sf, andthen apply Plot3d for drawing the surface using sf as follows:Input]: = sf[X_,Y_] = If[4X^2Y^2>0, Sqrt[4X^2Y^2], 0]Input[2]: = Plot3D[sf[X,Y],{X,–2,2},{Y,–2,2},PlotPoints->{60,60}]5.4 PROBLEMSNUINTGRA1. Having learned how to apply Trapezoidal Rule for numerical integration,how would you find the area under the line y(x) = 1 + 2x and betweenx = 1 and x = 2? Do it not by direct integration, but numerically. Whatshould be the stepsize for x in order to ensure an accurate result?2. Having learned how to apply Simpson’s Rule for numerical integration,how would you find the area under the parabolic curve y(x) = 1 + 2x +3x2 and between x = 1 and x = 2? Do it not by direct integration butnumerically! What should be the stepsize for x in order to ensure anaccurate result?3.
If Trapezoidal Rule, instead of Simpson’s Rule, is applied for Problem 2,find out how small should be the stepsize for x in order to achieve thesame result accurate to the fifth significant digit.4. Could Simpson’s Rule be applied for Problem 1? Would the result bedifferent? If the result is the same, explain why.5. Given five points (1,1), (2,3), (3,2), (4,5), and (5,4), use a stepsize of x =1 to compute ydx by application of Simpson’s and Trapezoidal rules.6. Use the trapezoidal and Simpson’s rules to find the area within the ellipsedescribed by the equation (x/a)2 + (y/b)2 = 1. Compare the numericalresults with the exact solution of ab.7.
Implement the integration of the function f(x) = 3e–2xsinx over the intervalfrom x = 0 to x = 1 (in radian) by applying both the Trapezoidal andSimpson’s rules and using an increment of x = 0.25.8. Find the exact solution of Problem 7 by referring to an integration formulafor f(x) from any calculus book. Decrease the increment of x (i.e., ,© 2001 by CRC Press LLC9.10.11.12.13.14.15.16.17.18.increase the number of points at which the integrand function is computed)to try to achieve this analytical result using both Trapezoidal and Simpson’s Rules.Apply the function Quad.m of MATLAB to solve Problem 1.Apply the function Quad.m of MATLAB to solve Problem 2.Apply the function Quad.m of MATLAB to solve Problem 6.Apply the function Quad.m of MATLAB to solve Problem 7.Apply MATLAB to spline curve-fit the five points given in Problem 5and then integrate.Apply the function NIntegrate of Mathematica to solve Problem 1.Apply the function NIntegrate of Mathematica to solve Problem 2.Apply the function NIntegrate of Mathematica to solve Problem 6.Apply the function NIntegrate of Mathematica to solve Problem 7.Problem 13 but apply Mathematica instead.VOLUME1.
Apply trapezoidal rule for integration along the x direction and Simpson’srule along the y direction to calculate the volume under the surface z(x,y) =3x + 2y2 + 1 over the rectangular region 0≤x≤2 and 0≤y≤4 using increments x = y = 1.2. Rework Problem 1 except trapezoidal rule is applied for both x and ydirections.3. Find by numerical integration of the ellipsoidal volume based on thedouble integral 3[1–(x/5)2–(y/4)2]1/2dxdy and for x values ranging from2 to 4 and y values ranging from 1 to 2. Three stations (for using Simpson’srule) for the x integration and two stations (for using trapezoidal rule) forthe y integration are to be adopted.4. Find the volume between the z = 0 plane and the spherical surface z(x,y) =[4x2 – y2]1/2 for x and y both ranging from 0 to 2 by applying the Simpson’srule for both x and y integrations.
Three stations are to be taken along thex direction and five stations along the y direction for the specified numerical integration.5. Specify a FUNCTION Z(x,y) for program Volume so that the volumeenclosed by the ellipsoid (x/a)2 + (y/b)2 + (z/c)2 = 1 can be estimated bynumerical integration and compare to the exact solution of 4abc/3.26.