ENGINEERING MATHEMATICS 4 (BDA34003)

Similar documents
ENGINEERING MATHEMATICS 4 (BDA 34003)

ELASTICITY (MDM 10203)

Chapter 5: Numerical Integration and Differentiation

In numerical analysis quadrature refers to the computation of definite integrals.

Section 6.6 Gaussian Quadrature

Computing Integrals. Lectures INF2320 p. 1/48

Engg. Math. II (Unit-IV) Numerical Analysis

COURSE Numerical integration of functions (continuation) 3.3. The Romberg s iterative generation method

dt 2 The Order of a differential equation is the order of the highest derivative that occurs in the equation. Example The differential equation

Homework set #7 solutions, Math 128A J. Xia

Integration. Topic: Trapezoidal Rule. Major: General Engineering. Author: Autar Kaw, Charlie Barker.

Multiple Integrals. Chapter 4. Section 7. Department of Mathematics, Kookmin Univerisity. Numerical Methods.

MATH 1014 Tutorial Notes 8

Introductory Numerical Analysis

APPLICATIONS OF INTEGRATION

5 Numerical Integration & Dierentiation

Numerical integration and differentiation. Unit IV. Numerical Integration and Differentiation. Plan of attack. Numerical integration.

Numerical Integration and Numerical Differentiation. Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan

Romberg Integration and Gaussian Quadrature

Math 122 Fall Unit Test 1 Review Problems Set A

Topic 6a Numerical Integration

MA2501 Numerical Methods Spring 2015

APPM/MATH Problem Set 6 Solutions

Ch. 03 Numerical Quadrature. Andrea Mignone Physics Department, University of Torino AA

Bindel, Spring 2012 Intro to Scientific Computing (CS 3220) Week 12: Monday, Apr 16. f(x) dx,

Numerical Integration of Functions

Chapter 4 Integration

Practice Exam 2 (Solutions)

Numerical Methods in Physics and Astrophysics

14 EE 2402 Engineering Mathematics III Solutions to Tutorial 3 1. For n =0; 1; 2; 3; 4; 5 verify that P n (x) is a solution of Legendre's equation wit

Lecture 32: Taylor Series and McLaurin series We saw last day that some functions are equal to a power series on part of their domain.

Name Class. (a) (b) (c) 4 t4 3 C

MA 3021: Numerical Analysis I Numerical Differentiation and Integration

x+1 e 2t dt. h(x) := Find the equation of the tangent line to y = h(x) at x = 0.

Math 1310 Lab 10. (Sections )

Higher-Order Derivatives

1.1 GRAPHS AND LINEAR FUNCTIONS

Automatic Differentiation Lecture No 1

1 Exam 1 Spring 2007.

Numerical Analysis Solution of Algebraic Equation (non-linear equation) 1- Trial and Error. 2- Fixed point

GAUSS-LAGUERRE AND GAUSS-HERMITE QUADRATURE ON 64, 96 AND 128 NODES

16.4. Power Series. Introduction. Prerequisites. Learning Outcomes

April 15 Math 2335 sec 001 Spring 2014

5. Hand in the entire exam booklet and your computer score sheet.

The polar coordinates

dy = f( x) dx = F ( x)+c = f ( x) dy = f( x) dx

Sample Questions PREPARING FOR THE AP (BC) CALCULUS EXAMINATION. tangent line, a+h. a+h

Applied Calculus I. Lecture 36

(x x 0 )(x x 1 )... (x x n ) (x x 0 ) + y 0.

1 + x 2 d dx (sec 1 x) =

. CALCULUS AB. Name: Class: Date:

Chapter 6: The Definite Integral

Basic Math Review for CS4830

Homework 5 - Solutions

1 Lesson 13: Methods of Integration

a x a y = a x+y a x a = y ax y (a x ) r = a rx and log a (xy) = log a (x) + log a (y) log a ( x y ) = log a(x) log a (y) log a (x r ) = r log a (x).

Numerical integration

Power Series Solutions to the Legendre Equation

Day 5 Notes: The Fundamental Theorem of Calculus, Particle Motion, and Average Value

Lecture 44. Better and successive approximations x2, x3,, xn to the root are obtained from

Practice Final Exam Solutions

Exam in TMA4215 December 7th 2012

