Professional Documents
Culture Documents
University of Dhaka
Department of Electrical and Electronic Engineering
EEE-3102: Numerical Technique Laboratory
Section: B-11
Class Roll: SH-073-027
Name:Mahabub-A-Alahi
Date:18-04-2019
Things to do: Read the theory carefully and answer all the questions from Question 1 to Question8
for the given Matlab code. After practicing the matlab example, perform exercise 1 to exercise 3.
The area of a trapezoid is obtained by adding the area of a rectangle and triangle:
1 (y y )
A y0x ( y1 y0 )x 1 0 x
2 2
Example: Given the function
y x2
The exact integral of the function is
b
b
x3 1 3
A x dx (b a3 )
2
a 3 a 3
The integral from a = 0 to b = 3 is
1
A (33 ) 9
3
Question3: Why the results are different? When the results become more accurate?
Ans:The results are different because the value of the x vector,The result has become more accurate
when the step among the values of x vector has taken very small as x=0:0.01:3.
Matlab built-in function for numerical integration:
1. Integral: MATLAB also has a variety of numerical integrators, of which the standard one is
‘integral’. To compute a numerical approximation of the definite integral, we can use the following
command ‘integral(f,a,b)’
Example: To find the numerical integral offunction y x 2 from 0 to 3, we use the following
command
y=@(x) x.^2;
A=integral(y,0,3)
Question4: What is the value of A obtained after running the above code? Is it accurate?
Ans:9. Yes the value of A obtained after the running the avobe code is accurate.
2. Quadrature: Quadrature is a numerical method used to find the area under the graph of a function,
that is, to compute a definite integral.
Example:To find the numerical integral of function y x 2 from 0 to 3, we use the following
command:
y=@(x) x.^2;
A=quad(y,0,3)
Question5: What is the value of A obtained after running the above code? Is it accurate?
Ans:9.0000.yes the value is accurate.
Exercise
Exercise-1: Find the numerical integration of the following function
5
y
x 2x2 x 3
3
from 0 to 5 using (a) trapezoid rule, (b) ‘integral’ matlab function, (c) ‘quad’ matlab function, and (d)
‘quadl’ matlab function.
Ans(a):2.3634
Ans(b):2.3760
Ans(c):2.3760
Ans(d):2.3760