





















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
These lecture slides are delivered at The LNM Institute of Information Technology by Dr. Sham Thakur for subject of Mathematical Modeling and Simulation. Its main points are: Numerical, Integration, Matlab, Functions, Single, Trapezoid, Integral, Simpson, Rule, Error
Typology: Slides
1 / 29
This page cannot be seen from the preview
Don't miss anything!
You can just fit a straight line
as approximation to actual
function and say what is area
under this straight line.
This area will have large error
as function and straight line
are not same.
f(x ) f(x ) f(x )
(b a) T (^) o
( ) 1 2
1 2 2 2
(b a) T (^) o
( ) 1 2 3 4
2 2 2 2 2 4
f(x ) f(x ) f(x ) f(x )]
[ f(x ) f(x ) f(x ) f(x ) f(x )
(b a) T (^) o
( )
5 6 7 8
1 2 3 4
3
a b x
b
a
gb ga f(x)dx
Strips = 18
Here with 18 Strips of different heights and same Width we get the
area under the curve.
( ) 2 ( ) 2 ( ) 2 ( ) ( )
2
f x 0 f x 1 f x 2 f xN 1 f xN
x Integral
x a i x i N i
, 0 , 1 , 2 , 3 ,,
2
N
b a x
( )
f f ( 2. 5 ) 0. 16 o
f 1 f ( 3. 5 ) 0. 0816
( 4. 5 ) 0. 2
f f
(b a) T o
( ) 1 2
1 2
2 2
fo f ( 2. 5 ) 0. 16
x ( 4. 5 2. 5 )/ 4 0. 5
f 1 f ( 3. 0 ) 0. 111
f 2 f ( 3. 5 ) 0. 0816
f 3 f ( 4. 0 ) 0. 0625
Integral
f(x ) f(x ) f(x ) f(x ) f(x )
( ) 1 2 3 4
2
% Program Name: Integral_1.m
% A MATLAB script file to compute Integral of f(x)
% over an interval [a, b] by trapezoidal rule.
% It calls an external function trapez.m using
% inputs of a, b and N (number of sub-divisions).
N = 8; a = 2.5; b = 4.5;
exact_value = 0.177778;
estimated_value = trapez(a, b, N)
error = abs(100(exact_value -*
estimated_value)/exact_value)
function z = trapez(a, b, N)
% function for integration by trapezoidal rule: trapez.m
% to be used with integral_1.m code.
delta_x = (b - a)/N;
x(1) = a;
if(x(1) == 0), error('A is zero, change it')
end
sum = 0;
f(1) = 1.0/(x(1)^2);
for i=2: N+
x(i) = x(i-1) + delta_x;
f(i) = 1/(x(i)^2);
end
if(N > 1)
for i=2: N, sum = sum + f(i); end
end
z = double((delta_x/2)(f(1) + 2sum + f(N+1)));**
( ) 4 ( ) ( )
0
x
x
k
-. If we have 2I intervals and apply Simpson's rule repeatedly I
2 ( ) 4 ( ) ( )]
[ ( ) 4 ( ) 2 ( ) 4 ( ) 2 ( )
3
( )
2 1
1 2 3 4
N N N
o
b
a
f x f x f x
f x f x f x f x f x
x f x dx
N
b a x
( )
x a i x for i N i
, 0 , 1 , 2 , 3 ,,