Multiplication of Polynomials

On the positivity of linear weights in WENO approximations. Abstract

Romberg Rule of Integration

MA 161 Final Exam December 13, You must use a #2 pencil on the scantron sheet (answer sheet).

Questions from Larson Chapter 4 Topics. 5. Evaluate

Some Applications of the Euler-Maclaurin Summation Formula

Fourth Order RK-Method

AP Calculus AB. Slide 1 / 175. Slide 2 / 175. Slide 3 / 175. Integration. Table of Contents

Chapter 5 - Quadrature

To find an approximate value of the integral, the idea is to replace, on each subinterval

Numerical Integration

X. Numerical Methods

CS 450 Numerical Analysis. Chapter 8: Numerical Integration and Differentiation

Research Computing with Python, Lecture 7, Numerical Integration and Solving Ordinary Differential Equations

AP Calculus AB 2nd Semester Homework List

MA6452 STATISTICS AND NUMERICAL METHODS UNIT IV NUMERICAL DIFFERENTIATION AND INTEGRATION

Notions of. Antonio Mucherino. last update: August University of Rennes 1 Numerical Analysis. A.

Integration, differentiation, and root finding. Phys 420/580 Lecture 7

integration integration

Introduction to computational modelling

y+2 x 1 is in the range. We solve x as x =

Chapter 2 Convergence

Math6100 Day 8 Notes 6.1, 6.2 & 6.3, Area

2008 CALCULUS AB SECTION I, Part A Time 55 minutes Number of Questions 28 A CALCULATOR MAY NOT BE USED ON THIS PART OF THE EXAMINATION

Day 2 Notes: Riemann Sums In calculus, the result of f ( x)

Math 113 Final Exam Practice

Review. Numerical Methods Lecture 22. Prof. Jinbo Bi CSE, UConn

Limits and Continuity. 2 lim. x x x 3. lim x. lim. sinq. 5. Find the horizontal asymptote (s) of. Summer Packet AP Calculus BC Page 4

Math 104A - Homework 3

LINEAR SYSTEMS (11) Intensive Computation

Math 1526 Excel Lab 2 Summer 2012

AM205: Assignment 3 (due 5 PM, October 20)

Econ 508B: Lecture 5

Numerical Programming I (for CSE)

04. Random Variables: Concepts

Examples 2: Composite Functions, Piecewise Functions, Partial Fractions

DRAFT - Math 102 Lecture Note - Dr. Said Algarni

Exercises, module A (ODEs, numerical integration etc)

Transcription:

ENGINEERING MATHEMATICS 4 (BDA34003) Lecture Module 6: Numerical Integration Waluyo Adi Siswanto Universiti Tun Hussein Onn Malaysia This work is licensed under a Creative Commons Attribution 3.0 License.

Topics Rectangular rule Trapezoidal rule Simpson's rule Simpson 1/3 Simpson 3/8 Gauss Quadrature 2-point 3-point Lecture Module 6 BDA 34003 2

Learning Outcomes Students have the knowledge of effective numerical integration in engineering Students will be able to use various methods of numerical integrations to calculate complex problems with high accuracy without involving mathematical exact solution Students will be able to decide the appropriate numerical method to solve particular engineering problem Lecture Module 6 BDA 34003 3

y y(x) You want to calculate the yellow area, under the curve y(x) Then you can calculate the area x n Area= x 1 y(x)dx x 1 x n x Lecture Module 6 BDA 34003 4

y y 2 y n 1 y(x) If the function is difficult You will find it difficult to integrate. Then you can predict by approximation Area=Area 1+ Area 2+ Area 3 Area=h y 1 + h y 2 + h y n 1 y 1 Or you can write Area=h( y 1 + y 2 + y n 1 ) x 1 x n Of course not accurate. If you use smaller division? x Lecture Module 6 BDA 34003 5

Rectangular rule y n 1 y 2 y y(x) If you want to divide by N division h= x n x 1 N Number of data n = N + 1 y 1 x n x 1 y(x)dx = h( y 1 + y 2 + + y n 1) h h h x x 1 x n Lecture Module 6 BDA 34003 6

