Introduction to Chemical Engineering Calculations Lecture 2.
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. C(t) = e t 2 a nπx n x n y 0 n=1 a sinh (nπb/a) a a a u(x,y) = f(x)sin dx sin sinh 2
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. 3
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 4
Fitting a Straight Line to a Set of Data Points 5
Fitting a Straight Line to a Set of Data Points Calculating the slope and intercept using the method of least squares: slope : Δy m = = S - S S xy x y 2 xx x Δx S - S intercept : b = S S - S S xx y xy x 2 xx x S - S 6
Fitting a Straight Line to a Set of Data Points Calculating the S-values: S S S S x y xx (average of x values) = (average of y values) = i1 i1 n 2 2 xi n i1 (average of x values) = (average of xy values) = 1 n n 1 n n 1 1 n x y xy i i n i1 x y i i 7
Fitting a Straight Line to a Set of Data Points For the previous data set: S S S S x y xx xy 1 = 10 30 50 70 90 = 50 5 1 = 20.0 52.1 84.6 118.3 151.0 85.2 5 1 2 2 2 2 2 = 10 30 50 70 90 = 3300 5 10 20 30 52.1 5084.6 1 = 5572.8 5 70 118.3 90 151.0 8
Fitting a Straight Line to a Set of Data Points Calculating the slope and intercept: m 5572.8-5085.2 2 = 1.641 3300-50 b 330085.2-5572.850 2 3300-50 3.15 9
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 10
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) 11
Two-Point Linear Interpolation 12
Two-Point Linear Interpolation 13
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, y - y x - x Rearranging the equation, y = y + y - y = x - x 1 2 1 1 2 1 x - x 1 1 2 1 x2- x1 y - y 14
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 3 y 1 4 8 Find the value of y when x = 1.3. 1.3-1 y = 1 + 4-1 = 1.9 2-1 15
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 = mx 2 + b Linearized Form: y = mw + b (with w = x 2 ) Original equation: Linearized Form: sin y = m(x 2 4) + b u = aw + b (with w = x 2 4 and u = sin y) 16
Fitting Nonlinear Data A mass flow rate M(g/s) is measured as a function of temperature T( 0 C). T( 0 C) 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 = at 1/2 + b Determine the values and units of a and b. 17
Fitting Nonlinear Data 18
Fitting Nonlinear Data 19
Fitting Nonlinear Data Linearizing the data set: T 10.0 20.0 40.0 80.0 T 1/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. 20
Fitting Nonlinear Data Calculate for S X, S Y, S XX, and S XY : X (T 1/2 ) Y (M) X 2 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 S X = 5.726 S Y = 25.275 S XX = 37.50 S XY = 164.05 21
Fitting a Straight Line to a Set of Data Points Calculate the slope (a) and intercept (b): slope : intercept : (164.05) - (5.726)(25.275) a = 4.100 2 (37.50) - 5.726 (37.50)(25.275) - (164.05)(5.726) b = 1.798 2 (37.50) - 5.726 Apply dimensional consistency to get the units of a and b: a = 4.100 g/(s- 0 C 1/2 ) and b = 1.798 g/s 22
Nonlinear Axes: The Logarithmic Coordinates 23
Nonlinear Axes: The Logarithmic Coordinates 24
Nonlinear Axes: The Logarithmic Coordinates 25
Nonlinear Axes: The Logarithmic Coordinates 26
Nonlinear Axes: The Logarithmic Coordinates 27
Nonlinear Axes: The Logarithmic Coordinates 28
Nonlinear Axes: The Logarithmic Coordinates 29
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 = ae bx 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 = ax b 30
Nonlinear Axes: The Logarithmic Coordinates A plot of F versus t yields a straight line that passes through the points (t 1 = 15, F 1 = 0.298) and (t 2 = 30, F 2 = 0.0527) on a log plot. Determine the mathematical equation that relates F and t. If linear on a logarithmic plot, then, Linearizing the equation, F = at b ln (F) = ln (a) + b ln(t) 31
Nonlinear Axes: The Logarithmic Coordinates Determine a and b: Δ ln(f) ln(f 2 /F 1) ln(0.0527/.298) b = = = = -2.50 Δ ln(t) ln(t /t ) ln(30/15) To determine a: 2 1 ln (a) = ln (F 1 ) b ln(t 1 ) or ln (a) = ln (F 2 ) b ln(t 2 ) Using the first data point, ln (a) = ln (0.298) b ln(15) = 5.559 a = exp (5.559) = 260 32