0% found this document useful (0 votes)
33 views

Linearization

This document describes methods for fitting models to data using least squares approximation. It discusses fitting functions other than polynomials, such as exponential, logarithmic and power models, to discrete data by linearizing the models. It also describes fitting continuous functions to continuous data using continuous least squares. Examples are provided to demonstrate fitting exponential and power models to discrete data by first transforming the models and data to a linear form to allow application of linear regression.

Uploaded by

Izzah Maisara
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

Linearization

This document describes methods for fitting models to data using least squares approximation. It discusses fitting functions other than polynomials, such as exponential, logarithmic and power models, to discrete data by linearizing the models. It also describes fitting continuous functions to continuous data using continuous least squares. Examples are provided to demonstrate fitting exponential and power models to discrete data by first transforming the models and data to a linear form to allow application of linear regression.

Uploaded by

Izzah Maisara
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Part 3 THE METHOD OF LEAST SQUARES MAT 575

Chapter 5

Fitting Other
Models and
Continuous
Data
At the end of this chapter, students should be able to:
 Describe discrete least-squares for other type of functions or models
 Describe continuous least-squares approximation
 Apply these two least-squares method in curve fitting problems

5.1 Introduction
In the previous chapter we discussed about finding least-squares polynomials to
fit discrete data. In this chapter we shall proceed with fitting other models (other
than polynomials) to that type of data. We shall also discuss how to do
continuous least-squares approximation (fitting functions or continuous data). At
the end of this chapter, sequences of Legendre polynomials will be discussed as
an alternative method.

63
Part 3 THE METHOD OF LEAST SQUARES MAT 575

5.2 Fitting Other Functions or Models (Data


Linearization)
The method of least squares is not restricted to polynomials or to any specific
functional form. In cases where polynomials are not appropriate, transcendental
functions may be used to fit the data. Some functions are reducible to a linear
relationship, by suitable changes in the variables or transformation and may be
written so that the representation is expressed in linear form. Such procedure is
called data linearization.

The technique of data linearization has been used by scientists to fit curves such
as y = CeAx, y = cxA and y = Aln(x) + B and many more. Once the model has
been chosen, a suitable transformation of the variables must be found so that a
linear relation is obtained. Some examples of transformations are given as in the
table below.

Function Linear Transformation

1. y = a 0 + a1 X
y = ax2 + b
X = x2 , a=a1, b=a0
2.
Y = a 0 + a1 X
1
 ax 2  b
y 1
X = x2, Y = , a=a1, b=a0
y
3.
y = abx Y = a 0 + a1 X
ln y = ln a + x ln b
Y = ln y, ln a=a0, ln b=a1
4.
y = axb Y = a 0 + a1 X
ln y = ln a + b ln x
X = ln x , Y = ln y, ln a=a0, b=a1
5.
ax 1 a 1
y Y   a0  a1
bx y b b
6.
y = keax Y = a 0 + a1 x
ln y = ln k + ax
Y = ln y, ln k=a0 , a=a1,

64
Part 3 THE METHOD OF LEAST SQUARES MAT 575

Subsequent to data linearization, linear regression can be applied to the linear


equation in the transformed variable(s). In this case the normal equations will be
written in the new or transformed variable(s).

Steps : Fitting a transcendental function

 Identify the expected function f(x)


 Identify the unknowns.
 Linearize the expected function.
 Transform the data and/or unknowns.
 Identify the normal equations.
 Determine all the respective values.
 Solve for the coefficients: a0 and a1.
 Solve for the unknowns.
 Write the model obtained for the data.

Example 1

Use the method of least-squares to fit an exponential model y  ae bx to the


following data.
xi 0.4 0.8 1.2 1.6 2.0 2.3
yi 800 975 1500 1950 2900 3600

Solution

 Identify the expected function : y  ae bx

 Identify the unknown : a, b

 Linearize the function :

y  aebx
ln y  ln aebx

o ln y  ln a  ln ebx
 ln a  bx ln e ln e  1)
 ln a  bx

65
Part 3 THE METHOD OF LEAST SQUARES MAT 575

 Transform the data and/or unknown :


Y  ln y a0  ln a a1  b
 Identify normal equation
 n   n 
 n  xi  a   Yi 
 i 1 0
  a  =  n 