Trapezoidal rule y n y n 1 y 3 y 2 y y(x) If you want to divide by N division h= x n x 1 N Now the area is not rectangular but trapezoidal y 1 x n y(x)dx = h x 1 2 ( y + y )+ h 1 2 2 ( y + y )+ + h 2 3 2 ( y + y ) n 1 n h h h x n y(x)dx = h x 1 2 ( y + 2 y + + 2 y + y ) 1 2 n 1 n x x 1 x n Lecture Module 6 BDA 34003 7

Trapezoidal m function (trapezoidal.m): function I = trapezoidal(f_str, a, b, n) %TRAPEZOIDAL Trapezoidal Rule integration. % I = TRAPEZOIDAL(F_STR, A, B, N) returns the Trapezoidal Rule approximation % for the integral of f(x) from x=a to x=b, using N divisions (subintervals), where % F_STR is the string representation of f. I=0; g = inline(f_str); h = (b-a)/n; I = I + g(a); for ii = (a+h):h:(b-h) I = I + 2*g(ii); end I = I + g(b); I = I*h/2; Lecture Module 6 BDA 34003 8

Simpson's rule Simpson 1/3 x n y( x)dx = h x 1 3 ( y 1+ 4 y 2 + 2 y 3 + 4 y 4 + 2 y 5 + + 4 y n 1+ y n ) The number of division must be multiplication of 2 Simpson 3/8 x n x 1 y( x)dx = 3 h 8 ( y 1+ 3( y 2 + y 3 + y 5 + y 6 + )+ 2( y 4 + y 7 + )+ y n ) The number of division must be multiplication of 3 Lecture Module 6 BDA 34003 9

Simpson 1/3 m function (simpson13.m): function I = simpson13(f_str, a, b, n) %SIMPRULE Simpson's rule integration. % I = SIMPRULE(F_STR, A, B, N) returns the Simpson's rule approximation % for the integral of f(x) from x=a to x=b, using N subintervals, where % F_STR is the string representation of f. % An error is generated if N is not a positive, even integer. I=0; g = inline(f_str); h = (b-a)/n; if((n > 0) && (rem(n,2) == 0)) I = I + g(a); for ii = (a+h):2*h:(b-h) I = I + 4*g(ii); end for kk = (a+2*h):2*h:(b-2*h) I = I + 2*g(kk); end I = I + g(b); I = I*h/3; else disp('incorrect Value for N') end Lecture Module 6 BDA 34003 10

Simpson 3/8 m function (simpson38.m): function int=simpson38(f_str,x1,x2,n) h=(x2-x1)/n; x(1)=x1; f=inline(f_str); if((n > 0) && (rem(n,3) == 0)) sum=f(x1); for i=2:n x(i)=x(i-1)+h; end for j=2:3:n sum=sum+3*f(x(j)); end for k=3:3:n sum=sum+3*f(x(k)); end for l=4:3:n sum=sum+2*f(x(l)); end sum=sum+f(x2); int=sum*3*h/8; else disp('incorrect Value for N') end Lecture Module 6 BDA 34003 11

Example 6-1 Find the approximate value of 4 1 x x+ 1 dx By using : a) Exact integration, use SMath b) Rectangular rule, 12 division c) Trapezoidal rule, 12 division d) Simpson 1/3, 12 division e) Simpson 3/8, 12 division Lecture Module 6 BDA 34003 12

Exact integration in SMath Rectangular rule N = 12 h = 0.25 No data x x/sqrt(x+1) 1 1 0.70711 2 1.25 0.83333 3 1.5 0.94868 4 1.75 1.05529 5 2 1.15470 6 2.25 1.24808 7 2.5 1.33631 8 2.75 1.42009 9 3 1.50000 10 3.25 1.57648 11 3.5 1.64992 12 3.75 1.72062 13 4 15.15060 Result=0.25(15.15060)=3.78765 Lecture Module 6 BDA 34003 13

Trapezoidal rule N = 12 h = 0.25 No data x x/sqrt(x+1) 1 1 0.70711 2 1.25 0.83333 3 1.5 0.94868 4 1.75 1.05529 5 2 1.15470 6 2.25 1.24808 7 2.5 1.33631 8 2.75 1.42009 9 3 1.50000 10 3.25 1.57648 11 3.5 1.64992 12 3.75 1.72062 13 4 1.78885 2.49596 14.44350 In FreeMat: Result= 0.25 2 (2.49596+2(14.44350))=3.9229 Lecture Module 6 BDA 34003 14

