Numerical integration:
1. Consider example 21.3 in your book. We have used trapezoidal rule to find the distance (which is
the integration of velocity over time) in class using MATLAB.
a. Use the MATLAB code to find the integral in trapezoidal rule for 𝑛 = 10.
b. Write a MATLAB code to find the integral using Simpson’s 1/3 rule for 𝑛 = 10.
c. The exact integral value is given in the book. Calculate and compare the error in both the
above-mentioned methods.
2𝜋
2. Consider: 𝑦 = 𝑓(𝑥) = 2 sin ( 5 𝑥). [here is 𝑥 is time]
a. What is the period 𝑇?
𝑇1
b. Numerically find the following integral: 𝑌 = ∫0 [𝑓(𝑥)]2 𝑑𝑥. Set 𝑛 = 1000.
𝑇
1 1 2𝜋 2 𝑇
[Hint: assume 𝑔(𝑥) = [𝑓(𝑥)]2 = [2 sin ( 𝑥)] and find 𝑌 = ∫0 𝑔(𝑥) 𝑑𝑥 ]
𝑇 𝑇 5
c. Here, 𝑌 is the RMS value of 𝑦. Using your formula of RMS learnt in EEE201, find the
error.
3. Assume the datapoints are given. To get the data, you will use the following lines in your code:
clc
close all
clear
xi = linspace(-5,5,2001);
yi = sqrt(5^2 – xi.^2);
a. Find the area under the curve using trapezoidal method. Integration limit: -5 to 5.
b. Find the area under the curve using Simpson’s 1/3 method. Integration limit: -5 to 5.
c. Plot the data. This is actually a half-circle with radius 5. So, the exact area under the
1
curve should be 2 × 𝜋 (5)2 . Does your numerical integral value closely match with this
answer?