38. Numerical integration

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

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

©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

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

View Full Document
©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.
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

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

View Full Document
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
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

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

View Full Document
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
©2009 by L. Lagerstrom Calculating Velocity from Acceleration Consider a function that describes the velocity of an object over time, v(t). We know that we can find the acceleration of the object

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern