lect02. regression and nonlinear axes

32
Introduction to Chemical Engineering Calculations Prof. Manolito E Bambase Jr. Department of Chemical Engineering. University of the Philippines Los Baños Lecture 2. Regression and Nonlinear Axes

Upload: others

Post on 18-Oct-2021

18 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: LECT02. Regression and Nonlinear Axes

Introduction to Chemical Engineering Calculations

Prof. Manolito E Bambase Jr. Department of Chemical Engineering. University of the Philippines Los Baños

Lecture 2.

Regression and Nonlinear Axes

Page 2: LECT02. Regression and Nonlinear Axes

Prof. Manolito E Bambase Jr. Department of Chemical Engineering. University of the Philippines Los Baños SLIDE

2

Regression and Nonlinear Axes2

What is regression analysis?

A technique for modeling and analyzing the relationship between 2 or more variables. Usually, 1 variable is designated as the independent variable.

Purpose: Establish a mathematical relation between the variables.

t

a0

n=1

C(t) = e

2 nπx n x n yu(x,y) = f(x)sin dx sin sinha sinh (nπb/a) a a a

Page 3: LECT02. Regression and Nonlinear Axes

Prof. Manolito E Bambase Jr. Department of Chemical Engineering. University of the Philippines Los Baños SLIDE

3

Regression and Nonlinear Axes2

Linear Regression

An equation of a line is used to establish the relationship between 2 variables x and y.

y = mx + b

where

y,x = dependent and independent variables, respectively.

m, b = slope and intercept, respectively.

Page 4: LECT02. Regression and Nonlinear Axes

Prof. Manolito E Bambase Jr. Department of Chemical Engineering. University of the Philippines Los Baños SLIDE

4

Regression and Nonlinear Axes2

Fitting a Straight Line to a Set of Data Points

Consider a rotameter calibration data:

Rotameter Reading(independent variable)

Flow Rate (mL/min)(dependent variable)

10 20.0

30 52.1

50 84.6

70 118.3

90 151.0

Page 5: LECT02. Regression and Nonlinear Axes

Prof. Manolito E Bambase Jr. Department of Chemical Engineering. University of the Philippines Los Baños SLIDE

5

Regression and Nonlinear Axes2

Fitting a Straight Line to a Set of Data Points

Page 6: LECT02. Regression and Nonlinear Axes

Prof. Manolito E Bambase Jr. Department of Chemical Engineering. University of the Philippines Los Baños SLIDE

6

Regression and Nonlinear Axes2

Fitting a Straight Line to a Set of Data Points

Calculating the slope and intercept using the method of least squares:

xy x y2

xx x

xx y xy x2

xx x

S - S SΔy m = = Δx S - S

S S - S S b =

S - S

slope :

intercept :

Page 7: LECT02. Regression and Nonlinear Axes

Prof. Manolito E Bambase Jr. Department of Chemical Engineering. University of the Philippines Los Baños SLIDE

7

Regression and Nonlinear Axes2

Fitting a Straight Line to a Set of Data Points

Calculating the S-values:

1

1

2 2

1

1

1 (average of x values) =

1 (average of y values) =

1 (average of x values) =

1 (average of xy values) =

nx i

in

y iin

xx iin

xy i ii

S xn

S yn

S xn

S x yn

Page 8: LECT02. Regression and Nonlinear Axes

Prof. Manolito E Bambase Jr. Department of Chemical Engineering. University of the Philippines Los Baños SLIDE

8

Regression and Nonlinear Axes2

Fitting a Straight Line to a Set of Data Points

For the previous data set:

2 2 2 2 2

1 = 10 30 50 70 90 = 505

1 = 20.0 52.1 84.6 118.3 151.0 85.25

1 = 10 30 50 70 90 = 33005

10 20 30 52.1 50 84.61 = 5572.85 70 118.3 90 151.0

x

y

xx

xy

S

S

S

S

Page 9: LECT02. Regression and Nonlinear Axes

Prof. Manolito E Bambase Jr. Department of Chemical Engineering. University of the Philippines Los Baños SLIDE

9

Regression and Nonlinear Axes2

Fitting a Straight Line to a Set of Data Points

Calculating the slope and intercept:

2

2

5572.8 - 50 85.2 = 1.641

3300 - 50

3300 85.2 - 5572.8 503.15

3300 - 50

m

b

Page 10: LECT02. Regression and Nonlinear Axes

Prof. Manolito E Bambase Jr. Department of Chemical Engineering. University of the Philippines Los Baños SLIDE10

Regression and Nonlinear Axes2

Fitting a Straight Line to a Set of Data Points

Therefore, the mathematical relation for flow rate in terms of the rotameter reading is:

y = 1.641x + 3.15

