Professional Documents
Culture Documents
Dse 1 Unit 4
Dse 1 Unit 4
1: Numerical Techniques
Techniques-Unit-4
Numerical integration: The basic problem in numerical integration is to
compute an approximate solution to a definite integral to a given degree of
accuracy. It is useful when the explicit function is not known and some samples of
the function are available or the function is complicated to find the integration.
integration
Trapezoid rule: In numerical analysis
analysis, the trapezoidal rule (also known as
the trapezoid rule or trapezium rule) is a technique
technique for approximating the definite
integral.
The trapezoidal rule works by approximating the region under the graph of the
function as a trapezoid and calculating its area.
x 0 2 4 6 8
f(x) 3 7 11 9 3
Solution: The Trapezoidal Rule formula for n = 4 subintervals has the form
Manas Ku Mishra, Asst. Prof. of Comp. Sc., FM (A) College, BLS. Page 2 of 9
Simpson's method is a method for numerical integration, the
nd
numerical approximation of definite integrals. Specifically, it is 2 degree polynomial
approximation for n+1 values x0, x1, .................. xn boudnding n eaually spaced
divisions. It takes 2 strips for local integration.
The Simpson’s 1/3 rule can be written as follows:
y0 = f(x0) = f0
x 0 1 2 3 4
f(x) 2 7 12 10 5
Manas Ku Mishra, Asst. Prof. of Comp. Sc., FM (A) College, BLS. Page 3 of 9
Example: Find Solution of an equation 1/x using Simpson's 3/8 rule for x = 1 to 2.
Take Step value (h) = 0.25
Degree
of
Step Common
approxi Formula Remark
size, h name
mation,
n
(b – a)/n n is any
Trapezoidal h/2[(y0+yn)
1 = positive
rule +2(y1+y2+y3+…. +yn-1)]
(xn–x0)/n integer
Manas Ku Mishra, Asst. Prof. of Comp. Sc., FM (A) College, BLS. Page 4 of 9
Gaussian quadrature: The Gauss quadrature rule of approximating integrals is
c1 = 1 x1 = -1/√3 = −0.577350269
2
c2 = 2 x2 = 1/√3 = 0.577350269
√3
c1 = 5/9 = 0.555555556 x1 = 5
= −0.774596669
3 c2 = 8/9 = 0.888888889 x2 = 0
c3 = 5/9 = 0.555555556 x = √3 = 0.774596669
3
5
I = =
Example-1:
= 1 * (−0.577350269) + 1 * 0.577350269
=0
Manas Ku Mishra, Asst. Prof. of Comp. Sc., FM (A) College, BLS. Page 5 of 9
Example-2:
=0
Now let us find evaluate the integral by using 2 point Gaussian quadrature rule.
put t = (2x-0-1)/(1-0)
= 2x-1
x = (t+1)/2
dx = ½ dt
= ½ [1*e(−0.577350269+1)/2 + 1*e(0.577350269+1)/2]
= 1.717896
Euler’s method: For many of the differential equations, we need to solve in the
real world, there may not exist an algebraic solution. As a result, we need to find an
approximate solution using numerical methods for solving such DEs. The Euler
method is a first-order numerical procedure for solving ordinary differential equations
(ODEs) with a given initial value. The Euler method is a first-order method, which
means that the local error (error per step) is proportional to the square of the step
size, and the global error (error at a given time) is proportional to the step size.
Consider a differential equation dy/dx = y′ = f(x, y) with initial condition y (xo) = yo,
then approximate solution to this equation by using Euler’s method is as follows:
Manas Ku Mishra, Asst. Prof. of Comp. Sc., FM (A) College, BLS. Page 6 of 9
h indicates step size. Choosing smaller values of h leads to more accurate results
and more computation time.
n xn yn
2 0.5 0.0625
Example: Given dy/dx = y – 2x2 + 1, y(0) = 0.5, step size h = 0.2 , Find y(0.2)
Solution: Given x0 = 0, y0 = 0.5, h = 0.2
So, y1,p = y0 + h f(x0, y0)
= 0.5 + 0.2*(0.5 – 2*02 + 1) = 0.5+ 0.2 * 1.5 = 0.5 + 0.3 = 0.8
Now, y1,c = y0 + h/2 [f(x0, y0) + f(x1, y1,p)
= 0.5 + 0.2/2 * [(0.5 – 2*02 + 1) + (0.8 - 2*0.22 + 1)]
= 0.5 + 0.1 * [(1.5) + (0.8 - 0.08 + 1)]
Manas Ku Mishra, Asst. Prof. of Comp. Sc., FM (A) College, BLS. Page 7 of 9
= 0.5 + 0.1 * (1.5+1.72)
= 0.5 + 0.1 * 3.22
= 0.5 + 0.322
= 0.822
So, y(0.2) = 0.822 (ans)
Example: Find y(0.2) for y′ = (x-y)/2, y(0) = 1, with step length 0.1 by using both
second order and fourth order R-K method.
Manas Ku Mishra, Asst. Prof. of Comp. Sc., FM (A) College, BLS. Page 8 of 9
Solution by using Forth order R-K method:
k1 = hf(x0,y0) = (0.1)f(0,1) = (0.1)*(-0.5) = -0.05
k2 = hf(x0+h/2,y0+k1/2) = (0.1)f(0.05,0.975) = (0.1)*(-0.4625) = -0.04625
k3 = hf(x0+h/2, y0+k2/2) = (0.1)f(0.05,0.97688) = (0.1)*(-0.46344) = -0.04634
k4 = hf(x0+h, y0+k3) = (0.1)f(0.1,0.95366) = (0.1)*(-0.42683) = -0.04268
y1 = y0 + (k1+2k2+2k3+k4)/6
y1 = 1 + [-0.05+2(-0.04625) + 2(-0.04634) + (-0.04268)]/6 = 0.95369
∴ y(0.1) = 0.95369
Manas Ku Mishra, Asst. Prof. of Comp. Sc., FM (A) College, BLS. Page 9 of 9