Excep for Scientists and Engineers: Numerical Methods by E. Joseph Billo Copyright 0 2007 John Wiley & Sons, Inc. Appendix 4 Some Equations for Curve Fitting This appendix describes a number of equation types that can be used for curve fitting. Some of the equation types can be handled by Excel's Trendline utility for charts; these cases are noted below. Multiple Regression. Multiple regression fits data to a model that defines y as a function of two or more independent x variables. For example, you might want to fit the yield of a biological fermentation product as a function of temperature (0, pressure of COZ gas (P) in the fermenter and fermentation time (t) y = a.t + b.p +ct + d (A4-1) using data from a series of fermentation experiments with different conditions of temperature, pressure and time. Since you can't create a chart with three x-axes (e.g., T, P and t), you can't use Trendline for multiple regression. Polynomial Regression. Polynomial regression fits data to a power series such as equation A4-2: y = a + bx +cx2 + dx3 +... (A4-2) 409
-30 L Figure A4-1. Polynomial of order 3. The curve follows equation A42 with a = 5, b = -1, c = -5 and d = 1. The Trendline type is Polynomial. The highest-order polynomial that Trendline can use as a fitting function is a regular polynomial of order six, i.e., y = ax6 + bx5 +cx4 + ak3 + ex2 +fx + g. LINEST is not limited to order six, and LINEST can also fit data using other polynomials such as y = ax2 + bx3'2 + cx + + e. Exponential Decrease. 0.1 0 0.08 *, 0.06 0.04 0.02 0.00 Figure A4-2. Exponential decrease to zero. The curve follows equation A43 with a = 0.1 and b = -0.5. The Trendline equation is shown on the chart. Data with the behavior shown in Figure A4-2 can be fitted by the exponential equation
APPENDI 4 EOUATIONS FOR CURVE FITTING 41 1 y = aebx (A4-3) The sign of b is often negative (as in radioactive decay), giving rise to the decreasing behavior shown in Figure A4-2. The linearized form of the equation is In y = bx + In a; the Trendline type is Exponential. Exponential Growth. If the sign of b in equation A4-3 is positive, the curvature is upwards, as in Figure A4-3. r, Figure A4-3. Exponential increase. The curve follows equation A4-3 with a = 0.1 and b = 0.5. The Trendline equation is shown on the chart. Exponential Decrease or Increase Between Limits. If the curve decreases exponentially to a nonzero limit, or rises exponentially to a limiting value as in Figure A4-4, the form of the equation is y = aebx + c Excel's Trendline cannot handle data of this type. (A4-4)
412 ECEL: NUMERICAL METHODS 1 0.8 x 0.6 0.4 0.2 0 Figure A4-4. Exponential increase to a limit. The curve follows equation A4-4 with a = -1, b = -0.5 and c = 1. The linearized form of the equation is In 0, - c) = bx + In a. Double Exponential Decay to Zero. The sum of two exponentials (equation A4-5) gives rise to behavior similar to that shown in Figure A4-5. This type of behavior is observed, for example, in the radioactive decay of a mixture of two nuclides with different half-lives, one short-lived and the other relatively longer-lived. y = ae-bt + ce-dl (A4-5) 21 >r 1.5 o. q \ 0,, Figure A4-5. Double exponential decay. The curve follows equation A4-5 with a = 1, b = -2, c = 1 and d = -0.2. If the second term is subtracted rather than added, a variety of curve shapes are possible. Figures A4-6 and A4-7 illustrate two of the possible behaviors.
APPENDI 4 EQUATIONS FOR CURVE FITTING 413 I - - I I I I I 2 4 6 8 10-1 L Figure A4-6. Double exponential decay. The curve follows equation A4-5 with a = 1, b = 4.2, c = -2 and d = -2, -0.8 Figure A4-7. Double exponential decay. The curve follows equation A4-5 with a = 1, b = -2, c = -1 and d = -0.2. Equation A4-5 is intrinsically nonlinear (cannot be converted into a linear form). Power. Data with the behavior shown in Figure A4-8 can be fitted by equation A4-6. b y=a (A4-6)
4 14 ECEL: NUMERICAL METHODS y= 1.1x-O.~ Figure A4-8. Power curve. The curve follows equation A4-6 with a = 1.1, b = -0.5. The Trendline equation is shown on the chart. The linearized form of equation A4-6 is In y = b In x + In a; the Trendline form is Power. Logarithmic. 4 2 y = 2Ln(x) + 1-0 -2 I 10 t -6 Figure A4-9. Logarithmic function. The curve follows equation A4-7 with a = 2, b = 1. Data with the behavior shown in Figure A4-9 can be fitted by the logarithmic equation A4-7. y = a lnx + b (A4-7)
APPENDI 4 EQUATIONS FOR CURVE FITTING 415 The Trendline type is Logarithmic. "Plateau" Curve. A relationship of the form ax y=b+x exhibits the behavior shown in Figure A4-10. (A4-8) 1 >r 0.5 0 Figure A4-10. Plateau curve. The curve follows equation A4-8 with a = 1, b = 1. In biochemistry, this type of curve is encountered in a plot of reaction rate of an enzyme-catalyzed reaction of a substrate as a function of the concentration of the substrate, as in Figure A4-10. The behavior is described by the Michaelis- Menten equation, (A4-9) where V is the reaction velocity (typical units mmol/s), K,,, is the Michaelis- Menten constant (typical units mm), V,, is the maximum reaction velocity and [S] is the substrate concentration. Some typical results are shown in Figure A4-11.
416 ECEL: NUMERICAL METHODS 50 40 30 20 10 0 Figure A4-11. Michaelis-Menten enzyme kinetics. The curve follows equation A4-9 with V,, = 50, K,, = 0.5. Double Reciprocal Plot. The Michaelis-Menten equation can be converted to a straight line equation by taking the reciprocals of each side. This treatment is called a Lineweaver-Burk plot, a plot of the reciprocal of the enzymatic reaction velocity (UV) versus the reciprocal of the substrate concentration (l/[si). 1 K,1 1 - +- (A4-10) V Vmax S Vmax A double-reciprocal plot of the data of Figure A4-11 is shown in Figure A4-12. The parameters V,,, and K,,, can be obtained from the slope and intercept of the straight line (Vmm = Uintercept, K,,, = interceptlslope). However, relationships dealing with the propagation of error must be used to calculate the standard deviations of V,,, and K, from the standard deviations of slope and intercept. By contrast, when the Solver is used the expression does not need to be rearranged, ycalc is calculated directly from equation A4-19, the Solver returns the coefficients V,,, and K,,,, and SolvStat.xls returns the standard deviations of V,,, and K,.
APPENDI 4 EQUATIONS FOR CURVE FITTING 417 0.00 ' 0 5 10 WSI Figure A4-12. Double-reciprocal plot of enzyme kinetics. The curve follows equation A4-10 with V,,, = 50, K,,, = 0.5. Logistic Function. The logistic equation or dose-response curve 1 y=- 1 + e-" produces an S-shaped curve like the one shown in Figure A4-13. (A4-11) Y -10-5 0 5 10 Figure A4-13. Simple logistic curve. The curve follows equation A4-1 1 with a = 1.
418 ECEL: NUMERICAL METHODS In the dose-response form of the equation, the y-axis (the response) is normalized to 100% and the x-axis (usually logarithmic) is normalized so that the midpoint (the half-maximum response or ECSo) occurs at x = 0. Logistic Curve with Variable Slope. In equation A4-11, the coefficient a determines the slope of the rising part of the curve; in biochemistry a is referred to as the Hill slope. Figure A4-14 illustrates the effect of varying Hill slope. At the midpoint the slope is a/4. -10-5 0 5 10 Figure A4-14. Variable slopes of logistic curve. The three curves have a = 0.5, 1 and 2, respectively. Logistic Curve with Additional Parameters. Equation A4-12 is the logistic equation with addition parameters that determine the height of the "plateau" and the offset of the mid-point from x = 0. b Y= (A4-12) c + e-ax The height of the plateau is equal to b/c.
APPENDI 4 EQUATIONS FOR CURVE FITTING 419 Figure A4-15. Logistic curve with additional variables. The curve follows equation A4-12 with a = 1, b = 0.5 and c = 5. Logistic Curve with Offset on the y-axis. The logistic equation (A4-13) -10-5 0 5 10 15 20 A Figure A4-16. Logistic curve with offset on the y-axis. The curve follows equation A4-13 with a = 1, b = -2, c = 1 and d = -0.2. This equation takes into account the value of the plateau maximum and minimum (coefficients a and d, respectively), the offset on the x-axis, and the Hill slope.
420 ECEL: NUMERICAL METHODS Gaussian Curve. The Gaussian or normal error curve (equation A4-14) exp[-(x - p)2 /202] Y= (A4-14) OJG can be used to model UV-visible band shapes, usually in order to deconvolute a spectrum consisting of two or more overlapping bands. When used for deconvolution, a simplified form of the Gaussian formula can be used, for example A = &axe-[(~-~)~~~l l (A4-15) where A is absorbance, x is the independent variable, either wavelength (e.g., nm), or, more commonly, l/wavelength (e.g., cm- ), and in is the value of x at Amax. The parameters is related to the bandwidth at half-height. 10 8 6 4 2 0 Figure A4-17. Gaussian curve. The curve follows equation A4-15 with A,, = 10, m = 5 and s = 1.5. Log vs. Reciprocal. The function y=exp a-- ( 3 (A4-16) is often seen in the relationship of physical properties to temperature. The linearized form is In y = -b/x + a. This equation form is encountered in the Clausius-Clapeyron equation (A4-17)
APPENDI 4 EOUATIONS FOR CURVE FITTING 42 1 which relates vapor pressure of a pure substance to temperature, and the Arrhenius equation Ink=- -Ea +InA RT which relates rate constant k of a reaction to temperature. (A4-1 8) Trigonometric Functions. Excel's trigonometric functions require angles in radians. For an angle 6' in degrees, use n6'/180. The function represented by equation A4-19 y = a sin (bx + c) + d (A4-19) or its cosine equivalent produces a curve with the appearance of a "sine wave" centered around the x-axis if d = 0, or offset from the x-axis if d # 0. Functions of the form y = sin ax + sin bx (A4-20) and their cosine equivalents produce a "beat frequency" curve such as the one shown in Figure A4-17. Figure A4-18. "Beat fi-equency" curve. The curve follows equation A4-21 with a = 1, b = 0.9. Equation A4-21 combines the parameters of equations A4-19 and A4-20. y =a sin (bx + c) + d sin (ex +A + g (A4-2 1)