At any given value of x, a corresponding value for y can easily be calculated using this equation.

For x = 25, y = 1.641(25) + 3.15 = 44.175

for x = 250, y = 1.641(250) + 3.15 = 413.40

Page 11: LECT02. Regression and Nonlinear Axes

Prof. Manolito E Bambase Jr. Department of Chemical Engineering. University of the Philippines Los Baños SLIDE11

Regression and Nonlinear Axes2

Two-Point Linear Interpolation

Given the following set of data:

x 1.0 2.0 3.0 4.0

y 0.3 0.7 1.2 1.8

Supposed we want to know two values of y when:

1. x = 2.5 (x is between the range of data points: interpolation)

2. x = 5.0 (x is outside the range of data points: extrapolation)

Page 12: LECT02. Regression and Nonlinear Axes

Prof. Manolito E Bambase Jr. Department of Chemical Engineering. University of the Philippines Los Baños SLIDE12

Regression and Nonlinear Axes2

Two-Point Linear Interpolation

Page 13: LECT02. Regression and Nonlinear Axes

Prof. Manolito E Bambase Jr. Department of Chemical Engineering. University of the Philippines Los Baños SLIDE13

Regression and Nonlinear Axes2

Two-Point Linear Interpolation

Page 14: LECT02. Regression and Nonlinear Axes

Prof. Manolito E Bambase Jr. Department of Chemical Engineering. University of the Philippines Los Baños SLIDE14

Regression and Nonlinear Axes2

Two-Point Linear Interpolation

If points 1, 2, and A lie on the same line, then

Slope (1-A) = Slope (1-2)

If slope is defined as y/x, then,

1 2 1

1 2 1

y - y y - y=x - x x - x

Rearranging the equation,

11 2 1

2 1

x - xy = y + y - yx - x

Page 15: LECT02. Regression and Nonlinear Axes

Prof. Manolito E Bambase Jr. Department of Chemical Engineering. University of the Philippines Los Baños SLIDE15

Regression and Nonlinear Axes2

Two-Point Linear Interpolation

Two-point interpolation can be used when extracting values from a tabular data.

Consider the following tabular data:

x 1 2 3y 1 4 8

Find the value of y when x = 1.3.

1.3 - 1y = 1 + 4 - 1 = 1.92- 1

Page 16: LECT02. Regression and Nonlinear Axes

Prof. Manolito E Bambase Jr. Department of Chemical Engineering. University of the Philippines Los Baños SLIDE16

Regression and Nonlinear Axes2

Fitting Nonlinear Data

For simple non-linear equations, linearization can be done by manipulating or plotting the data so that it can be expressed analogously as a linear equation.

Original equation: y = mx2 + bLinearized Form: y = mw + b (with w = x2)

Original equation: sin y = m(x2 – 4) + bLinearized Form: u = aw + b

(with w = x2 – 4 and u = sin y)

Page 17: LECT02. Regression and Nonlinear Axes

Prof. Manolito E Bambase Jr. Department of Chemical Engineering. University of the Philippines Los Baños SLIDE17

Regression and Nonlinear Axes2

Fitting Nonlinear Data

A mass flow rate M(g/s) is measured as a function of temperature T(0C).

T(0C) 10.0 20.0 40.0 80.0

M 14.76 20.14 27.73 38.47

There is reason to believe that m varies linearly with the square root of T:

M = aT1/2 + b

Determine the values and units of a and b.

Page 18: LECT02. Regression and Nonlinear Axes

Prof. Manolito E Bambase Jr. Department of Chemical Engineering. University of the Philippines Los Baños SLIDE18

Regression and Nonlinear Axes2

Fitting Nonlinear Data

Page 19: LECT02. Regression and Nonlinear Axes

Prof. Manolito E Bambase Jr. Department of Chemical Engineering. University of the Philippines Los Baños SLIDE19

Regression and Nonlinear Axes2

Fitting Nonlinear Data

Page 20: LECT02. Regression and Nonlinear Axes

Prof. Manolito E Bambase Jr. Department of Chemical Engineering. University of the Philippines Los Baños SLIDE20

Regression and Nonlinear Axes2

Fitting Nonlinear Data

Linearizing the data set:

T 10.0 20.0 40.0 80.0

T1/2 3.162 4.472 6.325 8.944

M 14.76 20.14 27.73 38.47

The values of a (slope) and b (intercept) can be determined using the method of least squares as discussed previously.

Page 21: LECT02. Regression and Nonlinear Axes

Prof. Manolito E Bambase Jr. Department of Chemical Engineering. University of the Philippines Los Baños SLIDE21

Regression and Nonlinear Axes2

Fitting Nonlinear Data

Calculate for SX, SY, SXX, and SXY:

X (T1/2) Y (M) X2 XY

