Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
25 views

03 Integration Methods

1. The document discusses numerical integration methods called the Trapezoidal Rule and Simpson's Rule. 2. The Trapezoidal Rule approximates the area under a curve using trapezoids, while Simpson's Rule uses parabolas to get a better approximation. 3. Examples are provided to demonstrate calculating definite integrals using these rules by dividing the area into strips and summing the areas.

Uploaded by

John Reyniel
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

03 Integration Methods

1. The document discusses numerical integration methods called the Trapezoidal Rule and Simpson's Rule. 2. The Trapezoidal Rule approximates the area under a curve using trapezoids, while Simpson's Rule uses parabolas to get a better approximation. 3. Examples are provided to demonstrate calculating definite integrals using these rules by dividing the area into strips and summing the areas.

Uploaded by

John Reyniel
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

firefoxActivity No.

3
Integrating Numerically Using Trapezoidal and Simpson’s Rules

1. Objective
The activity aims to introduce the Trapezoidal and Simpson’s Rules concepts and application through
computing for getting the integral of equations.
2. Intended Learning Outcomes (ILOs)
The students should be able to:
2.1 Explain the concept of Trapezoidal and Simpson’s rules in integrating systems of equations.
2.2 Create programs through computing tools for trapezoidal and simpson’s rules.
2.3 Perform integration through Trapezoidal and Simpson’s rules.
3. Discussion

Integration can be used to find areas, volumes, central points and


many useful things. But it is often used to find the area under the
graph of a function like this:

The area can be found by adding slices that approach zero in width:
And there are Rules of Integration that help us get the answer.

Notation
The symbol for "Integral" is a stylish "S"
(for "Sum", the idea of summing slices):
After the Integral Symbol we put the function we want to find the integral of (called the Integrand),
and then finish with dx to mean the slices go in the x direction (and approach zero in width).

Definite Integral
A Definite Integral has started and end values: in other words there is an interval (a to b). The
values are put at the bottom and top of the "S", like this:
Indefinite Integral Definite Integral
(no specific values) (from a to b)
We can find the Definite Integral by calculating the Indefinite Integral at points a and b, then subtracting:

Example 1:
The Definite Integral, from 1 to 2, of 2xdx:

The Indefinite Integral is: ∫2x dx = x2 + C


 At x=1: ∫2x dx = 12 + C
 At x=2: ∫2x dx = 22 + C

Subtract:
(22 + C) − (12 + C)
22 + C − 12 − C
3 −1+C−C=3
4
And "C" gets cancelled out ... so with Definite Integrals we can ignore C.
In fact we can give the answer directly like this:
Example 2:
The Definite Integral, from 0.5 to 1.0, of cos(x)dx:

(Note: x must be in radians)


The Indefinite Integral is: ∫cos(x) dx = sin(x) + C. We can ignore C when we do the subtraction (as
we saw above):

= sin(1) − sin(0.5)

= 0.841... − 0.479...
= 0.362...

Example 3:
The Definite Integral, from 0 to 1, of sin(x)dx:

The Indefinite Integral is: ∫sin(x) dx = −cos(x) + C. Since we are going from 0, can we just calculate
the area at x=1? −cos(1) = −0.540...What? The Area at x=1 is negative? No, we need to subtract
the integral at x=0. We shouldn't assume that it is zero. So let us do it properly, subtracting one
from the other (and C gets cancelled so we don't need to show it):

= −cos(1) − (−cos(0))

= −0.540... − (−1)

= 0.460...
Example 4:
The Definite Integral, from 1 to 3, of cos(x) dx:

Notice that some of it is positive, and some negative. The definite integral will work out the net
area. The Indefinite Integral is: ∫cos(x) dx = sin(x) + C. So let us do the calculations:

= sin(3) − sin(1)

= 0.141... − 0.841...
= −0.700...

Properties
Reversing the interval

Reversing the direction of the interval gives the negative of the original direction.

Interval of zero length

When the interval starts and ends at the same place, the result is zero:

Adding intervals
We can also add two adjacent intervals together:

Finding definite integrals of certain equations may vary and may not be accurate. As a resort, numerical
methods were developed by mathematicians. The most common of these methods are the Trapezoidal and
Simpson’s Rules.

The Trapezoidal Rule


Instead of using rectangles as we did in the arches problem, we'll use trapezoids (trapeziums) and
we'll find that it gives a better approximation to the area.

Recall that we write "Δx" to mean "a small change in x". Now, the area of a trapezoid (trapezium) is
given by:


𝐴𝑟𝑒𝑎 = (𝑝 + 𝑞)
2

So the approximate area under the curve is found by adding the area of the trapezoids. (Our
trapezoids are rotated 90° so that their new base is actually the height. So h = Δx.)

𝑦0 𝑦𝑛
𝐴𝑟𝑒𝑎 ≈ ∆𝑥( + 𝑦1 + 𝑦2 + 𝑦3 + ⋯ + )
2 2

To find ∆x for the area from x = a to x=b, we use:


𝑏−𝑎
∆𝑥 =
𝑛

And we also need


𝑦0 = 𝑓(𝑎)
𝑦1 = 𝑓(𝑎 + ∆𝑥)
𝑦2 = 𝑓(𝑎 + 2∆𝑥)

𝑦𝑛 = 𝑓(𝑏)
Note:
 We get a better approximation if we take more trapezoids up to limit.
 The more trapezoids we take, ∆x will tend to 0, that is, ∆x→0.
 We can write (if the curve is above the x-axis only between x=a and x=b.

Example 5:
Using n=5, approximate the integral.
1
∫ √𝑥 2 + 1𝑑𝑥
0
Solution to Example 5:

I have joined each of the points at the top of the vertical segments with a straight line. Here, a = 0
and b =1, and the width of each trapezoid is given by:

𝑏−𝑎 1−0
∆𝑥 = = = 0.2
𝑛 5
𝑦0 = 𝑓(𝑎) = 𝑓(0) = √02 + 1 = 1
𝑦1 = 𝑓(𝑎 + ∆𝑥) = 𝑓(0.2) = √0.22 + 1 = 1.0198039
𝑦2 = 𝑓(𝑎 + 2∆𝑥) = 𝑓(0.4) = √0.42 + 1 = 1.0770330
𝑦3 = 𝑓(𝑎 + 3∆𝑥) = 𝑓(0.6) = √0.62 + 1 = 1.1661904
𝑦4 = 𝑓(𝑎 + 4∆𝑥) = 𝑓(0.8) = √0.82 + 1 = 1.2806248
𝑦5 = 𝑓(𝑎 + 5∆𝑥) = 𝑓(1.0) = √1.02 + 1 = 1.4142136
So we have:

Integral ≈

1 1
0.2 ( × 1 + 1.0198039 + 1.0770330 + 1.1661904 + 1.2806248 + × 1.4142136)
2 2
= 𝟏. 𝟏𝟓𝟎
So
1
∫ √𝑥 2 + 1𝑑𝑥 ≈ 1.150
0

We can see in the graph above the trapezoids are very close to the original curve, so our
approximation should be close to the real value. In fact, to 3 decimal places, the integral value is
1.148.

The Simpson’s Rule


In Trapezoidal Rule, we use straight lines to model curve and learned that it was an improvement
over using rectangles for finding areas under a curves because we had much less ‘missing’ from
each segment. We seek an even better approximation for the area under a curve.

In Simpson’s rule, we will use parabolas to approximate each part of the curve. This proves to be
very efficient since it’s generally more accurate than the other numerical methods we’ve seen.

We divide the area into n equal segments of width ∆x. The approximate area is given by the
following.
𝑏
∆𝑥
𝐴𝑟𝑒𝑎 = ∫ 𝑓(𝑥)𝑑𝑥 ≈ (𝑦0 + 4𝑦1 + 2𝑦2 + 4𝑦3 + 2𝑦4 … + 4𝑦(𝑛 − 1) + 𝑦𝑛); 𝑤ℎ𝑒𝑟𝑒 ∆𝑥
𝑎 3
(𝑏 − 𝑎)
=
𝑛

Note: In Simpson’s Rule, n must be even.

The above formula might be a little tricky to be memorized. Hence we may simplify it as shown
below.
𝑏
∆𝑥
∫ 𝑓(𝑥)𝑑𝑥 ≈ (𝑦0 + 4(𝑦1 + 𝑦3 + 𝑦5 + ⋯ ) + 2(𝑦2 + 𝑦4 + 𝑦6 + ⋯ ) + 𝑦𝑛)
𝑎 3
𝒃
∆𝒙
∫ 𝒇(𝒙)𝒅𝒙 ≈ (𝑭𝑰𝑹𝑺𝑻 + 𝟒(𝒔𝒖𝒎 𝒐𝒇 𝑶𝑫𝑫𝒔) + 𝟐(𝒔𝒖𝒎 𝒐𝒇 𝑬𝑽𝑬𝑵𝒔) + 𝑳𝑨𝑺𝑻)
𝒂 𝟑

Example 6:
3 𝑑𝑥
Approximate ∫2 using Simpson’s Rule with n=4.
𝑥+1

Answer to Example 6:

𝑏−𝑎 3−2
∆𝑥 = = = 0.25
𝑛 4
1
𝑦0 = 𝑓(𝑎) = 𝑓(2) = = 0.3333333
2+1
1
𝑦1 = 𝑓(𝑎 + ∆𝑥) = 𝑓(2.25) = = 0.3076923
2.25 + 1
1
𝑦2 = 𝑓(𝑎 + 2∆𝑥) = 𝑓(2.5) = = 0.2857142
2.5 + 1
1
𝑦3 = 𝑓(𝑎 + 3∆𝑥) = 𝑓(2.75) = = 0.2666667
2.75 + 1
1
𝑦4 = 𝑓(𝑏) = 𝑓(3) = = 0.25
3+1

So
𝑏
𝐴𝑟𝑒𝑎 = ∫ 𝑓(𝑥)𝑑𝑥
𝑎
0.25
≈ (0.3333333 + 4(0.3076923) + 2(0.2857142)
3
+ 4(0.26666667) + 0.25) = 0.2876831

Notes
1. The actual answer to this problem is 0.287682 (to 6 decimal places) so our Simpson's Rule
approximation has an error of only 0.00036%.
2. In this example, the curve is very nearly parabolic, so the 2 parabolas shown above
1
practically merge with the curve 𝑦 = 𝑥+1.

4. Resources:
The students shall be able to:
4.1 A personal computer with installed operating system
4.2 A Spreadsheet software
4.3 A C/C++ IDE or Matlab (or any equivalent tool)
4.4 Knowledge in C/C++ programming.

5. Procedure:
1. Using either spreadsheet software or any C/C++ IDE, create a program that follows the step-by-
step procedure of solving areas under a curve of certain equation. Instead of using definite
integrals, use Trapezoidal and Simpson’s Rules.
2. After creating the program(s) for Trapezoidal and Simpson’s Rules, solve the following integrals
below:
4
a. Approximate ∫0 𝑥 2 𝑑𝑥 using the Trapezoidal and Simpson’s rule with n=8 and n=4
subintervals.

3. Show your results in 6. Data and Results.

6. Data and Results:


SOURCE CODE
Trapezoidal Rule
**Insert your source code here.**

Simpson’s Rule
**Insert your source code here.**

ITEM TRAPEZOIDAL SIMULATION SIMPSON SIMULATION ANSWER


A a. Using
Trapezoidal
b. Using
Simpson

TO DO: Differentiate the results of Trapezoidal and Simpson Rules based from the output above and
explain briefly in 2-3 sentences.

7. Reflection:
**Insert your reflection here**
8. Assessment:

TECHNOLOGICAL INSTITUTE OF THE PHILIPPINES

RUBRIC FOR CONDUCT OF EXPERIMENTS

(Engineering Programs)

Student Outcome (d1): Design and conduct experiments, as well as to analyze, and interpret data, and synthesize information to provide valid conclusions for

investigating complex problems.

Program: Course: _______________ Section: Semester School Year ____________

Beginner Acceptable Proficient


Performance Indicators Score
1 2 3
Student do not follow Student follow good and
1. Conduct experiments in Student follow good and safe
good and safe laboratory safe laboratory practice most
accordance with good and safe laboratory practice at all times in
practice in the conduct of of the time in the conduct of
laboratory practice the conduct of experiments.
experiments. experiments.
Student is able to operate the
Student is unable to Student is able to operate
2. Operate equipment and equipment and instruments with
operate the equipment equipment and instrument
instruments with ease ease and with minimum
and instruments. with supervision.
supervision.

3. Analyze data, validate


Student has complete data,
experimental values against Student has complete data
Student has incomplete validates experimental values
theoretical values to determine but has no analysis and valid
data. against theoretical values, and
possible experimental errors, conclusion.
provides valid conclusion.
and provide valid conclusions.

Total Score 0
Mean Score = (Total Score/3) 0
Percentage Score = (Total Score / 9) x 100 0

Evaluated by:
Engr. Marwin B. Alejo
_______________________________________ ____________________

Printed Name and Signature of Faculty Member Date


TECHNOLOGICAL INSTITUTE OF THE PHILIPPINES
938 Aurora Boulevard, Cubao, Quezon City

COLLEGE OF ENGINEERING AND ARCHITECTURE


Computer Engineering Department

MATH 012 – Numerical Methods


Quiz 1, Midterm, SY 2017-2018

NAME: John Reyniel S. Balagbagan DATE: 9-8-17

QUESTION ANSWER

1. What is the use of


It is a technique for approximating a definite integral.
Trapezoidal Rule?

Numerical differentiation describes algorithms for estimating the derivative of a mathematical


2. What is Numerical
function or function subroutine using values of the function and perhaps other knowledge
Differentiation?
about the function.

3. What is your It gives a better approximation of the area under a curve. The approximation becomes more
observation of accurate as the resolution of the partition increases. When the partition has a regular spacing,
Trapezoidal Rule? as is often the case, the formula can be simplified for calculation efficiency.

𝐴𝑟𝑒𝑎 = (𝑝 + 𝑞)
2

So the approximate area under the curve is found by adding the area of the
trapezoids. (Our trapezoids are rotated 90° so that their new base is actually the
height. So h = Δx.)

𝑦0 𝑦𝑛
𝐴𝑟𝑒𝑎 ≈ ∆𝑥( + 𝑦1 + 𝑦2 + 𝑦3 + ⋯ + )
2 2
4. Write an equation
of Trapezoidal To find ∆x for the area from x = a to x=b, we use:
Rule? 𝑏−𝑎
∆𝑥 =
𝑛

And we also need


𝑦0 = 𝑓(𝑎)
𝑦1 = 𝑓(𝑎 + ∆𝑥)
𝑦2 = 𝑓(𝑎 + 2∆𝑥)

𝑦𝑛 = 𝑓(𝑏)

1 1 2
For definite integrals such as ∫0 √1 − 𝑥 3 𝑑𝑥 or ∫0 𝑒 −𝑥 𝑑𝑥

5. Which formula is The trapezoidal rule is a numerical method that approximates the value of a definite
used in integral. We consider the definite integral
Trapezoidal Rule? 𝑏
∫ 𝑓(𝑥)𝑑𝑥
𝑎
TECHNOLOGICAL INSTITUTE OF THE PHILIPPINES
938 Aurora Boulevard, Cubao, Quezon City

COLLEGE OF ENGINEERING AND ARCHITECTURE


Computer Engineering Department

MATH 012 – Numerical Methods


Quiz 2, Midterm, SY 2017-2018

NAME: John Reyniel S. Balagbagan DATE: 9-8-17

QUESTION ANSWER

1. What is
Simpson's rule is a method for numerical integration, the numerical approximation of definite
Simpson’s 1/3
integrals.
Rule?

 Composite Simpson’s Rule


 Alternative extended Simpson’s Rule
2. List Simpson’s
 Simpson’s 3/8 Rule
Rule.
 Simpson’s 3/8 Rule (for n intervals)

Simpson's rule actually gives exact results when approximating integrals of polynomials up to
3. Write an
cubic degree. Simpson's rule gains an extra order because the points at which the integrand is
observation about
evaluated are distributed symmetrically in the interval. The fourth derivative of such a
Simpson’s Rule.
polynomial is zero at all points.
𝑏
∆𝑥
4. Write down ∫ 𝑓(𝑥)𝑑𝑥 ≈ (𝑦0 + 4(𝑦1 + 𝑦3 + 𝑦5 + ⋯ ) + 2(𝑦2 + 𝑦4 + 𝑦6 + ⋯ ) + 𝑦𝑛)
Simpson’s Rule. 𝑎 3

5. Simpson’s Rule is
applied on which End points a and b and the midpoint.
point of parabola?

You might also like