0% found this document useful (0 votes)
139 views16 pages

CH-6, Math-5 - Lecture - Note

This document discusses polynomial interpolation and curve fitting. It introduces interpolation as a technique to study the behavior of a function using a few discrete data points. Polynomial interpolation fits a polynomial to a set of (x, f(x)) points. The Newton divided difference form provides a convenient way to determine the coefficients of the interpolating polynomial. The divided differences are defined recursively and allow the interpolating polynomial to be written in terms of the divided differences. Both forward and backward divided difference interpolation formulas are presented to fit a polynomial to a discrete data set.

Uploaded by

Rudra Dhar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
139 views16 pages

CH-6, Math-5 - Lecture - Note

This document discusses polynomial interpolation and curve fitting. It introduces interpolation as a technique to study the behavior of a function using a few discrete data points. Polynomial interpolation fits a polynomial to a set of (x, f(x)) points. The Newton divided difference form provides a convenient way to determine the coefficients of the interpolating polynomial. The divided differences are defined recursively and allow the interpolating polynomial to be written in terms of the divided differences. Both forward and backward divided difference interpolation formulas are presented to fit a polynomial to a discrete data set.

Uploaded by

Rudra Dhar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Fall 21-22

Numerical Methods For Science and Engineering


Lecture Note 6
Interpolation & Curve Fitting

6.1 Introduction
In many occasions we are given only a few discrete set of values. To study the behavior of the
function through those points a technique known as interpolation is introduced. Polynomial is a
function which is easy to handle. The method of finding a polynomial that fits a selected set of
points ( x ,f (x )) which behaves nearly the same way as the true function will be considered.

6.2 Polynomial Interpolation


Given the values of a function f(x) at (n+1) distinct points 0 1 2
x , x , x ,⋅⋅⋅, x
n we can construct a
unique polynomial of degree less than equal to n which satisfies the conditions
p( x i )=f ( x i ), i=0 , 1 , 2, 3 ,⋅⋅⋅, n
General Form : An nth degree polynomial can be taken as
2 3 n
p( x )=a0 +a1 x+a2 x +a 3 x +⋅⋅⋅+an x
To fit this polynomial to (n+1) set of points we have to solve (n+1) simultaneous equations and
is very tedious.

Newton Interpolating Polynomial : A form which is convenient to use is suggested by Newton


is
p( x )=a0 +a1 ( x−x 0 )+a2 ( x−x 0 )(x −x1 )+⋅⋅⋅+an ( x−x 0 )(x −x1 )⋅¿⋅( x−x n−1 )
The unknown coefficients can be determined successively by substituting the set of values given.
This form of representation is convenient in determining the unknown coefficients and plays an
important role in the derivation of an interpolating polynomial.

Example 6.1 : Find the polynomial of least degree which takes the values
x 1 1 2 5
f(x) 9 3 6 39
Solution: There are four set of values given. Let the approximated polynomial be
f (x )≈a 0 +a 1 ( x+1)+a2 ( x+1 )( x−1)+a 3 ( x +1)( x−1)( x−2)
Using the values of x and f(x) in turn, we get
From x=−1 , f (−1)=9 , we get 9=a0
1
From x=1 , f (2 )=6 , we get 3=9+a1 (2) or
a1 = 2 93−9 )=−3
1
From x=2 , f (2 )=3 , we get 3=9−3(3 )+a 2 (3 )(1) or a2 = 3 (6)=2

From x=5 , f (2 )=39 , we get 39=9−3(6 )+2(6)(4 )+a 3 (6 )(4 )(3 ) or