i 1
n n 
2  1

 x
i  xi
   x i Yi 
i 1 
 i 1 i 1 
 Determine the respective values:
i xi xi2 yi Yi xi Yi
1 0.4 0.16 800 ln 800 2.6738
2 0.8 0.64 975 ln 975 5.5059
3 1.2 1.44 1500 ln 1500 8.7759
4 1.6 2.56 1950 ln 1950 12.1209
5 2.0 4.00 2900 ln 2900 15.9449
6 2.3 5.29 3600 ln 3600 18.8340
n n
 xi Yi  63.8555
n

 x i  8.3
y
n

i  14.09  Yi  44.6170
i 1
i1 i 1
i1

 Substitute the respective values in the normal equation.


 6 8.3  a0  44.6170 
    =  
8.3 14.09   a1  63.8555 
 Solve for the coefficients: a 0 and a1

a0  6.3037 and

a1  0.8187
 Substitute to the transform unknown :
a0  ln a  6.3037 a1  b  0.8187
6.3037
ae
 546 .5906

 The expected function is y  546.5906 e0.8187 x

66
Part 3 THE METHOD OF LEAST SQUARES MAT 575

Example 2
Use least-squares procedure to fit y = Axk to the following data.
xi 1.00 1.15 1.40 1.43 1.60 2.00
yi 4.33 4.58 4.98 5.06 5.28 5.80

Solution

y  Ax k
Taking natural logarithm both sides:
ln y = l n A + k ln x

Y a0  a1X

The necessary transformation for the data and unknowns are:

Y  ln y X  ln x a0  ln A k  a1

x y X = ln x X2 Y = ln y XY
1.00 4.33 0.0000 0.0000 1.4656 0.0000
1.15 4.58 0.1398 0.0195 1.5217 0.2127
1.40 4.98 0.3365 0.1132 1.6054 0.5402
1.43 5.06 0.3677 0.1279 1.6214 0.5799
1.60 5.28 0.4700 0.2209 1.6639 0.7821
2.00 5.80 0.6831 0.4805 1.7579 1.2185
1.9971 0.9620 9.6358 3.3333

Rewrite
ln y = ln A + k ln x
as
Y = a0 + a1 X
Hence, the required normal equations:

 6   6 
 6  xi    Yi 
a 0 
 i 1 
  = 6
i 1 
6 6   1
a  
  x i  x i2    x i Yi 
i 1 i 1  i 1 

67
Part 3 THE METHOD OF LEAST SQUARES MAT 575

 6 1.9971 a0  9.6358 


    =  
1.9971 0.9620   a1  3.3333 

Solving for a0 and a1:

a0 = 1.4649

Since a1 = 0.4239 then k = a1 = 0.4239

But ln A = a0 then

A = e a0 = e1.4649 = 4.327

Hence, the expected function is y = Axk = 4.327x0.4239

Warm up exercise

Find the values of a and b of the form y = aex + be-x to the following data:

x 0 0.5 1.0 1.5 2.0 2.5


y 5.02 5.21 6.49 9.54 16.02 24.53

5.3 Continuous Least Squares Polynomials


The previous section considered the problem of least-squares approximation to
fit a collection of discrete data. The other approximation problem concerns the
approximation of functions or fitting continuous data.
Consider a function y = f(x), which is continuous in [a, b]. Let

Pm ( x)  a0  a1x  a2 x 2  ...  ai xi  ...  amxm be a polynomial which represent


the function y = f(x), then the total least squares error is defined as follows
b

∫f(x)- Pm (x)
2
E dx
a

∫f(x)- a  dx
b
2
 0  a1x  a2 x 2  ...  ai x i  ...  am x m
a

68
Part 3 THE METHOD OF LEAST SQUARES MAT 575

We seek to minimize the sum of error squares. From the calculus of functions of
several variables, a necessary condition for the values a0, a1, …, and am to
minimize E such that
∂E ∂E ∂E ∂E
= = ...  = ...  =0 0im
∂a0 ∂a1 ∂ai ∂am

Hence,

∫a0 f(x)- a0  a1x  ...  ai x 


b
 i
 ...  am x m 2 dx  0 (1)
a

∫a1 f(x)- a0  a1x  ...  ai x 