Simpson 1/3 rule N = 12 h = 0.25 No data x x/sqrt(x+1) 1 1 0.70711 2 1.25 0.83333 3 1.5 0.94868 4 1.75 1.05529 5 2 1.15470 6 2.25 1.24808 7 2.5 1.33631 8 2.75 1.42009 9 3 1.50000 10 3.25 1.57648 11 3.5 1.64992 12 3.75 1.72062 13 4 1.78885 2.49596 7.85389 6.58961 In FreeMat : Result= 0.25 3 (2.49596+4(7.85389)+2(6.48961))=3.9242 Lecture Module 6 BDA 34003 15

Simpson 3/8 rule N = 12 h = 0.25 No data x x/sqrt(x+1) 1 1 0.70711 2 1.25 0.83333 3 1.5 0.94868 4 1.75 1.05529 5 2 1.15470 6 2.25 1.24808 7 2.5 1.33631 8 2.75 1.42009 9 3 1.50000 10 3.25 1.57648 11 3.5 1.64992 12 3.75 1.72062 13 4 1.78885 2.49596 10.47542 3.96808 In FreeMat : Result= (3)0.25 8 (2.49596+ 3(10.47542)+ 2(3.96808))=3.9242 Lecture Module 6 BDA 34003 16

Example 6-2 A racing car velocity record from start to 12 seconds is shown below. You have to calculate the distance of the car from its start position in 12 seconds. The data is taken every 1 second. Use Simpson's rule 1/3. 180 160 150 160 170 170 170 140 120 110 speed (km/h) 100 80 60 50 60 70 75 80 90 40 20 0 0 0 2 4 6 8 10 12 time (seconds) Lecture Module 6 BDA 34003 17

N = 12 h= 1/3600 no t v(t) 1 0 0 2 1 50 3 2 60 4 3 70 5 4 75 6 5 80 7 6 90 8 7 110 9 8 150 10 9 160 11 10 170 12 11 170 13 12 170 170 640 545 Result= 1 (170+ 4(640)+ 2(545))=0.3537 km 3 3600 Lecture Module 6 BDA 34003 18

Gauss Quadrature The main idea in Gauss Quadrature is to change the integration limits to natural (dimensionless) coordinate limits from -1 to 1 y y(x) ϕ x 1 ϕ(ξ) x n x Change to natural coordinates 1 1 Lecture Module 6 BDA 34003 19 ξ

Gauss Quadrature The main idea in Gauss Quadrature is to change the integration limits to natural (dimensionless) coordinate limits from -1 to 1 y y(x) x ξ = 1 2 [ (1 ξ) x 1 + (1+ ξ) x n ] ϕ(ξ)= y(x ξ ) ϕ x 1 ϕ(ξ) x n x I = x 1 n x 1 ϕ(ξ)d ξ 2 1 1 1 Lecture Module 6 BDA 34003 20 ξ I = x n x 1 2 I ξ

1 I ξ = ϕ(ξ)d ξ 1 I ξ = R 1 ϕ(ξ 1 ) + R 2 ϕ(ξ 2 ) + + R n ϕ(ξ n ) ξ j R j is the location of the integration point j relative to the center is the weighting factor for point j relative to the center, and n is the number of points at which ϕ(ξ) is to be calculated Lecture Module 6 BDA 34003 21

Gauss Quadrature Coefficients for Gaussian Quadrature n ±ξ j R j 1 0.0 2.0 2 0.5773502692 1.0 3 0.7745966692 0.555555556 0.0 0.888888889 4 0.8611363116 0.3478548451 0.3399810436 0.6521451549 5 0.9061798459 0.2369268851 0.5384693101 0.4786286705 0.0 0.5688888889 Lecture Module 6 BDA 34003 22

