lecture21

lecture21 - Lecture 21 Integration: Left, Right and...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Lecture 21 Integration: Left, Right and Trapezoid Rules The Left and Right endpoint rules In this section, we wish to approximate a definite integral: integraldisplay b a f ( x ) dx where f ( x ) is a continuous function. In calculus we learned that integrals are (signed) areas and can be approximated by sums of smaller areas, such as the areas of rectangles. We begin by choosing points { x i } that subdivide [ a,b ]: a = x < x 1 < ... < x n- 1 < x n = b. The subintervals [ x i- 1 ,x i ] determine the width x i of each of the approximating rectangles. For the height, we learned that we can choose any height of the function f ( x * i ) where x * i [ x i- 1 ,x i ]. The resulting approximation is: integraldisplay b a f ( x ) dx n summationdisplay i =1 f ( x * i ) x i . To use this to approximate integrals with actual numbers, we need to have a specific x * i in each interval. The two simplest (and worst) ways to choose x * i are as the left-hand point or the right-hand point of each interval. This gives concrete approximations which we denote by L n and R n given by L n = n summationdisplay i =1 f ( x i- 1 ) x i and R n = n summationdisplay i =1 f ( x i ) x i . function L = myleftsum(x,y) % produces the left sum from data input. % Inputs: x -- vector of the x coordinates of the partition % y -- vector of the corresponding y coordinates % Output: returns the approximate integral n = max(size(x)); % safe for column or row vectors L = 0; for i = 1:n-1 L = L + y(i)*(x(i+1) - x(i)); end 75 76...
View Full Document

Page1 / 4

lecture21 - Lecture 21 Integration: Left, Right and...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online