23
BCA 3 rd Semester BC0043 – 01 Computer Oriented Numerical Methods Q1. Explain the following terms in five sentences each (i) Data error (ii) Conversion error (iii) Numerical error (iv) Round off error (v) Truncation error (vi) Significant digits Solution: Absolute Errors: Definition Absolute error is the numerical difference between its true value of a quantity and its approximate value. If X is the true quantity and X a is its approximate value then the absolute error E a is given by : Relative Errors: Definition The relative error is the absolute error divided by the true value of the quantity and this is denoted by Er 1

SEM 3 BC0043 1 Computer Oriented Numerical Methods

Embed Size (px)

Citation preview

Page 1: SEM 3 BC0043 1 Computer Oriented Numerical Methods

BCA 3rd SemesterBC0043 – 01

Computer Oriented Numerical Methods

Q1. Explain the following terms in five sentences each (i) Data error (ii) Conversion error (iii) Numerical error (iv) Round off error (v) Truncation error (vi) Significant digits

Solution:

Absolute Errors:Definition

Absolute error is the numerical difference between its true value of a quantity and its approximate value. If X is the true quantity and Xa is its approximate value then the absolute error Ea is given by :

Relative Errors:Definition

The relative error is the absolute error divided by the true value of the quantity and this is denoted by Er

Percentage Errors:Definition

1

Page 2: SEM 3 BC0043 1 Computer Oriented Numerical Methods

The percentage error Ep is given by

Observation:1. The relative and percentage errors are independent of the units used while absolute error is expressed in terms of there units.2. if number X is rounded to N decimal places, then

2. Find the real root of the equation x3 – 4x – 9 = 0 using the Bisection method.

Solution:

2

Page 3: SEM 3 BC0043 1 Computer Oriented Numerical Methods

Q3. Find a real root of the equation x3 – 2x – 5 = 0 by the method of regula-falsi position, correct to three decimal places.

Let f (x) = x3 – 2x – 5

Then f (1) = 1 – 2 – 5 = – 6 < 0

f (2) = 8 – 4 – 5 = – 1 < 0

f (3) = 27 – 6 – 5 = 16 > 0

Hence a root lies between 2 and 3.

Take x1 = 2, x2 = 3, f (x1) = – 1, f (x2) = 16, in the method of false position, we get

x3 = x1 – = 2 – = = 2 + = 2.0588

3

Page 4: SEM 3 BC0043 1 Computer Oriented Numerical Methods

Now f(x3) = f(2.0588) = (2.0588)3 – 2 ´ 2.0588 – 5 = – 0.3908 < 0.

Since f(2.0588) < 0 we have that root lies between 2.0588 and 3.0.

Replace x1 by x3, and generate the next approximation using the formula,

x4 = x3 – = 2.0588 – = 2.0813.

Repeating this process, the successive approximations are x5 = 2.0862,x6 = 2.0915, x7 = 2.0934, x8 = 2.0941, x9 = 2.0943 etc.

Hence the root x = 2.094 correct to three decimal places.

Observation: The regula-falsi method is intended to produce faster convergence to the solution. However, it does not always do so. Sometimes, the values of xnew do not improve quickly. One reason for the slow convergence can be the departure from the basic premises on which the false position method is built.

Q4. Find a real root of the transcendental equation cosx – 3x + 1 = 0, correct to four decimal places using the method of iteration.

Let f(x) = cos x – 3x + 1.

Now f(0) = cos 0 – 0 + 1 = 2 > 0 and f + 1 < 0. Therefore a root lies

between 0 and .

Rewriting the given equation cos x – 3x + 1 = 0 as

x = (1 + cos x) = (x) – (i)

(x) = (1 + cos x) (say)

4

Page 5: SEM 3 BC0043 1 Computer Oriented Numerical Methods

Differentiate with respect to x on both the sides,

(x) = and

Since

1, we have < 1.

Therefore | (x) | < 1 for all x in .

Hence the iteration method can be applied to the equation (i) and we start with x0 = 0 or any

choice of x in the interval

x1 = (x0) = (1+ cos 0) = 0.6667

x2 = (x1) = (1+ cos 0.6667) = 0.5953

x3 = (x2) = (1+ cos 0.5953) = 0.6093

x4 = (x3) = (1+ cos 0.6093) = 0.6067

x5 = (x4) = (1+ cos 0.6067) = 0.6072

x6 = (x5) = (1+ cos 0.6072) = 0.6071

x7 = (x6) = (1+ cos 0.6071) = 0.6071

Hence we take the solution as x = 0.6071 correct to 4 decimal place.

5

Page 6: SEM 3 BC0043 1 Computer Oriented Numerical Methods

Q5. Compute the adjoint and the inverse of .

Solution:The minors and cofactors of all elements of the matrix A are calculated in the following table.Element Minor Cofactor

a11 = 1= 9 – 16 = –7

(–1)1+1 (–7) = – 7

a12 = 2= 3 – 4 = –1

(-1)1+2 (–1) = 1

a13 = 3

= 4 – 3 = 1

(–1)1+3 1 = 1

