Adeup Co
Adeup Co
co
1
www.gradeup.co
ENGINEERING MATHEMATICS
8 NUMERICAL METHOD
Descartes' rule of sign is used to determine the number of real zeros of a polynomial function.
It tells us that the number of positive real zeroes in a polynomial function f(x) is the same or
less than by an even number as the number of changes in the sign of the coefficients. The
number of negative real zeroes of the f(x) is the same as the number of changes in sign of the
coefficients of the terms of f(-x) or less than this by an even number.
Example: Determine the number of positive and negative real zeros for the given function:
𝑓(𝑥) = 𝑥 5 + 2𝑥 4 −4𝑥 2 + 3𝑥 − 7
2
www.gradeup.co
Sol.
Our function is arranged in descending powers of the variable, if it were not, we would have to
do that as a first step. Second, we count the number of changes in sign for the coefficients of
f(x).
Here are the coefficients of our variable in f(x): 1+2−4+3−7
Our variable goes from positive (1) to positive (2) to negative (-4) to positive (3) to negative
(-7).
Between the first two coefficients there are no change in signs but between our second and
third we have our first change, then between our third and fourth we have our second change
and between our 4th and 5th coefficients we have a third change of coefficients. Descartes´ rule
of signs tells us that the we then have exactly 3 real positive zeros or less but an odd number
of zeros. Hence our number of positive zeros must then be either 3, or 1.
In order to find the number of negative zeros we find f(-x) and count the number of changes
in sign for the coefficients:
𝑓(−𝑥) = −𝑥 5 + 2𝑥 4 −4𝑥 2 − 3𝑥 − 7
Here we can see that we have two changes of signs, hence we have two negative zeros or less
but an even number of zeros.
In total, we have 3 or 1 positive zeros or 2 or 0 negative zeros.
Suppose p(x) is n degree polynomial in x if and suppose 𝑥1 , 𝑥2 . . . . . . . . , 𝑥𝑛 are the roots of p(x)
then,
𝑝(𝑥) = ∑𝑛𝑖=0 𝑎𝑖 𝑥 𝑖 ; where 𝑎𝑛 ≠ 0
𝑝(𝑥) = 𝑎0 𝑥 0 + 𝑎1 𝑥 1 + 𝑎2 𝑥 2 +. . . . . . . . . . +𝑎𝑛 𝑥 𝑛 ; 𝑎𝑛 ≠ 0
𝑝(𝑥) = 𝑎𝑛 (𝑥 − 𝑥1 )(𝑥 − 𝑥2 ) … … . . (𝑥 − 𝑥𝑛 );
𝑝(𝑥) = 𝑎0 𝑥 0 + 𝑎1 𝑥 1 + 𝑎2 𝑥 2 +. . . . . . . . . . +𝑎𝑛 𝑥 𝑛 ≡ 𝑎𝑛 (𝑥 − 𝑥1 )(𝑥 − 𝑥2 ). . . . . . . . (𝑥 − 𝑥𝑛 )
3.1. Properties of the roots:
𝑎𝑛−1
• Sum of roots taken one at a time: ∑𝑛𝑖=1 𝑥𝑖 = (−1)1 ;
𝑎𝑛
𝑎𝑛−2
• Sum of the roots taken two at a time: ∑1≤𝑖<𝑗≤𝑛 𝑥𝑖 𝑥𝑗 = (−1)2 ;
𝑎𝑛
𝑎𝑛−3
• Sum of the roots taken three at a time: ∑1≤𝑖<𝑗≤𝑘≤𝑛 𝑥𝑖 𝑥𝑗 𝑥𝑘 = (−1)3 ;
𝑎𝑛
Similarly,
𝑎0
• Sum of the roots taken all at a time or product of the roots: 𝑥1 ⋅ 𝑥2 ⋅ 𝑥3 ⋅⋅⋅⋅⋅⋅ 𝑥𝑛 = (−1)𝑛
𝑎𝑛
3
www.gradeup.co
Intermediate Value Theorem: If a function f(x) is continuous in closed interval [a,b] and
satisfies f(a)f(b) < 0 ; then there exists at least one real root of the equation f(x) = 0 in open
interval (a , b).
Algebraic Equations are equations containing algebraic terms (different powers of x). For
example: 𝑥 3 −4𝑥 2 + 3𝑥 − 8 = 0
Transcendental equations are equations containing non-algebraic terms like trigonometric,
exponential, logarithmic terms. For example: 𝑠𝑖𝑛𝑥 − 𝑒 𝑥 + 2𝑥 4 = 0
One of the most frequently occurring problems in scientific work is to find the roots of equations
of the form 𝑓(𝑥) = 0 ---------------(1)
In what follows, we always assume that f(x) is a continuously differentiable real-valued function
of a real variable x. We further assume that the equation (1) has only isolated roots, that is,
for each root of (1), there is a neighbourhood which does not contain any other roots of the
equation.
The key idea in approximating the isolated real roots of (1) consisting of two steps:
I. Initial guess: Establishing the smallest possible intervals [a, b] containing one and only
one root of the equation (1). Take a point c inside [a, b] as an approximation to the root of
(1).
II. Iteration Step: Improving the value of the root If this initial guess x0 is not in desired
accuracy, then devise a method to improve the accuracy.
This process of improving the value of the root is called the iterative process and such methods
are called iterative methods.
4.1. Bisection Method
This method is based on the theorem on continuity. Let f(x) = 0 has a root in [a, b], the
function f(x) being continuous in [a, b]. Then, f (a) and f (b) are of opposite signs, i.e.,
f (a). f (b) < 0.
𝒂+𝒃
Let 𝒙𝟏 = , the middle point of [a, b]. If f(x1) = 0, then x1 is the root of f(x) = 0.
𝟐
Otherwise, either f(a). f(x1) < 0, implying that the root lies in the interval [a, x1] or f(x1).
f (b) < 0, implying that the root lies in the interval [x 1, b]. Thus, the interval is reduced
from [a, b] to either [a, x1] or [x1,b]. We rename it [a1, b1].
𝒂𝟏 +𝒃𝟏
Let 𝒙𝟐 = , the middle point of [a1, b1]. If f (x2) = 0, then x2 is the root of f(x) = 0.
𝟐
Otherwise, either f(a1). f(x2) < 0 implying that the root ∈ [a1, x2] or f(x2). f (b1) < 0 ⇒
the root ∈ [x2, b1] and so on. We rename it [a2, b2]. We continue in this manner and the
process is repeated until the root is obtained to the desired accuracy.
Step 1. find a and b such that 𝒇(𝒂)𝒇(𝒃) <0
4
www.gradeup.co
𝑎+𝑏
Step 2. Iteration step: 𝑐 =
2
In the 8th step, an, bn and xn+1 are equal to 3- significant figures. Therefore α = 3.79.
Correct to three significant figures.
4.2. Regula Falsi Method
In this method, we first find a sufficiently small interval [a 0, b0], such that f(a0).f(b0) <
0, by tabulation or graphical method, and which contains only one root α (say) of f(x) =
0, i. e. f’(x) maintains same sign in [a 0,b0].
This method is based on the assumption that the graph of y = f(x) in the small interval
[a0, b0] can be represented by the chord joining (a0, f(a0)) and (b0, f(b0,)). Therefore, at
the point x = x1 = a0 + h0, at which the chord meets the x-axis, we obtain two intervals
[a0, x1] and [x1, b0], one of which must contain the root α, depending upon the condition
f(a0)f(x1) < 0 or f(x1,)f(b0) < 0.
5
www.gradeup.co
Let f(x1,)f(b0) < 0, then α lies in the interval [x1, b0] which we rename as [a1, b1] Again,
we consider that the graph of y = f(x) in [a 1,b1] as the chord joining (a1,f(a1)) and
(b1,f(b1)) . Thus, the point of intersection of the chord with the x-axis (say) x2 = a1 + h1
gives us an approximate value of the root α of the equation f(x) = 0.
Now we are going to establish an iteration formula which may generate a sequence of
successive approximations of an exact root α of the equation f(x) = 0. Geometrically, we
interpret it as follows:
In the above figure, we assume that one root α of f(x) = 0 lies in the small interval [an,
bn] and f(an) < 0 and f (bn) > 0. Let PRQ be the graph of y = f(x) in [a n,bn] intersecting
the x-axis at R.
Thus, x = OR (= α) gives the exact value of the root α. If we consider the curve PRQ as
the chord PQ, in the small interval [an, bn], which intersects the x-axis at C, then OC =
xn+1 = an + hn approximates the root α of the equation f (x) = 0.
Now from similar triangles AQC and CBP, we get,
𝐴𝐶 𝐶𝐵 𝐴𝑄 |𝑓(𝑎𝑛 )|
= 𝑜𝑟 𝐴𝐶 = 𝐶𝐵 = (𝐴𝐵 − 𝐴𝐶)
𝐴𝑄 𝐵𝑃 𝐵𝑃 |𝑓(𝑏𝑛 )|
|𝑓(𝑎𝑛 )| |𝑓(𝑎𝑛 )| |𝑓(𝑎𝑛 )|
𝑜𝑟, 𝐴𝐶 [1 + ]= . 𝐴𝐵 = (𝑏 − 𝑎𝑛 )
|𝑓(𝑏𝑛 )| |𝑓(𝑏𝑛 )| |𝑓(𝑏𝑛 )| 𝑛
|𝑓(𝑎𝑛 )|
∴ 𝐴𝐶 = ℎ𝑛 = (𝑏 − 𝑎𝑛 ).
|𝑓(𝑎𝑛 )| + |𝑓(𝑏𝑛 )| 𝑛
|𝒇(𝒂𝒏 )|
𝑇ℎ𝑢𝑠, 𝒙𝒏+𝟏 = 𝒂𝒏 + 𝒉𝒏 = 𝒂𝒏 + . (𝒃𝒏 − 𝒂𝒏 )
|𝒇(𝒂𝒏 )| + |𝒇(𝒃𝒏 )|
The above formula is known as the iteration formula for Regula-Falsi method.
Step 1. find a and b such that 𝒇(𝒂)𝒇(𝒃) <0
Step 2. Iteration step:
𝑏𝑓(𝑎) − 𝑎𝑓(𝑏)
𝑐=
(𝑏 − 𝑎)
6
www.gradeup.co
7
www.gradeup.co
8
www.gradeup.co
9
www.gradeup.co
Example: Solve cos x = x ex, correct to two significant figures by Secant method correct
up to 2 decimal places.
Sol.
Cos x = x ex …. (iii)
Let f(x) = cos x – x ex
f(0) = 1, f(1) = cos 1 – e = –2.178
As f(0) f(1)< 0 by Intermediate value Theorem the root of real root of the equation f(x)
= 0 lies between 0 to 1
Let x0 = 0 and x1 = 1 be two initial guesses to the equation (iii).
Then
(𝑥1 − 𝑥0 )𝑓(𝑥1 ) (1 − 0)𝑓(1) 2.178
𝑥2 = 𝑥1 − =1− = 1− = 0.31465
𝑓(𝑥1 ) − 𝑓(𝑥0 ) 𝑓(1) − 𝑓(0) −3.178
f(x2) = f(0.31465) cos (0.31465) – 0.31465 e0.31465 = 0.51987
10
www.gradeup.co
5. NUMERICAL INTEGRATION
𝑏 𝑥
Consider the integral 𝐼 = ∫𝑎 𝑓(𝑥)𝑑𝑥 = ∫𝑥 𝑛 𝑦𝑑𝑥
0
• The end points of subintervals are (n+1) points (𝑎 = 𝑥0 , 𝑦0 ), (𝑥1 , 𝑦1 ), (𝑥2 , 𝑦2 ),……. (𝑏 = 𝑥𝑛 , 𝑦𝑛 ).
5.1. Trapezoidal Rule of integration
Let us approximate integrand f by a line segment in each subinterval. Then coordinate of
end points of subintervals are
(x0, y0), (x1, y1), (x2, y2), ............., (xn, yn )
Then from x=a to x=b the area under curve of y = f(x) is approximately equal to sum of
the areas of n trapezoids of each n subintervals.
so the integral
𝑏
I = ∫𝑎 𝑓(𝑥)𝑑𝑥 = (ℎ/2)[𝑦0 + 𝑦1 ] + (ℎ/2)[𝑦1 + 𝑦2] + (ℎ/2)[𝑦2 + 𝑦3 ]+. . . . . . +(ℎ/2)[𝑦𝑛−1 + 𝑦𝑛 ]
Note:
• Trapezoidal rule is known as 2 points formula.
• Is accurate till polynomial of degree 1.
𝑏−𝑎
• The error in trapezoidal rule is − ℎ2 𝑓′′(𝜃) where a < θ < b
12
Where integrand f(x) is a given function and a and b are known which are end points of
the interval [a, b]. Either f(x) is given or a table of values of f(x) are given.
11
www.gradeup.co
Generally
𝒃 𝒙 𝒉
∫𝒂 𝒇(𝒙)𝒅𝒙 = ∫𝒙 𝒚𝒅𝒙= 𝟑 ((𝒚𝟎 + 𝒚𝒏 ) + 𝟒(𝒚𝟏 + 𝒚𝟑 … ) + 𝟐(𝒚𝟐 + 𝒚𝟒 + ⋯ ))
𝒏
𝟎
Note:
• Is accurate till polynomial of degree 2.
𝑏−𝑎
• The error is Simpson 1/3rd rule is − ℎ4 𝑓 ′𝑣 (𝜃)where a < 𝜃 < b
180
Where integrand f(x) is a given function and a, b are known which are end points of the
interval [a, b].
Either f(x) is given or a table of values of f(x) are given.
We are taking three strips at a time Instead of taking one strip as in trapezoidal rule. For
this reason the number of intervals in Simpsons 3/8th rule of Numerical integration must
be multiple of 3.
The length of each subinterval is h = (b – a)/(3m)
The formula is if number of intervals are multiple of 3.
𝑏
𝐼 = ∫ 𝑓(𝑥)𝑑𝑥 = (3ℎ/8)[𝑦0 + 𝑦3𝑚 + 3(𝑦1 + 𝑦2 + 𝑦4 + 𝑦5 +. . . +𝑦3𝑚−1 ) + 2(𝑦3 + 𝑦6 +. . . +𝑦3𝑚−3 )]
𝑎
𝑏 𝑥
Generally, the formula is ∫𝑎 𝑓(𝑥)𝑑𝑥 = ∫𝑥 𝑛 𝑦𝑑𝑥
0
3ℎ
= ((𝑦0 + 𝑦𝑛 ) + 3(𝑦1 + 𝑦2 + 𝑦4 + 𝑦5 + ⋯ ) + 2(𝑦3 + 𝑦6 + ⋯ ))
8
Note:
• Is accurate till polynomial of degree 3.
𝑏−𝑎
The error in Simpson 1/3rd rule is − ℎ4 𝑓 ′𝑣 (𝜃)where a<𝜃<b
80
12
www.gradeup.co
13
www.gradeup.co
Sol.
Rewrite the given equations so that each equation for the variable that has coefficient
largest we get
5x1 + x2 + x3 = 15 (1)
2x1 + 3 x2 + x3 = 12 (2)
x1 + x2 + 2 x3 = 10 (3)
From equation (1) we get x1 in terms of other variables x2 and x3 as
5x1 = 1 5 - x2 - x3
x1 = (1 5 - x2 - x3 )/5 = 3 – 0.2 x2 – 0.2 x3 (4)
From equation (2) we get x2 in terms of other variables x1 and x3 as
2x1 + 3 x2 + x3 = 12
x2 = 4 - (2x1 + x3 )/3 (5)
From equation (3) we get x3 in terms of other variables x1 and x2 as
x1 + x2 + 2 x3 =10
x3 = 5 - 0.5 x1 - 0.5 x2 (6)
Step-1
Putting x2 = 1, x3 = 1 in equation (4) we get
x1 = 3 – 0.2 x2 – 0.2 x3 = 3 – 0.2 – 0.2 = 2.6
Putting x1 = 2.6, x3 = 1 in equation (5) we get
x2 = 4 - (2x1 + x3 )/3 = 4 – (5.2+1)/3 = 1.93333
Putting x2 = 1.93333, x1 = 2.6 in equation (6) we get
x3 = 5 - 0.5 x1 - 0.5 x2 = 5 - 0.5 (2.6) - 0.5 (1.93333) = 2.73333
Step-2
Putting x2 = 1.93333, x3 = 2.73333 in equation (4) we get
x1 = 3 – 0.2 x2 – 0.2 x3 = 3 – 0.2(1.93333) – 0.2 (2.73333 )= 2.066666
Putting x1 = 2.06666, x3 = 2.73333 in equation (5) we get
x2 = 4 - (2x1 + x3)/3 = 4 – (4.13333 + 2.73333 )/3 = 1.71111
Putting x2 = 1.71111, x1 = 2.066666 in equation (6) we get
x3 = 5 - 0.5 x1 - 0.5 x2 = 5 - 0.5 ( 2.066666 ) - 0.5 (1.71111) = 3 .11111
Step-3
Putting x2 = 1.71111, x3 = 3 .11111 in equation (4) we get
x1 = 3 – 0.2 x2 – 0.2 x3 = 3 – 0.2(1.71111) – 0.2 (3 .11111 )= 2.035555
Putting x1 = 2.035555 , x3 = 3 .11111in equation (5) we get
x2 = 4 - (2x1 + x3 )/3 = 4 – ( 4.07111 + 3 .11111)/3 = 1.605925
Putting x2 = 1.605925, x1 = 2.035555 in equation (6) we get
x3 = 5 - 0.5 x1 - 0.5 x2 = 5 - 0.5 (2.035555) - 0.5 (1.605925) = 3.17926
14
www.gradeup.co
Step-4
Putting x2 = 1.605925, x3 = 3 .17926 in equation (4) we get
x1 = 3 – 0.2 x2 – 0.2 x3 = 3 – 0.2(1.605925) – 0.2 (3 .17926)= 2.042962
Putting x1 = 2.042962, x3 = 3 .17926 in equation (5) we get
x2 = 4 - (2x1 + x3 )/3 = 4 – ( 4.08592 + 3 .17926)/3 = 1.57827
Putting x2 = 1.57827, x1 = 2.042962 in equation (6) we get
x3 = 5 - 0.5 x1 - 0.5 x2 = 5 - 0.5 (2.042962) - 0.5 (1.57827) = 3.18938
Many differential equations cannot be solved exactly. For these DE's we can use numerical
methods to get approximate solutions.
The Euler's method is the simplest numerical method, akin to approximating integrals using
rectangles, but it contains the basic idea common to all the numerical methods that will be
studied.
7.1. Euler Method (Forward or Explicit Method)
𝑑𝑦
Note: Differential Equation: = 𝑓(𝑥, 𝑦)
𝑑𝑥
15
www.gradeup.co
NOTE:
Also known as Second order Runge – kutta method.
Order of error is 𝑂(ℎ3 )
7.4. Runge – Kutta Method (fourth order Method)
𝑑𝑦
Note: Differential Equation: = 𝑓(𝑥, 𝑦) ; ℎ𝑒𝑟𝑒 𝑦(𝑥0 ) = 𝑦0
𝑑𝑥
𝑘1 = ℎ𝑓(𝑥0 , 𝑦0 )
ℎ 𝑘1
𝑘2 = ℎ𝑓(𝑥0 + , 𝑦0 + )
2 2
ℎ 𝑘2
𝑘3 = ℎ𝑓(𝑥0 + , 𝑦0 + )
2 2
𝑘4 = ℎ𝑓(𝑥0 + ℎ, 𝑦0 + 𝑘3 )
1
Now k = (𝑘1 + 2𝑘2 + 2𝑘3 +𝑘4 )
6
Solution 𝑦1 = 𝑦0 + 𝑘
NOTE:
Order of error is 𝑂(ℎ4 )
Example : Use the Euler method to solve numerically the initial value problem
u′ = –2tu2, u(0) = 1
With h = 0.2 on the interval [0, 1]. Compute u (1.0)
We have
uj+1 = uj – 2htjuj2, j = 0, 1, 2, 3, 4. [Here x and y are replaced by t and u respectively)
With h=0.2. The initial condition gives u0=1
For j = 0: t0 = 0, u0 = 1
u (0.2) = u1 = u0 – 2ht0u02 = 1.0.
For j = 1: t1 = 0.2, u1 = 1
u (0.4) = u2= u1 – 2ht1u12 = 0.92.
For j = 2: t2 = 0.4, u2 = 0.92
u (0.6) = u3 = u2 – 2ht2u22 = 0.78458.
For j = 3: t3 = 0.6, u3 = 0.78458
u(0.8) = u4 = 0.63684.
16
www.gradeup.co
Similarly, we get
u(1.0) = u5 = 0.50706.
8. REGRESSION ANALYSIS
X : 65 66 67 67 68 69 70 72
Y : 67 68 65 68 72 72 69 71
17
www.gradeup.co
2.9892
𝑦 − 69 = (𝑥 − 68) ⇒ 𝑦 = 0.665𝑥 + 23.78
(2.12)2
9. PROBLEMS
Problem 1: Find a root of the equation 𝑥 3 − 4𝑥 − 9 = 0, using the bisection method correct to
three decimal places.
Ans. 2.706
1
Problem 2: By using the bisection method, find an approximate root of the equation sin 𝑥 =
sin 𝑥
Ans. 17.0621
0.6 2
Problem 9: Use Simpson’s 1/3rd rule to find ∫0 𝑒 −𝑥 . 𝑑𝑥 , by taking seven ordinates.
Ans. 0.5351
1.4
Problem 10: Compute the value of ∫0.2 (sin 𝑥 − log 𝑥 + 𝑒 𝑥 ). 𝑑𝑥 , using Simpson’s 3/8th rule.
Ans. 4.053
Problem 11: Solve the system of equations using Jacobi method.
2𝑥 + 𝑦 + 𝑧 = 10
3𝑥 + 2𝑦 + 3𝑧 = 18
𝑥 + 4𝑦 + 9𝑧 = 16
18
www.gradeup.co
Ans. 3.18
Problem 14: Using modified Euler’s method, find y(0.2) and y(0.4), given
𝑑𝑦
= 𝑦 + 𝑒 𝑥 , 𝑦(0) = 0
𝑑𝑥
Ans. 0.2468, 0.6031
Problem 15: Using Runge-Kutta method of fourth order, solve the given DE at x=0.2 and
x=0.4. Given: y(0) = 1.
𝑑𝑦 𝑦 2 − 𝑥 2
=
𝑑𝑥 𝑦 2 + 𝑥 2
Ans. 1.196, 1.375
****
19
www.gradeup.co
20