Nonlinear Note PDF
Nonlinear Note PDF
From fundamental theories, we may know the relationship between two variables.
An example in chemical engineering is the Clausius-Clapeyron equation that relates vapor
pressure P of a vapor to its absolute temperature, T .
log(P ) = A +
B
(1)
T
where A and B are the unknown parameters to be determined. The above equation is not
linear in the unknown parameters. Any model that is not linear in the unknown parameters is
described as a nonlinear regression model.
Exponential model
Given ( x1 ,y1 ) , ( x 2 ,y 2 ) , . . . ( x n ,y n ) , best fit y = ae bx to the data. The variables a and
b are the constants of the exponential model. The residual at each data point xi is
Ei = yi − ae bxi (2)
The sum of the square of the residuals is
n
S r = ∑ Ei2
i =1
( )
n
= ∑ y i − ae bxi
2
(3)
i =1
To find the constants a and b of the exponential model, we minimize S r by differentiating
with respect to a and b and equating the resulting equations to zero.
∂S r
( )( )
n
= ∑ 2 y i − ae bxi − e bxi = 0
∂a i =1
∂S r
( )( )
n
= ∑ 2 y i − ae bxi − axi e bxi = 0 (4a,b)
∂b i =1
or
n n
− ∑ y i e bxi + a ∑ e 2bxi = 0
i =1 i =1
n n
∑y xe
i =1
i i
bxi
− a ∑ xi e 2bxi = 0
i =1
(5a,b)
Equations (5a) and (5b) are nonlinear in a and b and thus not in a closed form to be
solved as was the case for linear regression. In general, iterative methods (such as
Gauss-Newton iteration method, method of steepest descent, Marquardt's method, direct
search, etc) must be used to find values of a and b .
However, in this case, from Equation (5a), a can be written explicitly in terms of b as
n
∑ye i
bxi
a= i =1
n
(6)
∑e i =1
2 bxi
n ∑ye i
bxi
n
∑ yi xi e bxi − i =1
n ∑x e i
2 bxi
=0 (7)
i =1
∑e
i =1
2 bxi i =1
This equation is still a nonlinear equation in b and can be solved best by numerical methods
such as the bisection method or the secant method.
Example 1
Many patients get concerned when a test involves injection of a radioactive material. For
example for scanning a gallbladder, a few drops of Technetium-99m isotope is used. Half of
the technetium-99m would be gone in about 6 hours. It, however, takes about 24 hours for
the radiation levels to reach what we are exposed to in day-to-day activities. Below is given
the relative intensity of radiation as a function of time.
If the level of the relative intensity of radiation is related to time via an exponential formula
γ = Ae λt , find
a) the value of the regression constants A and λ ,
b) the half-life of Technium-99m, and
c) the radiation intensity after 24 hours.
Solution
a) The value of λ is given by solving the nonlinear Equation (7),
n
n ∑ γ eλ i
ti
n
f (λ ) = ∑ γ i t i e λti − i =1
n ∑t e λ i
2 ti
=0 (8)
i =1
∑e i =1
2 λt i i =1
∑γ eλ i
ti
A= i =1
n
(9)
∑e
i =1
2 λt i
Equation (8) can be solved for λ using bisection method. To estimate the initial
guesses, we assume λ = −0.120 and λ = −0.110 . We need to check whether these values
first bracket the root of f (λ ) = 0 . At λ = −0.120 , the table below shows the evaluation of
f (− 0.120) .
∑i =1
6.2501 2.9062 2.8763 6.0954
From Table 2
n=6
6
∑γ t e
i =1
i i
−0.120 ti
= 6.2501
6
∑γ e
i =1
i
−0.120 ti
= 2.9062
6
∑
i =1
e 2 (−0.120 )ti = 2.8763
6
∑t e (
i =1
i
2 −0.120 )ti
= 6.0954
∑ γ eλ i
ti
A= i =1
6
∑e λ
i =1
2 ti
1
b) Half life of Technetium-99m is when γ = γ
2 t =0
0.99983 × e −0.11508t =
1
(0.99983)e −0.11508(0)
2
e −0.11508t = 0.5
− 0.11508t = ln(0.5)
t = 6.0232 hours
c) The relative intensity of the radiation after 24 hrs is
Nonlinear Regression
γ = 0.99983 × e −0.11508(24 )
= 6.3160 × 10 −2
6.3160 × 10 −2
This implies that only × 100 = 6.3171% of the initial radioactive intensity is left
0.99983
after 24 hrs.
Growth model
Growth models common in scientific fields have been developed and used
successfully for specific situations. The growth models are used to describe how something
grows with changes in the regressor variable (often the time). Examples in this category
include growth of thin films or population with time. Growth models include
a
y= (10)
1 + be −cx
a
where a, b and c are the constants of the model. At x = 0 , y = and as x → ∞ ,
1+b
y→a.
The residuals at each data point xi , are
a
Ei = yi − (11)
1 + be −cxi
The sum of the square of the residuals is
n
S r = ∑ Ei2
i =1
2
n
a
= ∑ yi − − cxi
(12)
i =1 1 + be
To find the constants a , b and c we minimize S r by differentiating with respect to a ,
b and c , and equating the resulting equations to zero.
∂S r n
= ∑
[
2e cxi ae cxi − yi e cxi + b ( )] = 0 ,
∂a i =1 e cxi + b (
2
)
∂S r
= ∑
n
2ae cxi [by
+ e cxi ( y i − a )
i
= 0,
]
∂b
i =1
cxi
+b (e 3
)
∂S r
= ∑
n cx cx
[
− 2abxi e i by i + e i ( y i − a )
= 0.
] (13a,b,c)
∂c
i =1 e cxi + b
3
(
)
One can use the Newton-Raphson method to solve the above set of simultaneous nonlinear
equations for a , b and c .
Example 2
The height of a child is measured at different ages as follows.
Estimate the height of the child as an adult of 30 years of age using the growth model,
a
H=
1 + be −ct
Solution
The saturation growth model of height, H vs. age, t is given as
a
H=
1 + be −ct
where the constants a , b and c are the roots of the simultaneous nonlinear equation system
6
[ (
2e cti ae cti − H i e cti + b )]
∑ =0
i =1 e +b(
cti 2
)
6
[
2ae cti bH i + e cti (H i − a ) ]
∑ =0
i =1 (
e cti + b
3
)
Nonlinear Regression
6
[ ]
− 2abt i e cti bH i + e cti (H i − a )
∑ =0 (14a,b,c)
i =1 ( e +b
cti
) 3
We need initial guesses of the roots to get the iterative process started to find the root of
those equations. Suppose we use three of the given data points such as (0, 20), (12, 60) and
(18, 70) to find the initial guesses of roots; we have
a
20 =
1 + be −c ( 0 )
a
60 =
1 + be −c (12 )
a
70 =
1 + be −c (18)
One can solve three unknowns a , b and c for the initial guesses from the three equations as
a = 7.5534 × 101
b = 2.7767
c = 1.9772 × 10 −1
Applying the Newton-Raphson method for simultaneous nonlinear equations with the above
initial guesses, one can get the roots
a = 7.4321×101
b = 2.8233
c = 2.1715 ×10 −1
The saturation growth model of the height of the child then is
7.4321 × 101
H= −1
1 + 2.8233e − 2.1715×10 t
The height of the child as an adult of 30 years of age is
7.4321 × 101
H= −1
1 + 2.8233e − 2.1715×10 ×(30 )
= 74 "
Polynomial Models
Given n data points ( x1 , y1 ), ( x 2 , y 2 ),......, ( x n , y n ) use least squares method to regress the
data to an m th order polynomial.
y = a 0 + a1 x + a 2 x 2 + + a m x m , m < n (15)
The residual at each data point is given by
Ei = y i − a 0 − a1 xi − . . . − a m xim (16)
The sum of the square of the residuals is given by
n
S r = ∑ Ei2
i =1
(17)
( )
n
= ∑ y i − a 0 − a1 xi − . . . − a m x m 2
i
i =1
To find the constants of the polynomial regression model, we put the derivatives with respect
to ai to zero, that is,
n
n n n m
∑ xi . . . ∑ xi a
∑ yi
i =1 i =1 0
n n
n
a ni =1
∑ xi ∑ xi . . . ∑ xi 1
2 m +1 =
∑ xi yi (19)
i =1 i =1 i =1 . . . i =1
. . . . . . . . . . . a . . .
m
n m n m+1 n 2m
n
∑ xim yi
∑ xi ∑ xi . . . ∑ xi i =1
i =1 i =1 i =1
The above are solved for a 0 , a1 ,..., a m
Example 3
To find contraction of a steel cylinder, one needs to regress the thermal expansion coefficient
data to temperature
Solution
Since α = a0 + a1T + a 2T 2 is the quadratic relationship between the thermal expansion
coefficient and the temperature, the coefficients a 0 , a1 , a 2 are found as follows
n n 2 n
n ∑ Ti ∑ Ti ∑αi
i =1 i =1 a i =1
0
n n 2 n 3 n
∑ Ti ∑ Ti ∑ Ti a1 = ∑ Ti α i
i =n1 i =1 i =1 i =1
n
n 4 2 T 2α
a
T 2 n 3
∑ i ∑ Ti ∑ i
T ∑i i
i =1
i =1 i =1 i =1
∑ − 8.6000 × 10 2 3.3600 × 10 −5
i =1 2.5800 × 10 5 − 7.0472 × 10 7
Table 5 (cont)
i T 4
T ×α T 2 ×α
1 4.0960 × 10 7
5.1760 × 10 −4 4.1408 × 10 −2
2 2.5600 × 10 6 2.4960 × 10 −4 9.9840 × 10 −3
− 2.2880 × 10 −4
3 2.5600 × 10 6 9.1520 × 10 −3
− 6.1080 × 10 −4
4 2.0736 × 10 8 7.3296 × 10 −2
− 8.6000 × 10 −4
5 1.6000 × 10 9 1.7200 × 10 −1
− 9.3240 × 10 −4
6 6.1466 × 10 9 2.6107 × 10 −1
1.3363 × 1010 − 8.3300 × 10 −4
7 2.8322 × 10 −1
7
2.1363 × 1010 − 2.6978 × 10 −3
∑
i =1
8.5013 × 10 −1
n=7
7
∑T
i =1
i = − 8.6000 × 10 − 2
7
∑T
i =1
i
2
= 2.5580 × 10 5
Nonlinear Regression
∑T
i =1
i
3
= − 7.0472 × 10 7
7
∑T
i =1
i
4
= 2.1363 ×1010
7
∑α
i =1
i = 3.3600 × 10 −5
7
∑T α
i =1
i i = − 2.6978 × 10 −3
7
∑T
i =1
i
2
α i = 8.5013 × 10 −1
We have
7.0000 − 8.6000 × 10 2 2.5800 × 10 5 a 0 3.3600 × 10 −5
− 8.600 × 10
2
2.5800 × 10 5 − 7.0472 × 10 7 a1 = − 2.6978 × 10 −3
2.5800 × 10 5 − 7.0472 × 10 7 2.1363 × 1010 a 2 8.5013 × 10 −1
Solving the above system of simultaneous linear equations, we get
a 0 6.0217 × 10
−6
a = 6.2782 × 10 −9
1
a 2 − 1.2218 × 10 −11
The polynomial regression model is
α = a 0 + a1T + a 2T 2
= 6.0217 × 10 −6 + 6.2782 × 10 −9 T − 1.2218 × 10 −11 T 2
The data z versus x is now a linear model. The constants a 0 and a1 can be found using the
equation for the linear model as
n n n
n∑ xi z i − ∑ xi ∑ z i
a1 = i =1 i =1 i =1
2
n
n
n∑ x − ∑ xi 2
i
(23a,b)
i =1 i =1
_ _
a 0 = z − a1 x
Now since a 0 and a1 are found, the original constants with the model are found as
b = a1
(24a,b)
a = e a0
Nonlinear Regression
Example 4
Repeat Example 1 using linearization of data.
Solution
γ = Ae λt
ln (γ ) = ln ( A) + λt
Assuming
y = ln γ
a 0 = ln( A)
a1 = λ
We get
y = a 0 + a1t
This is a linear relationship between y and t .
n n n
n∑ t i y i − ∑ t i ∑ y i
a1 = i =1 i =1 i =1
2
n n
n∑ t − ∑ t i i
2
i =1 i =1
a0 = y − a1t (25a,b)
∑ i =1
25.000 -2.8778 -18.990 165.00
n=6
6
∑t
i =1
i = 25.000
6
∑y
i =1
i = −2.8778
6
∑t y
i =1
i i = −18.990
6
∑t
i =1
i
2
= 165.00
= −0.11505
− 2.8778
− (− 0.11505)
25
a0 =
6 6
−4
= −2.6150 × 10
Since
a0 = ln ( A)
A = e a0
−4
= e −2.6150×10
= 0.99974
λ = a1 = −0.11505
The regression formula then is
γ = 0.99974 × e −0.11505t
Compare the formula to the one obtained without data linearization,
γ = 0.99983 × e −0.11508t
b) Half-life is when
1
γ = γ
2 t =0
Figure 4 Exponential regression model with transformed data for relative intensity of
radiation as a function of temperature.
Example 5
Sodium borohydride is a potential fuel for fuel cell. The following overpotential (η ) vs.
current (i ) data was obtained in a study conducted to evaluate its electrochemical kinetics.
At the conditions of the study, it is known that the relationship that exists between the
overpotential (η ) and current (i ) can be expressed as
η = a + b ln i (27)
where a is an electrochemical kinetics parameter of borohydride on the electrode. Use the
data in Table 7 to evaluate the values of a and b .
Solution
Following the least squares method, Table 8 is tabulated where
x = ln i
y =η
We obtain
y = a + bx (28)
This is a linear relationship between y and x , and the coefficients b and a are found as
follow
n n n
n∑ xi y i − ∑ xi ∑ y i
b= i =1 i =1 i =1
2
n n
n∑ x − ∑ xi 2
1
i =1 i =1
a = y − bx (29a,b)
∑
i =1
0.012400 -1.1371 -37.098 229.39 7.0117
n=6
6
∑x
i =1
i = −37.098
6
∑y
i =1
i = −1.1371
6
∑x y
i =1
i i = 7.0117
6
∑x
i =1
2
i = 229.39
= −1.3601
− 1.1371 − 37.098
a= − (− 1.3601)
6 6
= −8.5990
Hence
η = −8.5990 − 1.3601 × ln i
Nonlinear Regression
Power Functions
The power function equation describes many scientific and engineering phenomena. In
chemical engineering, the rate of chemical reaction is often written in power function form as
y = ax b (30)
The method of least squares is applied to the power function by first linearizing the data (the
assumption is that b is not known). If the only unknown is a , then a linear relation exists
between x b and y . The linearization of the data is as follows.
ln( y ) = ln(a ) + b ln( x ) (31)
The resulting equation shows a linear relation between ln(y ) and ln (x ) .
Let
z = ln y
w = ln( x)
a 0 = ln a implying a = e a0
a1 = b
we get
z = a 0 + a1 w (32)
n n n
n∑ wi z i − ∑ wi ∑ z i
a1 = i =1 i =1 i =1
2
n
n
n∑ w − ∑ wi
2
i
i =1 i =1 (33a,b)
n n
∑ zi ∑w i
a0 = i =1
− a1 i =1
n n
Since a 0 and a1 can be found, the original constants of the model are
b = a1
(34a,b)
a = e a0
Example 6
The progress of a homogeneous chemical reaction is followed and it is desired to evaluate the
rate constant and the order of the reaction. The rate law expression for the reaction is known
to follow the power function form
− r = kC n (35)
Use the data provided in the table to obtain n and k .
Solution
Taking the natural log of both sides of Equation (35), we obtain
ln (− r ) = ln (k ) + n ln (C )
Let
z = ln (− r )
w = ln (C )
a 0 = ln(k ) implying that k = e a0 (36)
a1 = n (37)
We get
z = a 0 + a1 w
This is a linear relation between z and w , where
n n n
n∑ wi z i − ∑ wi ∑ z i
a1 = i =1 i =1 i =1
2
n
n
n∑ w − ∑ wi
2
i
i =1 i =1
Nonlinear Regression
n n
∑ zi ∑ wi
a 0 = i =1 − a i =1 (38a,b)
n 1 n
∑
i =1
-4.3643 -12.391 16.758 30.998
n=7
7
∑w
i =1
i = −4.3643
7
∑z
i =1
i = −12.391
7
∑w z
i =1
i i = 16.758
7
∑w
i =1
2
i = 30.998
= 0.31943
− 12.391 − 4.3643
a0 = − (.31943)
7 7
= −1.5711
From Equation (36) and (37), we obtain
k = e −1.5711
= 0.20782
n = a1
= 0.31941
Finally, the model of progress of that chemical reaction is
− r = 0.20782 × C 0.31941
Growth Model
Growth models common in scientific fields have been developed and used successfully for
specific situations. The growth models are used to describe how something grows with
changes in a regressor variable (often the time). Examples in this category include growth of
thin films or population with time. In the logistic growth model, an example of a growth
model in which a measurable quantity y varies with some quantity x is
ax
y= (39)
b+x
For x = 0 , y = 0 while as x → ∞ , y → a . To linearize the data for this method,
1 b+x
=
y ax
(40)
b1 1
= +
ax a
Let
1
z=
y
Nonlinear Regression
1
w = ,
x
1 1
a 0 = implying that a =
a a0
b a
a1 = implying b = a1 × a = 1
a a0
Then
z = a 0 + a1 w (41)
The relationship between z and w is linear with the coefficients a 0 and found as follows.
n n n
n∑ wi z i − ∑ wi ∑ z i
a1 = i =1 i =1 i =1
2
n
n
n∑ w − ∑ wi
2
i
i =1 i =1
n n
∑ zi ∑ wi
a0 = i =1 − a1 i =1 (42a,b)
n n
Finding a 0 and a1 , then gives the constants of the original growth model as
1
a=
a0
a
b= 1 (43a,b)
a0