Program to generate abscissa and weight for any number of integration points function [x,a] = GaussNodes(n,tol) % USAGE: [x,a] = GaussNodes(n,tol) % n = order of integration points % tol = error tolerance (default is 1.0e4*eps). format long; if nargin < 2; tol = 1.0e4*eps; end A = zeros(n,1); x = zeros(n,1); nroots = fix(n + 1)/2; for i = 1:nRoots t = cos(pi*(i - 0.25)/(n + 0.5)); for j = i: 30 p0 = 1.0; p1 = t; for k = 1:n-1 p = ((2*k + 1)*t*p1 - k*p0)/(k + 1); p0 = p1;p1 = p; end dp = n *(p0 - t*p1)/(1 - t^2); dt = -p/dp; t = t + dt; if abs(dt) < tol x(i) = t; x(n-i+1) = -t; A(i) = 2/(1-(t^2))/(dp^2); A(n-i+1) = A(i); break end end if nroots == 1 x(i) =0; end end Lecture Module 6 BDA 34003 23

Program to use Gauss Quadrature, any number of integration points function I = GaussQuadrature(func,a,b,n) % USAGE: I = gaussquad(func,a,b,n) % func = handle of function to be integrated. % for example --> func= @(x) ((sin(x)/x)^2) % a,b = integration limits. % n = order of integration points % I = integral result format long; c1 = (b + a)/2; c2 = (b - a)/2; [x,a] = GaussNodes(n); sum = 0; for i = 1:length(x) y = feval(func,c1 + c2*x(i)); sum = sum + A(i)*y; end I = c2*sum; Lecture Module 6 BDA 34003 24

ϕ ϕ(ξ) Gauss Quadrature 1 point 0.0 1 1 2.0 ξ weighting I ξ = R 1 ϕ(ξ 1 ) I ξ = 2.0 ϕ(0) Lecture Module 6 BDA 34003 25

ϕ ϕ(ξ) Gauss Quadrature 2 points -0.5773502692 0.0 0.5773502692 1 1 1.0 1.0 ξ weighting I ξ = R 1 ϕ(ξ 1 ) + R 2 ϕ(ξ 2 ) I ξ = 1.0 ϕ( 0.5773502692) + 1.0 ϕ(0.5773502692) Lecture Module 6 BDA 34003 26

ϕ ϕ(ξ) Gauss Quadrature 3 points -0.7745966692 0.0 0.7745966692 1 1 0.888888889 0.555555556 0.555555556 ξ weighting I ξ = R 1 ϕ(ξ 1 ) + R 2 ϕ(ξ 2 ) + R 3 ϕ(ξ 3 ) I ξ = 0.555555556 ϕ( 0.7745966692) + 0.888888889 ϕ(0.0) + 0.555555556 ϕ(0.7745966692) Lecture Module 6 BDA 34003 27

Example 6-3 Find the approximate value of 4 1 x x+ 1 dx By using : a) Gauss Quadrature 2 points b) Gauss Quadrature 3 points Lecture Module 6 BDA 34003 28

Lecture Module 6 BDA 34003 29

Lecture Module 6 BDA 34003 30

Example 6-4 Find the approximate value of 4 1 1+ x 2 x 3 + 1 dx By using : a) Gauss Quadrature 4 points b) Check your result in Smath (Exact integration) c) Check your result, using Freemat (GaussQuadrature) Lecture Module 6 BDA 34003 31

Lecture Module 6 BDA 34003 32

Lecture Module 6 BDA 34003 33

Student Activity Lecture Module 6 BDA 34003 34

Problem 6-A1 A military radar detected an unidentified flying object and found that the vertical velocity (m/s) can be expressed in a polynomial function, v(t)=20 t 3 +48t 2 +14 t If the flying object starts moving from the ground to the sky, calculate the distance of the flying object when it moves 10 seconds from the ground, by using (a) (b) 3-points Gauss quadrature. Simpson s rule with 10 divisions. (you have to select the appropriate Simpson's method) Lecture Module 6 BDA 34003 35

Problem 6-A2 The velocity of a particle (m/s) at each 4 seconds time t, is measured and the recorded data is shown below Time 0 4 8 12 16 20 24 velocity 13.27 25.44 30.19 31.80 32.25 32.92 32.89 Time 28 32 36 40 44 48 velocity 32.24 32.16 29.74 30.38 28.06 29.94 a) Find the distance travel by the particle from 0 to 48 second by using trapezoidal rule b) Use Smath - Generate the polynomial function from 13 data then calculate the distance by Integrating it from 0 to 4 seconds Lecture Module 6 BDA 34003 36

Lecture Module 6 BDA 34003 37