# curve fitting and solution of equation - v curve fitting and solution of equation 5.1 curve...

Post on 23-Mar-2018

223 views

Embed Size (px)

TRANSCRIPT

UNIT V

Curve Fitting and Solution of Equation

5.1 CURVE FITTING

In many branches of applied mathematics and engineering sciences we come across experiments andproblems, which involve two variables. For example, it is known that the speed v of a ship varies with

the horsepower p of an engine according to the formula = + 3.p a bv Here a and b are the constants tobe determined. For this purpose we take several sets of readings of speeds and the correspondinghorsepowers. The problem is to find the best values for a and b using the observed values of v and .p

Thus, the general problem is to find a suitable relation or law that may exist between the variables xand y from a given set of observed values =( , ), 1, 2,.........., .i ix y i n Such a relation connecting x and yis known as empirical law. For above example, x = v and y = p.

The process of finding the equation of the curve of best fit, which may be most suitable forpredicting the unknown values, is known as curve fitting. Therefore, curve fitting means an exactrelationship between two variables by algebraic equations. There are following methods for fitting acurve.

I. Graphic methodII. Method of group averages

III. Method of momentsIV. Principle of least square.

Out of above four methods, we will only discuss and study here principle of least square.

5.2 PRINCIPLE OF LEAST SQUARES

The graphical method has the drawback in that the straight line drawn may not be unique but principleof least squares provides a unique set of values to the constants and hence suggests a curve of best fit tothe given data. The method of least square is probably the most systematic procedure to fit a uniquecurve through the given data points.

CURVE FITTING AND SOLUTION OF EQUATION 383

Let the curve = + + +2 1................. my a bx cx kx ...(1)

be fitted to the set of n data points 1 1( , )x y , 2 2( , )x y , 3 3( , )x y ,, ( , ).n nx y At =( )ix x the observed(or experimental) value of the ordinate is yi = PiMi and the corresponding value on the fitting curve ( )i

is + + + =2 ........ mi i i i ia bx cx kx L M which is the expected or calculated value. The difference of theobserved and the expected value is = (say)i i i i iP M L M e this difference is called error at =( )ix xclearly some of the error 1 2 3, , ,....., , .......,i ne e e e e will be positive and other negative. To make all errors

positive we square each of the errors i.e. = + + + + + +2 2 2 2 21 2 3 ........ ......i nS e e e e e the curve of best fit isthat for which e's are as small as possible i.e. S, the sum of the square of the errors is a minimum this

is known as the principle of least square. The theoretical values for x1, x2, ..., xn may be 1 2, , ...... .ny y y

5.3 FITTING OF STRAIGHT LINE

Let a straight line = +y a bx ...(1)

which is fitted to the given data points 1 1( , )x y , 2 2( , )x y , 3 3( , )x y ,, ( , )n nx y .

Let 1y be the theoretical value for x1 then = 11 1e y y

= +1 1 1( )e y a bx

= 2 21 1 1( )e y a bx

Now we have = + + + +2 2 2 21 2 3 ............ nS e e e e

== 2

1

n

ii

S e

== 2

1

( )n

i ii

S y a bx

By the principle of least squares, the value of S is minimum therefore,

=

0S

a...(2)

384 A TEXTBOOK OF ENGINEERING MATHEMATICSIII

and =

0S

b...(3)

On solving equations (2) and (3), and dropping the suffix, we have

= + y na b x ...(4)= + 2xy a x b x ...(5)

The equation (3) and (4) are known as normal equations.

On solving equations (3) and (4), we get the value of a and .b Putting the value of a and b inequation (1), we get the equation of the line of best fit.

5.4 FITTING OF PARABOLA

Let a parabola = + + 2y a bx cx ...(1)

which is fitted to a given data 1 1( , )x y , 2 2( , )x y , 3 3( , )x y ,, ( , )n nx y .

Let y be the theoretical value for 1x then = 1 1e y y

= + + 21 1 1 1( )e y a bx cx

= 2 2 21 1 1 1( )e y a bx cx

Now we have=

= 21

n

ii

S e

== 2 2

1

( )n

i i ii

S y a bx cx

By the principle of least squares, the value of S is minimum, therefore

=

0S

a, =

0S

b and

=

0S

c...(2)

Solving equation (2) and dropping suffix, we have

= + + 2y na b x c x ...(3)= + + 2 3xy a x b x c x ...(4)= + + 2 2 3 4x y a x b x c x ...(5)

The equation (3), (4) and (5) are known as normal equations.On solving equations (3), (4) and (5), we get the values of a,b and c. Putting the values of a, b

and c in equation (1), we get the equation of the parabola of best fit.

5.5 CHANGE OF SCALE

When the magnitude of the variable in the given data is large number then calculation becomes verymuch tedious then problem is further simplified by taking suitable scale when the value of x are givenat equally spaced intervals.

CURVE FITTING AND SOLUTION OF EQUATION 385

Let h be the width of the interval at which the values of x are given and let the origin of x and

y be taken at the point 0 0,x y respectively, then putting

= 0( )x x

uh

and = 0v y y