b
 i
 ...  am x m 2 dx  0 ( 2)
a
.
.
.

∫ai f(x)- a0  a1x  ...  ai x 


b
 i
 ...  am x m 2 dx  0 (i )
a
.
.
.

f(x)- a 
b

∫am 0  a1x  ...  ai x i  ...  am x m 2 dx  0 (m )
a

Simplifying (1) yields

∫2 f(x)- a0  a1x  ...  aix 


b
i
 ...  am xm ( 1)dx  0
a

∫a0  a1x  ...  ai x  


b
i
 ...  am x m  f ( x ) dx  0
a
b b b b b

   
a0 dx  a1xdx  ...  ai x i dx  ...  am x m dx  f ( x ) dx 
a a a a a
b b b b b

  
a0 dx  a1 xdx  ...  ai x dx  ...  am x m dx  f ( x ) dx  
i

a a a a a

Simplifying (2) to (m) using similar procedures yield the normal equations

69
Part 3 THE METHOD OF LEAST SQUARES MAT 575

b b b b b
a0  xdx  a1  x 2 dx  ...  ai  x i 1dx  ...  a m  x m 1dx   xf ( x )dx
a a a a a
.
.
b b b b b
a0  x i dx  a1  x 2  i dx  ...  ai  x 2i dx  ...  a m  x m  i dx   x i f ( x )dx
a a a a a
.
.
b b b b b
a0  x m dx  a1  x1 m dx  ...  ai  x i  m dx  ...  a m  x 2m dx   x m f ( x )dx
a a a a a

In matrix form the normal equations can be represented as


 b 
 b b b b   
 f ( x )dx 

 dx
    
i
xdx ... x dx ... xmdx  ba 
   
 
 ba  0

a a a a
b b b  xf( x )dx 
  a   

 xdx x 2dx  ...  xi 1dx ...  xm 1dx  1   a
 .  . 
 a a a a   
 ... ... ... ... ... ...  .   . 
b b b b  a    b 
 i  i   i

 x dx xi 1dx
 ... x
2i
dx ... x
im
dx   .  x f ( x )dx 
  
a a a a  .  a 
 ... ... ... ... ... ...  a   . 
b b b b   m

 xmdx xm 1dx mi     .
  x x 
2m
 ... dx ... dx  b
 m 
a

a a a 
 
 x f ( x )dx 
a 
 

Steps : Fitting Continuous Least Squares Polynomial

 Determine the degree m of the polynomial : m


 Write the general expression of the polynomial to be fitted
Pm(x) = a0 + a1x + a 2 x 2 + ... + am x m
 Write the normal equations in matrix form.
b 1

 x dx  x f ( x)dx for 0  i  m
i i
 Compute : for 0  i  2m and
a 0
 Solve for the coefficients a0, a1…am.
 Thus, the least-squares function is:
f(x) = a0 + a1x + a 2 x 2 + ... + am x m
 Solve for a0 and a1.
 Thus, the least-squares line is f(x) = a0 + a1x.

70
Part 3 THE METHOD OF LEAST SQUARES MAT 575

Example 3
Derive the normal equation in matrix form to approximate y = f(x) with a straight
line on the interval [a, b].

Solution

Let P1( x)  a0  a1x

∂E ∂E
= =0
∂a0 ∂a1
b

∫f(x)- P1(x) dx
2
E
a

∫f(x)- a0  a1x  dx


2

a

b

∫a0 f(x)- a0  a1x  dx  0
2

a
b

∫2 f(x)- a0  a1x (1)dx  0


a
b

∫a0  a1x   f ( x)dx  0


a
b b b

  
a0dx  a1xdx  f ( x )dx
a a a
b b b

  
a0 dx  a1 xdx  f ( x )dx
a a a

b

∫a1 f(x)- a0  a1x  dx  0
2

a
b

∫2 f(x)- a0  a1x (x)dx  0


a
b

∫a0  a1x   f ( x)xdx  0


a

71
Part 3 THE METHOD OF LEAST SQUARES MAT 575

b b b

 a0 xdx   a1x 
2
dx  xf ( x )dx
a a a
b b b

 
a0 xdx  a1 x 2dx  xf ( x )dx 
a a a

b b  b 

 dx

