Professional Documents
Culture Documents
Numerical Integration May Be Used When
Numerical Integration May Be Used When
Find
is difficult to integrate
Approximate the area under the curve as a trapezoid and calculate its area
𝒇 (𝒙)
𝑏
( 𝑓 ( 𝑏 )+ 𝑓 ( 𝑎 ) )( 𝑏− 𝑎)
∫ 𝑓 ( 𝑥 ) 𝑑𝑥 ≅ 2
𝑎
The area under is approximated by the area under the red line
Methods of Numerical Integration: Trapezoidal Rule
(i)
• Partition the integral interval [a,b] to (i+1)
()
sub-intervals of equal width,
¿
Application
Suppose that the velocity of an object at time is given by ), find the position at time
=2
Difficult integration
Demo..
• Open Octave
• Type math_session5a.m
• Interpret the output
Using Octave..
% Calculate the integral of y=x^2 on the interval [0,10] using trapezoidal rule
%% Exact value
% Define the function that needs to be integrated
fun = @(x) x.^2;
a=0;
b=10;
% Find exact value of integration from 0 to 10 using builtin function integral
ExactValue= integral(fun,a,b);
%% Approximated value using trapezoidal rule using n equal subintervals
n=5 % number of subintervals