38. Numerical integration

38. Numerical integration - Numerical Integration For an...

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

View Full Document Right Arrow Icon
©2009 by L. Lagerstrom Numerical Integration • For an introduction to the basic concepts, see the associated video clip • Trapezoidal integration • Calculating velocity from acceleration data, and distance from velocity data • Cumulative trapezoidal integration • Simpson's method • The Lobatto algorithm • Two-dimensional integration
Background image of page 1

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

View Full DocumentRight Arrow Icon
©2009 by L. Lagerstrom Overview Recall that the integral of a function f(x) from x=a to x=b can be interpreted as the area under the curve of f(x) from a to b. Sometimes we only have data points that presumably represent a functional relationship f(x), i.e., we don't know f(x) and so can't use our typical calculus methods to find the integral of f(x). But we can estimate the integral by "connecting the dots" of the data points and calculating the area under the connected dots. Other times we know what f(x) is, but there is no analytic formula for the integral of f(x). This can be true even for relatively simple functions. The function f(x) = cos(x 2 ), for example, cannot be integrated analytically. In this case, we approximate the shape of f(x) using, for example, quadratic polynomials, and then integrate them.
Background image of page 2
Matlab code Figure window display ©2009 by L. Lagerstrom Trapezoidal Integration %We use the technique of trapezoidal %integration when we have some %data points and need to estimate %the area under the data points %(that is, the integral of the %function the data represents). %The essential technique is to %connect the dots of the data %points, which results in a series %of side-by-side trapezoids. Sum- %ming the areas of the trapezoids %then gives an estimate for the %total area underneath the data. %Some sample data x = 1:5; y = [42 60 65 54 63]; %Plot the data, connecting the %points with straight lines: plot(x,y,'-o') title('Trapezoidal Integration') xlabel('x'), ylabel('y') axis([0 6 0 80]) 0 1 2 3 4 5 6 0 10 20 30 40 50 60 70 80 Trapezoidal Integration x y
Background image of page 3

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

View Full DocumentRight Arrow Icon
Matlab code Figure window display ©2009 by L. Lagerstrom Trapezoidal Integration, cont. %The figure at the right shows a %clearer view of the four trapezoids %created by connecting the data %points. %We will use Matlab's trapz function %to sum the areas of the %trapezoids and thus get the total %area under the data points (next %slide). 0 1 2 3 4 5 6 0 10 20 30 40 50 60 70 80 Trapezoidal Integration x y
Background image of page 4
Matlab code Command window display ©2009 by L. Lagerstrom Trapezoidal Integration, cont. %Here's the data again x = 1:5; y = [42 60 65 54 63]; %Do trapezoidal integration area = trapz(x,y) area = 231.50
Background image of page 5

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

View Full DocumentRight Arrow Icon
Matlab code Command window display ©2009 by L. Lagerstrom Multiple-column Trapezoidal Integration %If we have multiple columns of data %stored in an array, the trapz %function will integrate the data %in each column. For example: %x data values x = 1:5; %y data for first column (note the %use of the transpose operator) y(:,1) = [42 60 65 54 63]'; %y data for columns 2 and 3 y(:,2) = [35 49 52 58 51]'; y(:,3) = [44 57 69 48 53]'; %Do trapezoidal integration for each %column of values in the y array result = trapz(x,y) result = 231.50 202.00 222.50
Background image of page 6
©2009 by L. Lagerstrom
Background image of page 7

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

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

This note was uploaded on 02/23/2010 for the course ENG 42325 taught by Professor Lagerstrom during the Spring '10 term at UC Davis.

Page1 / 24

38. Numerical integration - Numerical Integration For an...

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

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