a21 =1

= 6 – 12 = – 6

(–1)2+1 (–6) = 6

a22 = 3

= 3 – 3 = 0

(–1)2+2 0 = 0

A23 = 4

= 4 – 2 = 2

(–1)2+3 (2) = –2

A31 = 1

= 8 – 9 = –1

(–1)3+1 (–1) = –1

A32 = 4

= 4 – 3 = 1

(–1)3+2 1 = –1

a33 = 3

= 3 – 2 = 1

(–1)3+3 1 = 1.

6

Page 7: SEM 3 BC0043 1 Computer Oriented Numerical Methods

The adjoint of a square matrix is the transpose of the matrix obtained by replacing each element of A by its co-factor in A.

Adj A =

= and

det A =

= = –7 + 2 + 3 = –2. Therefore,

A-1 is, A–1 =

= .

Observations: i) Inverse of a matrix is unique.

ii) (AB)–1 = B–1 A–1

iii) AA–1 = A–1A = I .

7

Page 8: SEM 3 BC0043 1 Computer Oriented Numerical Methods

Q6. Find the rank of using elementary row transformation.

The rank of A ≤ min {3, 4} = 3.

A = [Firstly we use the leading entry in the first row 1 to make the leading entries in second and third rows to zero].

Perform,

Perform,

Perform,

The above matrix is in the echelon form having two non-zero rows. Hence the rank of A is 2.

8

Page 9: SEM 3 BC0043 1 Computer Oriented Numerical Methods

ASHOK KUMARRoll No: 521032228BCA 3rd Semester

BC0043 – 02

Computer Oriented Numerical Methods

Q1. Investigate the values of l and m such that the system of equations

x + y + z = 6

x + 2y + 3z = 10

x + 2y + lz = m, may have

(i) Unique solution

(ii) Infinite number of solutions

(iii) No solution.

Solution:

=

Perform,

=

Perform,

9

Page 10: SEM 3 BC0043 1 Computer Oriented Numerical Methods

=

(i) Unique solution: For unique solution, we must have rank A = rank = 3. The rank (A) will be 3 if (l – 3) ¹ 0, since the other two entries in the last row are zero.

If (l -3) ¹ 0 or l

¹ 3 irrespective of the values of m, rank will also be 3. Therefore the system will have unique solution if l¹ 3.

(ii) Infinite solutions: The number of unknown n = 3, we need rank (A) = rank = r < 3. Since first row and second row are non zero, we have that r = 2.

Therefore rank (A) = rank

= 2 only when the last row of is completely zero. This is possible if l – 3 = 0, m -10 = 0.

Therefore the system will have infinite solutions if l = 3 and m = 10.

(iii) No solution: In this case, we must have rank (A) ¹ rank , by case (i) rank(A) = 3 if l¹ 3 and hence if l = 3 we obtain rank (A) = 2. If we impose (m – 10) ¹ 0 other than

will be 3.

Therefore the system has no solution if l = 3 and m¹ 10.

Q2. Apply Gauss-Seidel iteration method to solve the equations

Solution:

10

Page 11: SEM 3 BC0043 1 Computer Oriented Numerical Methods

We write the equation in the form ( after partial pivoting),

And …………………(i)

………………(ii)

………………(iii)

Initial approximation:

First Iteration:

Second Iteration

11

Page 12: SEM 3 BC0043 1 Computer Oriented Numerical Methods

The values in the 2nd and 3rd iterations being practically the same, we can stop the iterations. Hence the solution is

Q3. Find all eigen values and the corresponding eigen vectors of

the matrix

A =

The characteristic equation of A is = 0 where lI = .

That is, = 0.

Expanding we get

(8 – l) [(7–l) (3–l) –16] + 6 [–6 (3–l) + 8] + 2 [24 –2 (7–l) ] = 0

Þ – l3 + 18 l2 – 45 l = 0

That is, l3 – 18 l2 + 45l = 0 on simplification.

Þl (l – 3) (l – 15) = 0

12

Page 13: SEM 3 BC0043 1 Computer Oriented Numerical Methods

Therefore l = 0, 3, 15 are the eigen values of A.

If x, y, z be the components of an eigen vector corresponding to the eigen value l, then we have

(A –l I) X = .

That is, (8 – l) x – 6y + 2z = 0

– 6x + (7–l)y – 4z = 0

2x – 4y + (3 – l)z = 0

Case I: Let l = 0 we have

8x – 6y + 2z = 0 (i)

– 6x + 7y – 4z = 0 (ii)

2x – 4y + 3z = 0 (iii)

Applying the rule of cross multiplication for (i) and (ii)

=

Therefore (x, y, z) are proportional to (1, 2, 2) and we can write x = 1k,y = 2k, z = 2k where k (¹ 0) is an arbitrary constant. However it is enoughto keep the values of (x, y, z) in the simplest form x = 1, y = 2, z = 2(putting k = 1). These values satisfy all the equations simultaneously.

Thus the eigen vector X1 corresponding to the eigen value l = 0 is .

13

Page 14: SEM 3 BC0043 1 Computer Oriented Numerical Methods