xdx 
 a0   
 f ( x )dx 

ba b
a     ba 
   a1   

 xdx
a

x 2dx 


 xf ( x )dx 
a 
a

Example 4
Find the least squares polynomial approximation of degree one to
y = x 2 + 4x + 4 on the interval [0,2].

Solution

2 2  2 
  dx  xdx    f ( x )dx 
0 0  a0    0 
2  
2   a1   
2 2
  xdx  x dx    xf( x )dx 
0 0  0 

 56 
2 2  a   
0
8     3 

2 3   a1   68 
3

a0  3.336 
  
 a1  5.997 
Hence, P1( x)  3.336  5.997 x

Example 5
Find the least squares polynomial approximation of degree two to f(x) = e x on
the interval [ 0, 1]

72
Part 3 THE METHOD OF LEAST SQUARES MAT 575

Solution

 Determine the degree m of the polynomial


m=2
 Write the general expression of the polynomial to be fitted

P2(x) = a0  a1x  a2 x 2
 Write the normal equations in matrix form.
 1 1
2 
1  1 x 
  dx  xdx  x dx    e dx 
 0 0 0  a0   0 
1 1
2
1
3   
1
x 
  xdx  x dx  x dx   a1     xe dx 
0 0 0  a   0 
1 2  2  1
4  2 x 
1 1
3
  x dx  x dx  x dx    x e dx 
0 0 0  0 
1 1

 x dx  x f ( x )dx
i i
 Compute : for 0  i  4 and for 0  i  m
0 0

 1 0.5 0.3333  a0  1.7183 


 0.5 0.3333 0.25   a1    1 

0.3333 0.25 0.2  a2  0.7183 

 Solve for the coefficients a0, a1…am.


a0  1.0140 
 a   0.8445 
 1  
a2  0.8449 

 Thus, the least-squares function is:

P2(x) = 1.0140  0.8445x  0.8449x 2

5.4 Continuous Least-Squares Approximation using


Legendre Polynomials (Optional)
The previous section considered the problem of least-squares approximation to
fit a collection of discrete data. The other approximation problem concerns the
approximation of functions or fitting continuous data. In this section we shall
learn to fit data in continuous form using sequences of Legendre polynomials.

73
Part 3 THE METHOD OF LEAST SQUARES MAT 575

Definition
The functions listed below are called Legendre polynomials and are defined for
-1  x  1:
P0(x) = 1
P1(x) = x

P2 ( x ) 
1 2
2

3x - 1 
P3 ( x ) 
2

1 3
5x - 3x 
P4 ( x ) 
1
8
35x 4 - 30x 2 + 3 
P5 ( x ) 
1
8
63x 5 - 70x 3 + 15x 
.
.
 2m + 1  m 
Pm 1( x )    Pm -   Pm -1
 m +1   m + 1
This set of Legendre polynomials is said to be orthogonal on [-1,1] with respect
to the weight function w(x)  1 .The criteria required is that these functions are
designed to satisfy the following orthogonality condition:
1  0 if n  m

 Pm ( x ) Pn ( x ) dx   2
 if n  m
1  2n  1
(details of orthogonality and weight function shall not be discussed here)
In general, the Legendre polynomials can also be derived by the formula:

Pn ( x ) 
1
n
dn
2 n! dx n
(x 2
- 1)n 
Suppose y(x) is a function continuous on [-1,1]. Here, the approach to finding the
least-squares approximating polynomial f(x) to fit the function y(x) (or, the
continuous data) is done in a similar manner. Let f(x) be of polynomial of degree
m defined using sequences of Legendre polynomials such that
f(x) = a0P0(x) + a1P1(x) + a2P2(x) + . . . + amPm (x) .

74
Part 3 THE METHOD OF LEAST SQUARES MAT 575

We seek to minimize the sum of error squares; i.e.


1

∫ f(x)- y(x) dx
2
L
-1
1
 ∫ a 0 P0 (x) + a1P1 (x) + ...  a m Pm (x) - y(x)2 dx (1)
-1

where, Pi (x) is a Legendre polynomial and a i is a constant coefficient.

From the calculus of functions of several variables, a necessary condition for the
values a0, a1, …, am to minimize L is that
∂L
= 0, for each k = 0, 1, …, m.
∂ak
Hence, using (1),