1
a3 = 72 (39−39 )=0
Thus the polynomial is f (x )=9−3( x+1)+2(( x +1)( x−1 )
2
=9−3 x−3+2 x −2
Fall 21-22

2
=2 x −3 x+4
6.3 Divided Differences
Interpolating polynomials can be expressed in a variety of forms, and among these the Newton
divided difference form is probably the convenient and efficient one.
Let the values of f (x ) corresponding to the arguments
x 0 , x 1 ,⋅⋅⋅, xn be
f (x 0 ), f ( x 1 ),⋅⋅⋅, f ( x n ) .
x
The first divided difference for arguments 0 and x 1 is defined by :
f (x 1 )−f ( x 0 )
f [ x 0 , x 1 ]=
x 1−x 0
x
The second divided difference for arguments 0 , x 1 and x 2 is defined as :
f [ x 1 , x 2 ]−f [ x 0 , x 1 ]
f [ x 0 , x 1 , x 2 ]=
x 2 −x 0
Similarly higher divided differences are defined. The nth divided differences with (n+1)
f [ x 1 , x2 ,⋯, x n ]−f [ x 0 , x 1 ,⋯, x n−1 ]
f [ x 0 , x 1 , x 3 ,⋯, xn ]=
arguments is defined by x n −x 0
Property 1: The divided differences are symmetric about their arguments i.e. does not depend
on the order of the arguments.
Property 2: The nth divided differences of a polynomial of degree n is constant

6.4 Interpolation Formula using Divided Differences

6.4.1 Newton Divided Difference Interpolation


The interpolating polynomial p( x) through the points x 0 , x1 , x 2 ,⋅⋅⋅, x n can be written in
the Newton form as
f (x )≈ p( x )=a0 +a1 ( x−x 0 )+a 2 ( x−x 0 )( x−x 1 )+⋅⋅⋅+a n ( x−x 0 )( x−x 1 )⋅¿⋅( x−x n−1 )
Substituting x=x 0 , x 1, x 2 ,⋅¿⋅, x n , we have
f (x 0 )=a0
f ( x 1 )−f ( x 0 )
a1 = =f [ x0 , x1 ]
f (x 1 )=f ( x 0 )+a1 ( x 1 −x 0 ) or x1 −x 0
f (x 2 )=f ( x 0 )+f [ x 0 , x 1 ]( x 2−x 0 )+a 2 ( x 2−x 0 )( x 2 −x1 )
f ( x 2 )−f ( x 0 )
( x 2−x 1 ) a2= −f [ x 0 , x 1 ]=f [ x 2 , x 0 ]−f [ x 0 , x1 ]
or ( x 2 −x 0 )
f [ x 2 , x 0 ]−f [ x 0 , x1 ] f [ x1 , x 2 ]−f [ x 0 , x 1 ]
a2 = = =f [ x 0 , x 1 , x 2 ]
or ( x 2−x 1 ) ( x 2 −x 0 )

Continuing the process it can be shown that n 0 1 2 a =f [ x , x , x ,⋅⋅⋅, x ]


n
Thus in terms of the divided differences interpolating polynomial can be written as
Fall 21-22

p( x )=f ( x 0 )+f [ x 0 , x1 ]( x−x 0 )+f [ x 0 , x 1 , x 2 ]( x−x 0 )( x−x 1 )+⋯


+f [ x 0 , x 1 , x2 ,⋯, x n ]( x−x 0 )( x−x 1 )⋯( x−x n−1 )
This is known as Newton’s divided difference interpolation formula.
If f (x ) is a polynomial through (n+1) points
x 0 , x1 , x 2 ,⋅⋅⋅, x n , then the polynomial g( x )
through those points with an extra point
x=x n+1 is
g( x )=f ( x )+b (x −x0 )( x−x 1 )⋅¿⋅( x−x n )
The constant b can be calculated by substituting
x=x n+1 .
Example 6.2
The table below gives the values of x and f(x):

x: 1 1 2 3 4
f(x) : 7 1 8 29 68

(i) Construct a divided-difference table for the above data.


(ii) Find the polynomial of least degree that incorporates the values in the table and find
f (5 ) .
(iii) Find by linear interpolation a real root of f (x )=0 .
(iv) Find the polynomial g( x ) that takes the values of the above table and g(5)=203 .
Solution:
(i) The divided difference table for the given data is as follows:

x f(x) f1[ ] f2[ ] f3[ ] f4[ ]


-1 -7
1 -1 3
2 8 9 2
3 29 21 6 1
4 68 39 9 1 0

(ii) The needed differences are enclosed by the double lined box.
By Newton’s divided difference formula, we get
f (x )=−7+3 (x +1 )+2(x +1 )(x−1)+1( x+1 )( x−1)( x−2 )
and f (5 )=−7 +3(6 )+2(6)( 4 )+1(6)( 4 )(3)
=−7+ 18+48+72=131
(iii) Here f (1 )f (2)=(−1)(8 )=−8<0
Thus a root is in (1, 2).
From the table, we have
x f(x) 1DD
1 1
2 8 9
Thus the root is the solution of
Fall 21-22

f (x )=−1+9( x−1 )=0


1
or
x=1+ 9 ≈1 .111
(iv) The polynomial g( x ) can be written as
g( x )=f ( x )+b (x +1 )( x−1)( x−2)( x−3 )( x−4 )
where b is a constant.
Taking x=5 , we have
g(5)=f (5 )+b(6 )(4 )(3 )(2)(1)
or 203=131+144 b
203−131 72 1
b= = =
Hence 144 144 2
The required polynomial is
1
g( x )=f ( x )+ 2 (x +1 )(x −1)( x−2)( x−3 )( x−4 )

6.4.2 Newton Backward Divided Difference Formula

If the nodes are reordered as


x n , x n−1 ,⋅⋅⋅, x 0 , the divided differences interpolating polynomial
can be written as

p( x )=f ( x n )+f [ x n , x n−1 ]( x−x n )+f [ x n , x n−1 , x n−2 ]( x−x n )( x−x n−1 )+⋯
+f [ x n , x n−1 , x n−2 ,⋯, x 0 ]( x−x n )( x−x n−1 )⋯( x−x 0 )
and is called the Newton Backward Divided Difference formula.

6.5 Lagrange Interpolating Polynomial

Lagrange polynomial of degree one passing through two points ( x 0 , y 0 ) and ( x1 , y 1 ) is


written as
x−x 1 x−x 0
L1 ( x )= y0+ y
x 0 −x 1 x 1 −x 0 1
Lagrange polynomial of degree two passing through three points ( x 0 , y 0 ) , ( x1 , y 1 ) and
( x 2 , y 2 ) is written as
( x−x 1 )( x −x 2 ) ( x−x 0 )( x−x 2 ) ( x−x 0 )( x−x 1 )
L2 ( x )= y 0+ y1+ y2
( x 0 −x 1 )( x 0 −x 2 ) (x 1 −x 0 )( x1 −x 2 ) ( x 2−x 0 )( x 2 −x1 )
Lagrange polynomial of degree three passing through four points ( x 0 , y 0 ) , ( x1 , y 1 ) ,
( x 2 , y 2 ) and ( x3 , y 3 ) is written as
( x−x 1 )(x− x2 )( x−x 3 ) ( x−x 0 )( x −x2 )( x−x 3 )
L3 ( x )= y0 + y1
(x 0 −x 1 )( x0 −x 2 )( x 0−x 3 ) ( x 1−x 0 )( x 1−x 2 )( x 1−x 3 )
Fall 21-22

( x−x 0 )( x−x 1 )( x−x 3 ) ( x−x 0 )(x −x1 )( x−x 2 )


+ y2+ y3
( x 2−x 0 )( x 2 −x1 )( x 2−x 3 ) ( x3 −x 0 )( x 3−x 1 )( x 3−x 2 )
In general, the Lagrange polynomial of degree n passing through (n+1) points ( x0 , y0 ) ,
( x1 , y 1 ) ,    , ( x n , y n ) is written as
( x−x 1 )( x −x2 )⋅⋅⋅( x−x n ) ( x−x 0 )( x−x 2 )⋅⋅⋅( x−x n )
Ln ( x )= y 0+ y1
( x0 −x 1 )( x 0−x 2 )⋅⋅⋅( x 0 −x n ) ( x 1 −x 0 )( x 1 −x 2 )⋅⋅⋅( x 1 −x n )
( x −x 0 )( x−x 1 )⋅⋅⋅( x−x n−1 )
+⋅⋅⋅+ y
( x n −x 0 )( x n −x 1 )⋅⋅⋅( x n−x n−1 ) n

Example 6.3
The following table gives the values of an empirical function f(x) for certain values of x.

x 0 1 2 3
f(x) 4 1 8 29

Use the Lagrange interpolation formula to estimate


(i) the value of f (2 .5)
(ii) the root of the equation f(x) = 0 to 3 decimal places.

(i) Applying Lagrange’s formula, we have


( x−1)( x−2 )(x−3) ( x−0 )( x−2)( x−3 )
f (x )=−4 −1
(0−1)(0−2)(0−3 ) (1−0 )(1−2 )(1−3)
( x−0 )( x−1)( x−3 ) ( x−0 )( x−1)( x−2 )
+8 +29
(2−0)(2−1 )(2−3 ) (3−0)(3−1)(3−2)
(1.5)(0.5)(−0.5) (2.5)(0.5)(−0.5)
f (2.5)=−4 −1
and (−1)(−2)(−3) (1)(−1)(−2)
(2.5)(1.5)(−0.5 ) (2.5)(1 .5)(0.5)
+8 +29
(2)(1)(−1) (3)(2)(1)
=−0. 25+0 . 3125+7 .5+9 .0625
=16 . 625
(ii) Let y=f ( x ) . Then the root of f (x )=0 corresponds to y=0 . To find the root let us
use the Lagrange formula in reverse order i.e. consider the polynomial in terms of y.

y 4 1 8 29
x 0 1 2 3
Then
( y +4 )( y−8 )( y−29 ) ( y +4 )( y +1)( y−29 ) ( y+4 )( y +1)( y−8)
x=0+1 +2 +3
(−1+4 )(−1−8 )(−1−29) (8+4 )(8+1)(8−29 ) (29+4 )(29+1)(29−8 )
When y=0 , then
Fall 21-22

(4)(−8 )(−29 ) (4 )(1)(−29) (4 )(1 )(−8 )


x=0+1 +2 +3
(3)(−9)(−30 ) (12)(9)(−21) (33 )(30)(21 )
=1 .1457+0 .1023−0 .0046
=1 .2434

Exercise 6.4 The upward velocity of a rocket is given as a function of time below:
t (s) 10 15 20 22.5 30
v(t) (m/s) 227 363 517 603 903
i. Construct a divided-difference table for the above data.
ii. Determine the value of the velocity at t=17 seconds using two suitable points.
iii. Determine the value of the velocity at t=17 seconds using three suitable points.
iv. Find the polynomial which passes through all the points and find v(35).
v. Use Lagrange interpolating polynomial to estimate
a. the value of t for v ( t )=400 using two suitable points.
b. the value of t for v ( t )=400 using three suitable points.
vi. Write down MATLAB codes using “polyfit(x, y, n)” and “polyval(p, x)” for the
following.
a. Find the polynomial of least degree that incorporates all the values in the table. and
estimate the velocities corresponding to .t=17 , 25∧35 seconds.
b. Draw the figure showing fitted polynomial and the given points.

Solution:
i.
t v(t) v1[ ] v2[ ] v3[ ] v4[ ]
10 227
15 363 27.2
20 517 30.8 0.36
22.5 603 34.4 0.48 0.0096
30 903 40.0 0.56 0/0043 0.0002

ii. Note that 15<17< 20 and using the relevant part of the table
t v(t)
Fall 21-22

15 363
20 517 30.8
we have the linear polynomial v ( t )=363+30.8 ( t−15 ) .
And v ( 17 ) ≈ 363+30.8 ( 2 )=424.6 .

iii. Note that 17−10=7∧22.5−17=5.5. Thus we may choose points corresponding to


t=15 , 20∧22.5. Collecting the relevant part of the table

t v(t) v1[ ] v2[ ]


15 363
20 517 30.8
22.5 603 34.4 0.48
The polynomial with 3 points is v ( t )=363+30.8 ( t−15 ) +0.48 ( t −15 ) ( t−20 ) .
And v ( 17 ) =363+30.8 ( 2 )+ 0.48 ( 2 )(−3 )=421.72 .

iv. Polynomial passing through all the points is


v ( t )=227+27.2 ( t−10 ) +0.36 ( t−10 ) (t−15)+0.0096 ( t−10 ) ( t−15 ) (t−20)
−0.0002 ( t−10 ) (t−15 )( t−20 )( t−22.5 )
And v ( 35 ) =227+27.2 ( 25 )+ 0.36 ( 25 ) ( 20 )+ +0.0096 ( 25 ) ( 20 ) (15)
−0.0002 ( 25 ) ( 20 )( 25 )( 12.5 )
¿ 1140.25 .

v. For a given v we need to calculate the value of t, so consider the Lagrange polynomial in
reverse order.
v 363 517
a. With two points consider
t 15 20

( v −517 ) (v −363)
and the Lagrange polynomial is t=15 +20
(363−517) (517−363)
For v=400,
15(−117) 20(37) 2495
t= + = =16.2013 .
−154 154 154

b. With three points consider


v 227 363 517
t 10 1520
and the Lagrange polynomial is
( v−363 ) (v−517) (v −227) ( v−517 ) (v −227)(v−363)
t=10 + 15 +20 .
(227−363 ) (227−517) (363−227)(363−517) (517−227)(517−363)
For v=400,
10 ( 37 ) (−117 ) 15(173)(−117 ) 20(173)(37)
t= + +
(−136 ) (−290) (136)(−154) ( 290 ) (154 )
¿−1.0976+14.4965+2.8665=16.2654 .

vi. MATLAB CODES


Fall 21-22

a. >> t=[10 15 20 22.5 30];


>> v=[227 363 517 603 903];
>> pt=polyfit(t,v,4)
pt = -0.0002 0.0240 -0.4267 28.2000 -34.2000

>> t1=[17 25 30];


>> v1=polyval(pt,t1);
>> % Output value of v for t
>> t_v =[t1',v1']
t_v = 17.0000 421.9875 1200
Graph of v against t

25.0000 695.8000
30.0000 903.0000 1000

b. >> t=[10 15 20 22.5 30]; 800


>> v=[227 363 517 603 903]; Velocity v(t)

>> pt=polyfit(t,v,4);
600
>> t1=linspace(5,35,500);
% generates 500 values
400
>> v1=polyval(pt,t1); %
calculates values of v
200
>> plot(t, v,'o',t1,v1);
>> title('Graph of v against t');
0
>> xlabel('Time (t)'); 5 10 15 20 25 30 35

>> ylabel('Velocity v(t)'); Time (t)


Fall 21-22

Exercise 6.1

1. The table below gives the velocity v at time t

t(s) 1 3 4 7
v(m/s 3 5 21 201
)
i. Construct a divided-difference table for the above data.
ii. Find the polynomial of least degree that incorporates the values in the table.
iii. Find the acceleration at time t=6 s.
iv. Find the distance function when S ( 0 )=2.

2. . The table below gives the values of x∧f (x)


x -2 0 3 6 7
f(x) 2 -4 -58 842 1802
i. Construct a divided-difference table for the above data.
ii. Find the polynomial which passes through all the points of the table and find f (5).
iii. Find the polynomial g( x ) that takes the values of the above table and g ( 5 )=549.
iv. Use Lagrange interpolating polynomial to estimate
a. the value of f ( 4 ) using two suitable points.
b. the value of x for f( x )=0 using three suitable points.
v. Write down MATLAB codes using “polyfit(x, y, n)” and “polyval(p, x)” for the
following.
Find the polynomial of least degree that incorporates all the values in the table and estimate
the values corresponding to x=1 , 5∧9.

3. The table below gives the values of x∧f (x)

x 4 5 7 9 11
f (x) 62 95 185 307 461

i. Construct a divided-difference table for the above data.


ii. Find the polynomial which passes through all the points of the table and find f (12).
iii. Find the polynomial g( x ) that takes the values of the above table and g ( 12 )=1280.
iv. Use Lagrange interpolating polynomial to estimate
Fall 21-22

a. the value of f ( 8 ) using two points.


b. the value of x for f( x )=380 using three points.
v. Write down MATLAB codes using “polyfit(x, y, n)” and “polyval(p, x)” for the
following.
Find the polynomial of least degree that incorporates all the values in the table and estimate
the values corresponding to x=1 , 3∧5.

4. The table below gives the values of x and f(x):

i. x -2 -1 0 3
Construct a f(x) 12 14 10 22 divided-difference table
for the above data.
ii. Find the polynomial of least degree that incorporates the values in the table and find f (8).
iii. Given g ( 8 )=1202, find the polynomial g( x ) that also takes the values of the above
table.
iv. Use Lagrange interpolation formula to find
a. a real root of f ( x )=0 using linear approximation.
b. a real root of f ( x )=0 using all the points.
v. Write down MATLAB codes using “polyfit(x, y, n)” and “polyval(p, x)” to plot the
figure showing fitted polynomial and the given points.
Fall 21-22

Curve Fitting

6.6 Introduction

The purpose of curve fitting is to find the parameters values of the model function that closely
match the data’s. The fitted curves can be used to estimate the values of one variable
corresponding to the specified values of the other variable. The method of least squares may be
one of the most systematic procedure to fit a curve through the given data points. In polynomial
interpolation we have considered the problem of finding polynomial of least degree which agree
with the tabulated data’s. Spline interpolation is a form of polynomial interpolation where the
interpolant is a piecewise polynomial called spline. This means that between two points there is a
piecewise polynomial curve which joined smoothly to the neighboring curves. Cubic spline has
different important applications. One of the important applications is in Computer graphics.

6.7 Curve Fitting by Least Squares Method

The method of least squares may be one of the most systematic procedures to fit a curve through
given data points.
Consider the problem of fitting a set of n data points
( x r , y r ), r =1. 2 .3 ,⋯, n
to a curve Y =f ( x ) whose values depends on m parameters 1 2 3
c , c , c ,⋯, c
m . The values of
the function at a point depends on the values of the parameter involved. In least square method
we determine a set of values of the parameter
c 1 , c 2 , c 3 ,⋯, c m such that the sum of the squares
of the error
n
2
E(c 1 , c 2 ,⋯ , c m )= ∑ [ f (x i , c 1 , c 2 ,⋯ , c m )− y i ]
ii=1
is minimum.
The necessary conditions for E to have a minimum is that
∂E
=0 , r=1,2,3 ,⋯, m
∂c r
This condition gives a system of m equations, called normal equations, in m unknowns
c 1 , c 2 , c 3 ,⋯, c m .
Fall 21-22

If the parameters appear in the function in non-linear form, the normal equations become non-
linear and are difficult to solve. This difficulty may be avoided if f (x ) is transformed to a
form which is linear in parameters.

n
∑ 1=n
Note that i=1 .

Example 6.5
Given the following set of values of x and y:

X 1 2 3 4 5 6
Y 1.553 1.638 0.685 0.42 0.679 0.164
8

A physicist wants to approximate the data using a periodic curve y=a+b sin x .
Estimate the parameters a and b to 2 decimal places using least squares method.

Solution

Sum of the square deviation is


6
E(a , b )=∑ (a+b sin x i− yi )2
i=1
At minimum,
∂E ∂E
=0 =0
∂a and ∂b
These conditions gives
6
∑ 2(a+b sin xi − y i ) 1=0
i=1
6
∑ 2(a+b sin xi − y i ) sin x i =0
i=1
which can be rearranged as
a ∑ 1+b ∑ sin x i=∑ y i
a ∑ sin x i +b ∑ sin2 x i =∑ y i sin xi
Fall 21-22

The sum can be calculated as follows

X y sin x sin2x y sin x


1 1.553 0.8415 0.7081 1.3068
2 1.638 0.9093 0.8268 1.4894
3 0.685 0.1411 0.0199 0.0967
4 -0.428 -0.7568 0.5727 0.3239
5 -0.679 -0.9589 0.9195 0.6511
6 0.164 -0.2794 0.0781 -0.0458
Sum 2.933 -0.1032 3.1251 3.8221

The normal equations are


6 a 0.1032 b = 2.933
0.1032 a + 3.1251 b = 3.8221
By dividing each equation by the coefficient of a, we have
a 0.0172 b = 0.4888
a 30.282 b = 37.0359
Subtracting the equations
30.2648 b = 37.5247
Solving we have b=1. 2399≈1. 24
a=0 .5108≈0 . 51
Example 6.6

The height of a child is measured at different ages and listed below:

t (yrs) 3 6 9 12 15
H (ft ) 2.87 3.60 4.28 4.88 5.35

It is believed that height follows saturation growth model


6.45
H= .
1+a2 exp(−a3 t)
i. Use a suitable substitution to reduce the above relation to a linearized form in parameters.
ii. Use least square method to find the normal equation of the above data
iii. Estimate, to 2 decimal places, the values of a 2∧a3
iv. Estimate the height when the child becomes 20 years old.
v. Use MATLAB function a=lsqcurvefit (fun , a 0 , xdata , ydata) to fit the general form like

a1
H= .
1+a2 exp(−a3 t)
Solution
Fall 21-22

6.45
i. The curve H= is to be fitted to the given data.
1+a2 exp(−a3 t)
6.45
The equation of the curve can be rewritten as −1=a 2 e−a t
3

H
6.45
Taking logarithm of both sides, we get ln ( H )
−1 =ln a2−a3t,
which can be written in the form
Y = A+ BX

where Y =ln ( 6.45


H
−1 ) , H=t , A=ln a ∧B=−a .
2 3

ii. Sum of the square deviation is


5
E( A , B )=∑ ( A +BX i −Y i ) 2
i=1
∂E ∂E
=0 =0
At minimum, ∂A and ∂B
These conditions give
∑ 2( A+BX i−Y i ) 1=0
∑ 2( A+BX i−Y i ) X i =0
which can be rearranged as
A ∑ 1+B ∑ X i=∑ Y i
A ∑ X i +B ∑ X 2=∑ X i Y i
i
The sum can be calculated in a tabular form as shown below:

N T H X Y XY X2
1 3 2.87 3 0.221 0.663 9
2 6 3.60 6 -0.234 -1.402 36
3 9 4.28 9 -0.679 -6.113 81
4 12 4.88 12 -1.134 -13.609 144
5 15 5.35 15 -1.582 -23.727 225
Sum     45 -3.408 -44.187 495

Normal Equations
5 A + 45 B = -3.408
45 A + 495 B = -44.187

iii. Solutions: A + 9 B = -0.682


A + 11 B = -0.982
Fall 21-22

-2 B = 0.3

B = -0.150 a3 = 0.15
A = 0.668 a2 = 1.95

6.45
iv. The fitting curve is H= .
1+1.45 exp(−0.15 t )
From the equation of the curve, we get
when t=20 then H =5.88.
v. >> xd=[3 6 9 12 15]; % state x-values
>> yd=[2.87 3.60 4.28 4.88 5.35]; % staet y-values
Define fitting curve in terms of parameters as vector a
>> fun=@(a,xd) a(1)./(1+a(2).*exp(-a(3).*xd));
>> a0=[6,2,0.2]; % guess parameter values
% To fit the curve use MATLAB function lsqcurvefit with following syntax
>> a=lsqcurvefit(Fd,a0,xd,yd)

Exercise 6.2

1. Find the least square line v=b+2 atto the following data (where b , a are constants)
t 0 2 4 5 7
v 6.7 9.2 11.5 15.6 19.2
7

2. Average price, P, of a certain type of second-hand car is believed to be related to its age,t
years, by an equation of the form
50
P= t
a+ b e 4
wherea and b are constants. Data from a recent newspaper give the following average price
(in Taka) for used car of this type,

t (yrs) 2 4 6 8
P (lac) 20.50 17.25 14.50 11.75

(i) Estimate the values of a and b rounded to 3 significant figures.


(ii) Estimate the values of a car of this type that is 10 years old and the original new price.

3. A bowl of hot water is kept in a room of constant temperature 250C. At 5 minutes interval
temperature of the water is recorded and listed as given below.
Fall 21-22

t in minute 5 10 15 20 25
T in 0C 76.8 70.4 64.2 58.8 54.1
The law of cooling can be assumed to be of the form T =27+ ae−kt.
(i) Find, to 2 significant figures, the best values of a and k.
(ii) Estimate the initial temperature.
(iii) Estimate the time, to the nearest minute, when the temperature of the water in the bowl
will be 500C.

4. The equation v=70−c e−kt can be used for calculating the speed of a moving car, where
c and k are constants.
The table below shows the speed of the car at various times

t 4 8 12 16 20
v 23.21 28.52 33.07 36.96 40.29

(a) Estimate the values of c and k rounded to 2 significant figures.


(b) Find the time, to the nearest second, when the speed is 45 ms-1.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy