You are on page 1of 18

Independent University, Bangladesh

School of Engineering and Computer Science


Department of Electrical & Electronic Engineering

Course ID EEE-314L

Course Title Numerical Technique Lab

Student Name MD AKIF RAHMAN

Student ID 1711396

Experiment No: 07
Experiment Name: Study on finding the value of a definite integral using the trapezoidal rule.
Objectives:
➢ To get introduced with basic MATLAB commands for approximating the definite integral using the
trapezoidal rule.
➢ Performing the algorithm on given examples.
➢ Verify MATLAB output with the theoretical hand calculations.

Apparatus:
➢ MATLAB

Theory: (In Short)


• Trapezoidal Rule
• The drawback of the trapezoidal rule

• Definite Integral

Equations:
𝒃 𝑁

∫ 𝑓(𝑥) 𝑑𝑥 = ∑(𝑓(𝑥𝑘−1 ) + 𝑓(𝑥𝑘 ))
𝒂 2
𝑘=1


= (𝑓(𝑥0 ) + 2𝑓(𝑥1 ) + 2𝑓(𝑥2 ) + 2𝑓(𝑥3 ) + ⋯ + 2𝑓(𝑥𝑁−1 ) + 𝑓(𝑥𝑁 ))
2
𝑓(𝑥𝑁 ) + 𝑓(𝑥0 )
= ℎ (𝑓(𝑥1 ) + 𝑓(𝑥2 ) + 𝑓(𝑥3 ) + ⋯ + 𝑓(𝑥𝑁−1 ) + ( ))
2
𝑁−1
𝑓(𝑥𝑁 ) + 𝑓(𝑥0 )
= ℎ (∑ 𝑓(𝑥𝑘 ) + )
2
𝑘=1

Here,
𝑏−𝑎
h = Step size = 𝑁

N = Number of Steps

MATLAB Code:

Experiments:
Write down appropriate MATLAB code to Find the value of the following Integrals using the trapezoidal rule.

a) 𝑦 = 𝑥𝑠𝑖𝑛𝑥
b) 𝑦 = 𝑥 + 𝑐𝑜𝑠𝑥
c) 𝑦 = 3𝑥 2 +𝑥 5
d) 𝑦 = 4𝑥 3
Limits 0 to 4 and points, N = 5, 20, 100
a) y=xsinx

N=5
N=20
N=100
b) y=x+cosx

N=5
N=20
N=100
c) y=3x2+x5

N=5
N=20
N=100
d) y=4x3

N=5
N=20
N=100
Calculation:
Do the handwritten calculation for all the equations when N = 5.
Result:

y=4x3 & N=5

Theoretical Value Simulation Error(%)

266.24 266.24 0%

Discussion:

The conventional command for the trapezoid rule in MATLAB differs slightly from the standard
expression. In conventional mathematics, the endpoints are the X coordinates that are used to
locate the points Y. The Trapezoid equation is then used to integrate all of the points to produce
the area.
The function of y is initially denoted by the integrals of y in MATLAB commands. Limits are
then stated with N points, and step size h is determined using them. "X" represents the endpoints
that begin at a and end at b. The trapezoid equation with integral solutions for the a and b points
is denoted by the letter "T." Beginning the subsequent for loop, MATLAB automatically handles
shifting the value of I to the next member of the vector by indicating it with a limit. "T" in a for
loop corresponds to the answers for the I loop's modifying y and T before. The first endpoint of a
limit in the I loop is x0(i).
Trapezodial_integral gives the solution for actual area which we find theoretically and
Exact_integral gives the actual area of integration. We can also verify our coded answers with
MATLAB default Trapezoid function.
LAB REPORT RUBRICS

Student Name MD AKIF RAHMAN Student ID 1711396


Course Title Numerical Technique Lab Course Code EEE 314L
Term Spring Summer Autumn Year 2022
Experiment Study on finding the value of a definite integral Experiment
using the trapezoidal rule. 07
Name Number
Submission
08-Aug,2022 Due Date 08-Aug,2022
Date
Tick () on the appropriate box (anyone from 1 to 5)
Rubrics (weight) Accomplished Intermediate Developing Intermediate Novice
(5) (4) (3) (2) (1)
Understanding Defined experiment Intermediate Defined Intermediate Defined
experiment’s requirements and between experiment between novice experiment
requirements assume circuit developing requirements and and developing. requirements and
(25%) specifications, if any, and assume circuit assume circuit
properly. accomplished. specifications, if specifications, if
any, moderately. any, poorly.

Building Circuit Conducted Intermediate Conducted Intermediate Conducted


and conducting experiment properly between experiment between novice experiment
experiment (25%) by building developing & moderately by and developing. poorly by
simulation circuit accomplished. building building
using required simulation circuit simulation circuit
specification. using required using required
specification. specification.

Result and Analyzed and Intermediate The results are Intermediate The results are
analysis (25%) interpreted the results between analyzed to some between novice analyzed poorly
properly using the developing extent according and developing. due to
converter parameters. and to specified incomplete
accomplished. requirements. simulation.

Remarks / Answered the given Intermediate Answered Intermediate Answered the


Answering questions correctly between partially the given between novice given questions
Question (25%) and describe the developing questions and and developing. incorrectly and
remarks properly. and describe the describe the
accomplished. remarks remarks poorly.
moderately.

Sub Total 80
Deduction for late
submission / any
other issue
Total (100%)
10% of Total

You might also like