L 1
 ∫  a0 P0 ( x )  a1P1( x )    am Pm ( x ) - y( x )2 dx
ak -1
 0
With the orthogonality property of Legendre polynomials, this term can be
simplified to:
1
 akPk ( x)Pk ( x) - y( x)Pk ( x) dx  0

2

-1

1 1
ak . Pk ( x )2 x 
∫ ∫ y( x) Pk ( x)dx
-1 -1

1
2
ak  ∫y( x) Pk ( x)dx
2k  1
-1

Thus,
1
2k  1
ak  ∫ y(x)Pk (x) dx
2
-1

Notice that ak calculates the coefficients a0, a1, …, am with the condition that x is
defined for y(x) on the interval [-1,1].

75
Part 3 THE METHOD OF LEAST SQUARES MAT 575

Theorem
Suppose y(x) is continuous and defined on [-1,1], then y(x) can be approximated
by a least-squares polynomial f(x) of degree m, using series of Legendre
polynomials such that:
f(x) = a0P0(x) + a1P1(x) + a2P2(x) + . . . + amPm(x)
where, the coefficients a0, a1, …, am is be determined by
1
2k  1
ak 
2  y( x) Pk ( x) dx for k = 0,1,2,3,……….,m
1

Steps : Fitting continuous data (or function) using


Legendre polynomials if independent variable
is defined on [-1,1]

 Identify the observed function: y(x)


 Determine the Legendre polynomials of degree m:
f(x)= a0P0(x) + a1P1(x) + a2P2(x) + . . . + amPm(x)
 Determine the coefficients a0, a1, …, am :
1
2k  1
ak 
2  y ( x ) Pk ( x ) dx for k = 0,1,2,3,…m
1

Example 3
Find the least squares polynomial approximation of degree one to

y  x 2  4x  4 in the interval [-1,1].

Solution
 Identify the observed function :
y(x) = x 2 + 4x + 4
 Determine the Legendre polynomials of degree 1:
f(x) = a0P0(x) + a1P1(x)
= a0 + a1x
where P0(x) = 1 and P1(x) = x

76
Part 3 THE METHOD OF LEAST SQUARES MAT 575

 Determined the coefficients a0 and a1:


1
2k  1
ak 
2  y( x) Pk ( x) dx for k = 0,1
1

1
2(0)  1
k 0: a0 
2 
( x 2  4 x  4) P0 ( x ) dx
1
1
1

2 
( x 2  4 x  4)(1)dx
1
13

3
1
2(1)  1
k  1 : a1 
2 
( x 2  4 x  4) P1( x ) dx
1
1
3

2 
( x 2  4 x  4)x dx
1
4
 Thus, the polynomial of degree one to fit y(x) is:
f(x) = a0P0(x) + a1P1(x)
13
= + 4x
3
Other method which can be applied is
 1 1   1 
 
 dx xdx  
 a0  
 y( x )dx 
 
 11 1
1      1 
   a1   1 

 xdx
1
x 2dx 

  xy( x )dx 
1 

1

In the case where x (or the independent variable) is defined on [m,n], a


suitable linear transformation is required so that the interval range of the
independent variable is normalized to be on [-1,1].

77
Part 3 THE METHOD OF LEAST SQUARES MAT 575

Steps : Fitting continuous data (or function) using


Legendre polynomials if independent variable
is not defined on [-1,1]

 Transform x to t linearly: x  [m, n ]  t  [1,1 ]


 Let x  at  b
 Solve for a and b
 Rewrite y(x) in term of y(t)
 Determine the Legendre polynomials of degree m
f(t) = a0P0(t) + a1P1(t) + a2P2(t) + . . . + amPm(t)
 Determine the coefficients a0, a1, …, am :
1
2k  1
ak 
2 1 
y( t ) P k ( t ) dt for k = 0,1,2,3,..,m

 The polynomial of degree m to fit y(t) is:


f(t) = a0P0(t) + a1P1(t) + a2P2(x) + . . . + amPm(t)
 Rewrite f(t) in term of f(x).

Example 4
Find the least squares polynomial approximation of degree one to
y = x 2 + 4x + 4 on the interval [0,2]

Solution