3.162 14.76 10.00 46.68

4.472 20.14 20.00 90.07

6.325 27.73 40.00 175.38

8.944 38.47 80.00 344.09

SX = 5.726 SY = 25.275 SXX = 37.50 SXY = 164.05

Page 22: LECT02. Regression and Nonlinear Axes

Prof. Manolito E Bambase Jr. Department of Chemical Engineering. University of the Philippines Los Baños SLIDE22

Regression and Nonlinear Axes2

Fitting a Straight Line to a Set of Data Points

Calculate the slope (a) and intercept (b):

2

2

(164.05) - (5.726)(25.275) a = 4.100(37.50) - 5.726

(37.50)(25.275) - (164.05)(5.726) b = 1.798(37.50) - 5.726

slope :

intercept :

Apply dimensional consistency to get the units of a and b:

a = 4.100 g/(s-0C1/2) and b = 1.798 g/s

Page 23: LECT02. Regression and Nonlinear Axes

Prof. Manolito E Bambase Jr. Department of Chemical Engineering. University of the Philippines Los Baños SLIDE23

Regression and Nonlinear Axes2

Nonlinear Axes: The Logarithmic Coordinates

Page 24: LECT02. Regression and Nonlinear Axes

Prof. Manolito E Bambase Jr. Department of Chemical Engineering. University of the Philippines Los Baños SLIDE24

Regression and Nonlinear Axes2

Nonlinear Axes: The Logarithmic Coordinates

Page 25: LECT02. Regression and Nonlinear Axes

Prof. Manolito E Bambase Jr. Department of Chemical Engineering. University of the Philippines Los Baños SLIDE25

Regression and Nonlinear Axes2

Nonlinear Axes: The Logarithmic Coordinates

Page 26: LECT02. Regression and Nonlinear Axes

Prof. Manolito E Bambase Jr. Department of Chemical Engineering. University of the Philippines Los Baños SLIDE26

Regression and Nonlinear Axes2

Nonlinear Axes: The Logarithmic Coordinates

Page 27: LECT02. Regression and Nonlinear Axes

Prof. Manolito E Bambase Jr. Department of Chemical Engineering. University of the Philippines Los Baños SLIDE27

Regression and Nonlinear Axes2

Nonlinear Axes: The Logarithmic Coordinates

Page 28: LECT02. Regression and Nonlinear Axes

Prof. Manolito E Bambase Jr. Department of Chemical Engineering. University of the Philippines Los Baños SLIDE28

Regression and Nonlinear Axes2

Nonlinear Axes: The Logarithmic Coordinates

Page 29: LECT02. Regression and Nonlinear Axes

Prof. Manolito E Bambase Jr. Department of Chemical Engineering. University of the Philippines Los Baños SLIDE29

Regression and Nonlinear Axes2

Nonlinear Axes: The Logarithmic Coordinates

Page 30: LECT02. Regression and Nonlinear Axes

Prof. Manolito E Bambase Jr. Department of Chemical Engineering. University of the Philippines Los Baños SLIDE30

Regression and Nonlinear Axes2

Nonlinear Axes: The Logarithmic Coordinates

1. If y versus x data appear linear on a semilog plot, then ln(y) versus x would be linear on a rectangular plot, and the data can therefore be correlated by an exponential function:

y = aebx

2. If y versus x data appear linear on a log plot, then ln(y) versus ln(x) would be linear on a rectangular plot, and the data can therefore be correlated by a power function:

y = axb

Page 31: LECT02. Regression and Nonlinear Axes

Prof. Manolito E Bambase Jr. Department of Chemical Engineering. University of the Philippines Los Baños SLIDE31

Regression and Nonlinear Axes2

Nonlinear Axes: The Logarithmic Coordinates

A plot of F versus t yields a straight line that passes through the points (t1 = 15, F1 = 0.298) and (t2 = 30, F2 = 0.0527) on a log plot. Determine the mathematical equation that relates F and t.

If linear on a logarithmic plot, then,

F = atb

Linearizing the equation,

ln (F) = ln (a) + b ln(t)

Page 32: LECT02. Regression and Nonlinear Axes

Prof. Manolito E Bambase Jr. Department of Chemical Engineering. University of the Philippines Los Baños SLIDE32

Regression and Nonlinear Axes2

Nonlinear Axes: The Logarithmic Coordinates

Determine a and b:

2 1

2 1

Δ ln(F) ln(F /F ) ln(0.0527/.298)b = = = = -2.50Δ ln(t) ln(t /t ) ln(30/15)

To determine a:

ln (a) = ln (F1) – b ln(t1) or ln (a) = ln (F2) – b ln(t2)

Using the first data point,

ln (a) = ln (0.298) – b ln(15) = 5.559a = exp (5.559) = 260