If m is odd then, u = )( interval

term) (middle

h

x

But if m is even then, u = (interval)

21

term) middle two of (middlex

Example 1: Find the best-fit values of a and b so that = +y a bx fits the data given in the table.

: 0 1 2 3 4

: 1 1.8 3.3 4.5 6.3

x

y

Sol. Let the straight line is = +y a bx ...(1)

= = = =

2

2

0 1 0 0

1 1.8 1.8 1

2 3.3 6.6 4

3 4.5 13.5 9

4 6.3 25.2 16

10 16.9 47.1 30

x y xy x

x y xy x

Normal equations are, = + y na b x ...(2)= + 2xy a x b x ...(3)

Here = 5,n = 10,x = 16.9,y = 47.1,xy = 2 30xPutting these values in normal equations, we get

= +16.9 5 10a b= +47.1 10 30a b

On solving these two equations, we get

= 0.72a , = 1.33.bSo required line = +0.72 1.33 .y x Ans.

386 A TEXTBOOK OF ENGINEERING MATHEMATICSIII

Example 2: Fit a straight line to the given data regarding x as the independent variable.

1 2 3 4 5 6

1200 900 600 200 110 50

x

y

Sol. Let the straight line obtained from the given data by = +y a bx ...(1)

Then the normal equations are = + y na b x ...(2)= + 2xy a x b x ...(3)

2

2

1 1200 1 1200

2 900 4 1800

3 600 9 1800

4 200 16 800

5 110 25 550

6 50 36 300

21 91 64503060

x y x xy

x x xyy= = ==

Putting all values in the equations (2) and (3), we get

= +3060 6 21a b= +6450 21 91a b

Solving these equations, we get

= 1361.97a and = 243.42bHence the fitted equation is = 1361.97 243.42 .y x Ans.Example 3: Fit a straight line to the following data:

71 68 73 69 67 65 66 67

69 72 70 70 68 67 68 64

x

y

Sol. Here we from the following table:

x y xy x2

71 69 4899 5041

68 72 4896 4624

73 70 5110 5329

69 70 4830 4761

67 68 4556 4489

65 67 4355 4225

66 68 4488 4356

67 64 4288 4489

x = 546 y = 548 xy = 37422 x2 = 37314

CURVE FITTING AND SOLUTION OF EQUATION 387

Let the equation of straight line to be fitted bey = a + bx ...(1)

And the normal equations are

y an b x= + ...(2)

xy 2a x b x= + ...(3) 8a + 546b = 548

546a + 37314b = 37422Solving these equations, we get

a = 39.5454, b = 0.4242

Hence from (1)

y = 39.5454 + 0.4242x. Ans.

Example 4: Find the least square polynomial approximation of degree two to the data.

0 1 2 3 4

4 1 4 11 20

x

y

Also compute the least error.

Sol. Let the equation of the polynomial be = + + 2y a bx cx ...(1)

2 2 3 4

2 2 3 4

0 4 0 0 0 0 0

1 1 1 1 1 1 1

2 4 8 4 16 8 16

3 11 33 9 99 27 81

4 20 80 16 320 64 256

10 30 120 30 434 100 354

x y xy x x y x x

x y xy x x y x x

= = = = = = = The normal equations are,

= + + 2y na b x c x ...(2)= + + 2 3xy a x b x c x ...(3)= + + 2 2 3 4x y a x b x c x ...(4)

Here n = 5, = 10,x = 30,y = 120,xy = 2 30,x = 2 434,x y = 3 100,x= 4 354.x

Putting all these values in (2), (3) and (4), we get

= + +30 5 10 30a b c ...(5)

= + +120 10 30 100a b c ...(6) = + +434 30 100 354a b c ...(7)

388 A TEXTBOOK OF ENGINEERING MATHEMATICSIII

On solving these equations, we get = 4a , = 2b , = 1.c Therefore required polynomial is

= + + 24 2y x x , errors = 0. Ans.Example 5: Fit a second degree curve of regression of y on x to the following data:

1 2 3 4

6 11 18 27

x

y

Sol. We form the following table:

x y x2 x3 x4 xy x2y

1 6 1 1 1 6 6

2 11 4 8 16 22 44

3 18 9 27 81 54 162

4 27 16 64 256 108 432

x = 10 y = 62 x2 = 30 x3 = 100 x4 = 354 xy = 190 x2y = 644

The equation of second degree parabola is given byy = a + bx + cx2 ...(1)

And the normal equations are

y 2an b x c x= + + ...(2)

xy 2 3a x b x c x= + + ...(3)

2x y 2 3 4a x b x c x= + + ...(4)

4 10 30 62

10 30 100 190 3, 2, 1

30 100 354 644

a b c

a b c a b c

a b c

+ + = + + = = = =+ + =

Hence y = 3 + 2x + x2. Ans.

Example 6: By the method of least squares, find the straight line that best fits the following data:

1 2 3 4 5 6 7

14 27 40 55 68 77 85

x

y

Sol. The equation of line isy = a + bx ...(1)

The normal equations are y an b x = + ..

Recommended