MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 1 Bruce Mayer, PE Chabot College Mathematics Bruce Mayer, PE Licensed Electrical & Mechanical Engineer Chabot Mathematics §6.2 Numerical Integration
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 2 Bruce Mayer, PE Chabot College Mathematics Review § Any QUESTIONS About §6.1 → Integration by Parts, Use of Integral Tables Any QUESTIONS About HomeWork §6.1 → HW
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 3 Bruce Mayer, PE Chabot College Mathematics §6.2 Learning Goals Explore the trapezoidal rule and Simpson’s rule for numerical integration Use error bounds for numerical integration Interpret data using numerical integration
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 4 Bruce Mayer, PE Chabot College Mathematics Why Numerical Methods? Numerical Integration Very often, the function f(x) to differentiate, or the integrand to integrate, is TOO COMPLEX to yield exact analytical solutions. In most cases in Real World testing, the function f(x) is only available in a TABULATED form with values known only at DISCRETE POINTS
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 5 Bruce Mayer, PE Chabot College Mathematics Numerical Integration Game Plan: Divide Unknown Area into Strips (or boxes), and Add Up To Improve Accuracy the TOP of the Strip can Be Slanted Lines –Trapezoidal Rule Parabolas –Simpson’s Rule Higher Order PolyNomials
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 6 Bruce Mayer, PE Chabot College Mathematics Strip-Top Effect Parabolic (Simpson’s) Form Trapezoidal Form Higher-Order-Polynomial Tops Lead to increased, but diminishing, accuracy.
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 7 Bruce Mayer, PE Chabot College Mathematics Strip-Count Effect Adaptive Integration → INCREASE the strip- Count in Regions with Large SLOPES More Strips of Constant Width Tends to work just as well 10 Strips20 Strips
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 8 Bruce Mayer, PE Chabot College Mathematics AUC by Flat Tops
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 9 Bruce Mayer, PE Chabot College Mathematics Trapezoidal Area By the Diagram at Right Side Heights: Width: Now “Stack Up” for 2A Then or
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 10 Bruce Mayer, PE Chabot College Mathematics AUC by Trapezoids
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 11 Bruce Mayer, PE Chabot College Mathematics The Trapezoidal Rule To Find the APPROXIMATE Area Under the Curve given by y = f(x), and divided into vertical strips of equal width, Δx Where:
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 12 Bruce Mayer, PE Chabot College Mathematics Trapezoidal Rule Error AUC by the Trapezoidal Approximation incurs error in the amount of Where n ≡ the strip count K ≡ the maximum value of |d 2 y/dx 2 |
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 13 Bruce Mayer, PE Chabot College Mathematics Trapezoidal Rule Error Example The Function does NOT have a Closed Form, Analytical Solution Calculate the Area Under the Curve for this function between x=1 & x=3 using a 10-strip Trapezoidal Calculation
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 14 Bruce Mayer, PE Chabot College Mathematics Trapezoidal Rule Error Example Calculate Δx Then make Fcn T-Table using Then The T- Table Then the Approximation
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 15 Bruce Mayer, PE Chabot College Mathematics Trapezoidal Rule Error Example ReCall from Error Equation Taking the Derivative Twice Plot d 2 y/dx 2 to EyeBall Max Value Maximum at x = 3
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 16 Bruce Mayer, PE Chabot College Mathematics Trapezoidal Rule Error Example Then Thus, to 5 Sig-Figs: Finally the Maximum 10-Strip, Trapezoidal Error
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 17 Bruce Mayer, PE Chabot College Mathematics Simpson’s Rule The Simpson Method tops TWO Strips with successive 3-pt Curve-Fit Parabolas A Parabola can be fit EXACTLY to ANY 3 (x,y) points
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 18 Bruce Mayer, PE Chabot College Mathematics Simpson’s Rule Since 3-pts defines 2-strips Simpson’s Rule requires an EVEN Strip-Count Then for an Even Counting Number, n if M = max(|d 4 y/dx 4 |) then the Error
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 19 Bruce Mayer, PE Chabot College Mathematics Simpson’s Rule Example Use Simpson’s rule with n = 10 strips to approximate: SOLUTION From the Trapezoidal example Δx = 0.2 Now the SideWays T-Table
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 20 Bruce Mayer, PE Chabot College Mathematics Find Precise Value by MuPAD The Integrand Function fOFx := E^x/x Plot the AREA under the Integrand Curve fArea := plot::Function2d(fOFx, x = 1..3):plot(plot::Hatch(fArea), fArea) The Precise Value AUCn = numeric::int(fOFx, x=1..3)
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 21 Bruce Mayer, PE Chabot College Mathematics Simpson’s Error Find Fourth Derivative by MuPAD d4fdx4 := diff(fOFx, x $ 4) Then the 4 th Derivative Plot plot(d4fdx4, x=1..3, GridVisible = TRUE) Max at x=1
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 22 Bruce Mayer, PE Chabot College Mathematics Simpson’s Error Then the Error Calc The Error comparing to MuPAD Value Thus the TextBook Formula is Conservative
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 23 Bruce Mayer, PE Chabot College Mathematics NO Equation Functions Often in REAL LIFE “functions” disguise themselves as “Data Tables” When I was Research Tech at Lawrence Berkeley Lab (1978) I made Ventilation-Duct Volume-Flow measurements. A typical Data Set
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 24 Bruce Mayer, PE Chabot College Mathematics NO-Equation Functions I then had to Calculate the Duct Volume Flow, Q, from the Data Table using the integration This type of Integration Occurs Frequently in the Physical, Life, and Social Sciences, as well as in the Business world
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 25 Bruce Mayer, PE Chabot College Mathematics NO-Eqn Integration Example The Cylindrical Tank shown at right has a bottom area of 130 ft 2. The tank is initially EMPTY. To Fill the Tank, Water Flows into the top at varying rates as given in the Tank-Table below. Time (min) FlowRate (ft 3 /min)
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 26 Bruce Mayer, PE Chabot College Mathematics NO-Eqn Integration Example For this situation determine the water height,H, at t = 18 minutes SOLUTION Use the TRAPEZOIDAL Rule to Integrate the WaterFlow to arrive at the the Total Water VOLUME Use the Max No. of strips permitted by Data
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 27 Bruce Mayer, PE Chabot College Mathematics NO-Eqn Integration Example Make ΔV Calcs for the 10 strips Then by GeoMetry So Finally
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 28 Bruce Mayer, PE Chabot College Mathematics NO-Eqn Integration Example Note that in this case Δx is NON-constant 10 Strips of Varying Width Thus SIMPSON’s Rule Can NOT be Used Simpson’s Rule Requires constant Δx
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 29 Bruce Mayer, PE Chabot College Mathematics MatLab Code % Bruce Mayer, PE % MTH-15 01Aug13 Rev 11Sep13 % MTH15_Quick_Plot_BlueGreenBkGnd_ m % clear; clc; clf; % clf clears figure window % % The Domain Limits xmin = -6; xmax = 6; % The FUNCTION ************************************** x = [ ]; y = [ ]; % *************************************************** % the Plotting Range = 1.05*FcnRange ymin = min(y); ymax = max(y); % the Range Limits xmin = min(x); xmax = max(x); % the Range Limits R = ymax - ymin; ymid = (ymax + ymin)/2; ypmin = ymid *R/2; ypmax = ymid *R/2 % % The ZERO Lines zxh = [xmin xmax]; zyh = [0 0]; zxv = [0 0]; zyv = [ypmin*1.05 ypmax*1.05]; % % the 6x6 Plot axes; set(gca,'FontSize',12); whitebg([ ]); % Chg Plot BackGround to Blue-Green plot(x,y, '-d', 'LineWidth', 4),grid, axis([xmin xmax ypmin ypmax]),... xlabel('\fontsize{14}t (min)'), ylabel('\fontsize{14}Q = (ft^3/min)'),... title(['\fontsize{16}MTH16 Bruce Mayer, PE',]),... annotation('textbox',[ ], 'FitBoxToText', 'on', 'EdgeColor', 'none', 'String', 'MTH15 Quick Plot BlueGreenBkGnd m','FontSize',7) hold on plot(zxv,zyv, 'k', zxh,zyh, 'k', 'LineWidth', 2) stem(x,y, '-r.', 'LineWidth', 2) hold off
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 30 Bruce Mayer, PE Chabot College Mathematics WhiteBoard Work Problems From §6.2 P40 → Consumer’s Surplus
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 31 Bruce Mayer, PE Chabot College Mathematics All Done for Today Tracking Trapezoids
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 32 Bruce Mayer, PE Chabot College Mathematics Bruce Mayer, PE Licensed Electrical & Mechanical Engineer Chabot Mathematics Appendix –
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 33 Bruce Mayer, PE Chabot College Mathematics
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 34 Bruce Mayer, PE Chabot College Mathematics
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 35 Bruce Mayer, PE Chabot College Mathematics P MatLAB Code x = [ ] y = [ ] ps = y-ymin M = [ ] CS1 = ps.*M CS2 = (4/3)*CS1 CS3 = sum(CS2) CS4 = sum(CS1) CStot = (4/3)*CS4 % Bruce Mayer, PE % MTH-16 11Jan14 % MTH15_Quick_Plot_BlueGreenBkGnd_ m % clear; clc; clf; % clf clears figure window % % The FUNCTION ************************************** x = [0:4:24]; y = [ ]; % *************************************************** % the Plotting Range = 1.05*FcnRange ymin = min(y); ymax = max(y); % the Range Limits xmin = min(x); xmax = max(x); % the Range Limits R = ymax - ymin; ymid = (ymax + ymin)/2; ypmin = ymid *R/2; ypmax = ymid *R/2 ypmin =0 % % The ZERO Lines zxh = [xmin xmax]; zyh = [0 0]; zxv = [0 0]; zyv = [ypmin*1.05 ypmax*1.05]; % % the 6x6 Plot axes; set(gca,'FontSize',12); whitebg([1 1 1]); % Chg Plot BackGround to Blue-Green plot(x,y, '-d', 'LineWidth', 4),grid, axis([xmin xmax ypmin ypmax]),... xlabel('\fontsize{14}q (kUnits)'), ylabel('\fontsize{14}p ($/Unit)'),... title(['\fontsize{16}MTH16 Bruce Mayer, PE',]),... annotation('textbox',[ ], 'FitBoxToText', 'on', 'EdgeColor', 'none', 'String', 'MTH15 Quick Plot BlueGreenBkGnd m','FontSize',7) hold on plot(zxv,zyv, 'k', zxh,zyh, 'k', 'LineWidth', 2) stem(x,y, '-r.', 'LineWidth', 2) plot([xmin, xmax], [ ], '-.m', 'LineWidth', 3) hold off
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 36 Bruce Mayer, PE Chabot College Mathematics Example NONconstant ∆x Pacific Steel Casting Company (PSC) in Berkeley CA, uses huge amounts of electricity during the metal-melting process. The PSC Materials Engineer measures the power, P, of a certain melting furnace over 340 minutes as shown in the table at right. See Data Plot at Right.
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 37 Bruce Mayer, PE Chabot College Mathematics Example NONconstant ∆x The T-table at Right displays the Data Collected by the PSC Materials Enginer Recall from Physics that Energy (or Heat), Q, is the time-integral of the Power. Use Strip-Integration to find the Total Energy in MJ expended by The Furnace during this process run
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 38 Bruce Mayer, PE Chabot College Mathematics Example NONconstant ∆x GamePlan for Strip Integration Use a Forward Difference approach ∆t n = t n+1 − t n –Example: ∆t 6 = t 7 − t 6 = 134 − 118 = 16min → 16min·(60sec/min) = 960sec Over this ∆t assume the P(t) is constant at P avg,n =(P n+1 − P n ) –Example: P avg,6 = (P 7 − P 6 )/2 = ( )/2 = kW = kJ/sec
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 39 Bruce Mayer, PE Chabot College Mathematics Example NONconstant ∆x The GamePlan Graphically Note the Variable Width, ∆x, of the Strip Tops
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 40 Bruce Mayer, PE Chabot College Mathematics MATLAB Code MATLAB Code % Bruce Mayer, PE % MTH-15 25Jul13 % XY_Area_fcn_Graph_6x6_BlueGreen_BkGnd_Template_1306.m % clear; clc; clf; % clf is clear figure % % The FUNCTION xmin = 0; xmax = 350; ymin = 0; ymax = 225; x = [ ] y = [ ] % % The ZERO Lines zxh = [xmin xmax]; zyh = [0 0]; zxv = [0 0]; zyv = [ymin ymax]; % % the 6x6 Plot axes; set(gca,'FontSize',12); whitebg([ ]); % Chg Plot BackGround to Blue-Green % Now make AREA Plot area(x,y,'FaceColor',[ ],'LineWidth', 3),axis([xmin xmax ymin ymax]),... grid, xlabel('\fontsize{14}t (minutes)'), ylabel('\fontsize{14}P (kW)'),... title(['\fontsize{16}MTH15 Variable-Width Strip-Integration',]),... annotation('textbox',[ ], 'FitBoxToText', 'on', 'EdgeColor', 'none', 'String', 'Bruce Mayer, PE 25Jul13','FontSize',7) set(gca,'XTick',[xmin:50:xmax]); set(gca,'YTick',[ymin:25:ymax]) set(gca,'Layer','top')
MTH16_Lec-01_sec_6-1_Integration_by_Parts.pptx 41 Bruce Mayer, PE Chabot College Mathematics Example NONconstant ∆x The NONconstant Strip-Width Integration is conveniently done in an Excel SpreadSheet The 13 ∆Q strips Add up to MegaJoules of Total Energy Expended