Since x  [0 ,2 ] and x  [1, 1 ] then transformation is required.


 Transform x to t linearly:
x  [0,2 ]  t  [1,1 ]
 Let . x = at + b
 Solve for a and b
When x = 0: t=-1 : 0 = a(-1) + b …(1)
When x = 2: t=1 : 2 = a(1) + b … (2)
Solving (1) and (2):
a=1 and b=1
Thus
x=t+1 or t=x–1

78
Part 3 THE METHOD OF LEAST SQUARES MAT 575

 Rewrite y(x) in term of y(t):

y(x) = x 2 + 4x + 4, but x = t+1


y(t) = (t+1) 2 + 4(t+1) + 4

= t 2 + 6t +9
 Determine Legendre polynomials of degree 1:
f(t) = a0P0(t) + a1P1(t)
= a0 + a1t
where P0(t)=1 and P1(t)=t
 Determine the coefficients a0 and a1:
1
2k  1
ak 
2 1 
y( t ) P k ( t ) dt for k = 0,1

2(0)  1 1 2
k  0 : a0   ( t  6t  9) P 0( t ) dt
2 1
11 2 28
  ( t  6t  9)(1) dt 
2 1 3

2(1)  1 1
k  1 : a1   y( t ) P 1( t ) dt
2 1
3 1 2
  ( t  6t  9)(t ) dt  6
2 1

 The polynomial of degree 1 to fit y(t) is:


f(t) = a0P0(t) + a1P1(t)
28
= + 6t
3
 Rewrite f(t) in term of f(x):
28
f(x) = + 6(x-1) since t = x – 1
3
10
= + 6x
3

Example 5
Find the least squares polynomial approximation of degree two to f(x) = ex on
the interval
a) [-1, 1] b) [ 0, 1]

79
Part 3 THE METHOD OF LEAST SQUARES MAT 575

Solution
a) No transformation is required since x  [1, 1 ] .
Given
y(x) = ex
and
f(x) = a0P0(x) + a1P1(x) + a2P2(x) polynomial of degree two
 a0P0 ( x )  a1P1( x )  a2P2 ( x )
1 
 ao  a1x  a2  (3x 2  1) 
2 

1 
since P0 ( x )  1 , 1P1( x ) x and P2 ( x )   (3x 2  1) 
2 
Determined the coefficients a0 ,, a1 and a2:
1
2k  1
ak 
2  y( x) Pk ( x) dx for k = 0,1,2
1

1
2(0)  1
k  0 : a0 
2
e x P0 ( x ) dx 
1
1
1

2 
e x dx
1
 1.1752
1
2(1)  1
k  1 : a1 
2 
e x P1( x ) dx
1
1
3

2 
e x x dx
1
 1.1036
1
2(2)  1
k  2: a1 
2 
e x P2 ( x ) dx
1
1
5 1 

2 
e x  (3 x 2  1)  dx
2 
1
 0.3578

80
Part 3 THE METHOD OF LEAST SQUARES MAT 575

Hence,
f ( x )  a 0P0 ( x )  a1P1( x )  a 2P2 ( x )
1 
 a o  a1x  a 2  (3 x 2  1) 
2 
1 
 1.1752  1.1036 x  0.3578  (3 x 2  1) 
2 
 0.9963  1.1036 x  0.5367 x 2 .
b)
Need a suitable linear transformation since x  [1, 1 ] and x  [0 ,1 ]
Make a suitable linear transformation of x to t:
x  [0,1 ]  t  [1,1 ]
i.e. x = at + b, solve for a and b
when x = 0, t = - 1 : 0 = a(-1) + b = - a + b …(1)
when x = 1, t = 1 : 1 = a(1) + b = a + b … (2)

Solving (1) and (2):


1 1
a and b
2 2
Thus,
1 1 t 1
x t  or 2x  t  1  t  2x  1
2 2 2
Write y(x) in the term of y(t):
y( x )  e x
t 1
y( t )  e2
Write the least-squares polynomial in the new variable t in the form of
Legendre polynomials:
f(t) = polynomial of degree two (quadratic)
f ( t )  a 0P0 ( t )  a1P1( t )  a 2P2 ( t )
1 
 a o  a1t  a 2  (3t 2  1) 