Case II: Let l = 3 and the corresponding equations are

5x – 6y + 2z = 0 – (iv)

– 6x + 4y – 4z = 0 – (v)

2x – 4y – 1z = 0 – (vi)

From (iv) and (v) we have

That is,

That is,

Thus X2 = is the eigen vector corresponding to l = 3.

Case III: Let l = 15 and the associated equations are

– 7x – 6y + 2z = 0 (vii)

– 6x – 8y – 4z = 0 (viii)

2x – 4y – 12z = 0 (ix)

From (vii) and (viii) we have

That is,

14

Page 15: SEM 3 BC0043 1 Computer Oriented Numerical Methods

Thus X3 = is the eigen vector corresponding to l = 15.

Therefore l = 0, 3, 15 are the eigen values of A and are the corresponding eigen vectors.

Q4. Use the method of group averages and find a curve of the form y = mxn, that fits the following data:

X 10 20 30 40 50 60 70 80 Y 1.06 1.33 1.52 1.68 1.81 1.91 2.01 2.11

Solution: The required curve is of the form y = mxn

Taking logarithm on both sides, we get

log10y = log10 m+ n log10x

Let log10y = Y, log10m = c and log10x = X, then the equation becomesY = nX +c.

Now e take logarithms of the given pairs of data and divide them into two groups, such that the first group contains the first four values and the remaining constitutes the second group, as follows.

Group-I

x y Y = log10 y X = log10x10 1.06 0.0253 1.0000 20 1.33 0.1239 1.3010 30 1.52 0.1818 1.4771 40 1.68 0.2253 1.6021

SY = 0.5563 SX = 5.3802

15

Page 16: SEM 3 BC0043 1 Computer Oriented Numerical Methods

Group-II

x y Y = log10 y X = log10x50 1.81 0.2577 1.6990 60 1.91 0.2810 1.7782 70 2.01 0.3032 1.8451 80 2.11 0.3243 1.9031

SY = 1.1662 SX = 7.2254

Using the method of group averages, we determine the constants n and c from (5) and (6) as follows.

Substituting the values from the above tables, we get

and

Þ 4c + 5.3802n – 0.5563 = 0 and

4c + 7.2254n- 1.1662 = 0.

Solving we get c = -0.3055 and n = 0.3305.

Therefore m = antilog c = 0.4949.

Hence the required curve is y = (0.4949)x0.3305.

Q5. Evaluate f(15), given the following table of values:

x 10 20 30 40 50y = f(x) 46 66 81 93 101

16

Page 17: SEM 3 BC0043 1 Computer Oriented Numerical Methods

Solution: The value x = 15 is near to the beginning of the table. We use Newton’s forward difference interpolation formula.

Now we put D4 y = 0, we have 124 – 4a = 0. This implies that a = 31.

Using Newton forward difference formula

y(x) = y0 + pDy0 + + where x = x0 + ph.

Here h = 1, x0 = 10, y0 = 46, Dy0 = 20, D2y0 = -5,

D3y0 = 2, D4y0 = -3. Therefore p = .

Therefore

f(15) = 46 +(0.5)(20) + + + = 56. 8672.

Q6. Given that

x 1.0 1.1 1.2 1.3 1.4 1.5 1.6y 7.989 8.403 8.781 9.129 9.451 9.750 10.031

17

Page 18: SEM 3 BC0043 1 Computer Oriented Numerical Methods

Find and at (a) x = 1.1 (b) x = 1.6 using Newton’s forward difference formulae.

The difference table is,

x y D D2 D3 D4 D5 D6

1.0

1.1

1.2

1.3

1.4

1.5

1.6

7.989

8.8403

8.781

9.129

9.451

9.750

10.031

0.414

0.378

0.348

0.322

0.299

0.281

-0.036

-0.030

-0.026

-0.023

-0.018

0.006

0.004

0.003

0.005

-0.002

-.0001

0.002

0.0010.003

0.002

To find and at x = 1.1, we use Newton's Forward differentiation formula, we have

Here h = 0.1, x0 = 1.0, x1 = 1.1. The above formula can be rewritten as

(i)

(ii)

Substituting Dy1 = 0.378, D2y1 = – 0.030, D3y1 = 0.004, D4y1 = – 0.001, D5y1 = 0.003 in (i) and (ii), we get

18

Page 19: SEM 3 BC0043 1 Computer Oriented Numerical Methods

= 3.947

Therefore

Therefore

To find at x = 1.6, we have to use Newton's backward differentiation formula, that is,

… (iii)

and

… (iv)

We use the above difference table and backward difference operator Ñinstead of D.

Here h = 0.1, xn = x6 = 1.6 and Ñy6 = 0.281, Ñ2y6 = – 0.018, Ñ3y6 = 0.005, Ñ4y6 = – 0.002, Ñ5y6 = 0.003, Ñ6y6 = 0.002.

Putting these values in (iii) and (iv), by taking n = 6, we get,

19

Page 20: SEM 3 BC0043 1 Computer Oriented Numerical Methods

Therefore

and

.

20