2 
Determine the coefficients a0 , a1 and a2:
1
2k  1
ak 
2 1 
y( t ) Pk ( t ) dt for k = 0,1,2

81
Part 3 THE METHOD OF LEAST SQUARES MAT 575

t 1
2(0)  1 1 2
k  0 : a0   e P0 ( t ) dt
2 1
t 1
11
  e 2 dt
2 1
 1.7183
t 1
2(1)  1 1 2
k  1 : a1   e P1( t ) dt
2 1
t 1
3 1
  e 2 t dt
2 1
 0.8452
t 1
2(2)  1 1 2
k  2 : a2   e P2 ( t ) dt
2 1
t 1
51 1 
  e 2 . (3t 2  1)  dt
2 1 2 

 0.0559 
5
2
 0.1398
Thus,
f ( t )  a0P0 ( t )  a1P1( t )  a2P2 ( t )
1 
 1.7183  0.8452 t  (0.1398 ) (3t 2  1) 
2 
 1.6484  0.8452 t  0.8388 t 2
Hence

f ( x )  1.6484  0.8452(2x  1)  0.8388(2x  1)2


 1.3097  14.7872 x  13.0968 x 2

Warm up exercise

Find the least squares polynomial approximation of degree two to:


(i) f(x) = sin 2x on the interval [-1,1] and [0, 1]
(ii) f(x) = ln x on the interval [1,3]

82
Part 3 THE METHOD OF LEAST SQUARES MAT 575

Exercise 5

1. Find the values of A and B to fit a curve of the following form to the given data.
1 A
a) y  b) y  B
Ax  B x

x -1 0.1 1 2 3
y 6.62 3.94 2.17 1.35 0.89
Calculate the least square error and determine which is a better model to
represents the data. Plot the data and the non-linear model.

2. The data shows the solubility, S, of n-butane in anhydrous hydrofluoric acid at


high temperature T needed in the design of petroleum refineries. Determine the
constants  and  to fit the data to the model S  eT . Estimate the solubility

when temperature is 95F.

Temperature F 77 100 185 239 285


Solubility (weight %) 2.4 3.4 7.0 11.1 19.6

3. One of the following data sets, (x,y1) and (x,y2) , follows an exponential law
y  Aebx and the other follows a power law y  Axb . Which is which? Fit the
data to the respective model and calculate the sum square errors.

x 2.0 2.5 3.0 3.5 4.0 4.5 5.0


y1 14.79 27.75 47.09 74.07 109.99 156.10 213.69
y2 12.13 19.58 31.59 50.97 82.21 132.59 213.82

4. Find the least- squares polynomial approximation of degree one to the function
f(x) on the indicated interval.
a) f(x) = e2x ; [-1, 1] d) f(x) = sinx ; [-1, 1]
1
b) f (x)  ; [1, 3] e) f(x) = cos 2x ; [0, 0.5] ,
x
c) f(x) = x3 – 1; [0,2] f) f(x) = ln x; [1, 2]

83
Part 3 THE METHOD OF LEAST SQUARES MAT 575

5. Find the least- squares polynomial approximation of degree two to the function
f(x) on the indicated interval.
a) f(x) = e-x ; [0, 1] c) f(x) = cos x; [-1, 1]
b) f(x) = x3 – x + 1; [0, 3] d) f(x) = sin2x; [0, ]

6. Consider the function f(x) = sin 2x defined in [0, ].


 
a) Find the least-squares polynomial approximation of degree one in 0, 
 2
 
and  ,  .
2 
b) Find the least-square polynomial approximation of degree two in [0, ].
c) Plot the graph to show the polynomials in a) and b) together with the
function f(x).
d) Approximate f(0.2) and f(2) using a) and b). Which polynomial gives a
better approximation.
e) Calculate the total least-square error for a) and b).
f) If f(x) is approximated using least square polynomial of degree three i.e.,

f ( x )  ao  a1x  a2 x 2  a3 x 3 , find a3 .

84
Part 3 THE METHOD OF LEAST SQUARES MAT 575

1. a) A=0.2450, B=0.2961, E=0.0314


b) A=0.0442, B=2.8982, E=21.6972

2.

3.
4. a) d)
b) e)
c) f)

5. a) c)
b) d)
6 a) d)
b) e)
c) f)

85

You might also like