CURVE FITTIG LEAST SQUARE LIE Consider the class of linear function of the form f ( x) B...() In previous chapter we saw how to construct a polnomial that passes through a set of points. If all numerical values x, are nown to several significant digits of accurac, then the polnomial interpolation can be used successfull ; other wise it can not. For values x,, it realize that the true value f( x ) satisfies f ( x ) e.() where e is the measurement error How do find the best approximation of the form () that goes near (not alwas through) the points? To answer this question we need to discuss the errors e f ( x ) () There are several norms that can be used with the residuals in () to measure how far the curve f ( x) lies from the data max MAXIMUM ERROR : E ( f ) max f ( x ) e...() AVERAGE ERROR : E ( f ) f ( x ) e...(5) K K K ROOT MEA SQUARE ERROR ( RMS): E ( f ) f ( x ) e K...(6)
Example Compare the maximum error, average error and RMS error for the linear approximation f ( x) 8.6.6x to the data points (-,), (,9), (,7), (,5), (,), (,), (5,) and (6,-). x f ( x) 8.6.6x e f ( x ) e - 5 6 9 7 5 -. 8.6 7. 5..8..6 -......8.6..6.6..6.6.6. =8 MAXIMUM ERROR : E ( f ) max.,.,.,.,.8,.6,.8 AVERAGE ERROR : E ( f ) e (.6).5 8 K K 8 ROOT MEA SQUARE ERROR ( RMS): E ( f ) e (.).8 Best fitting line is found b minimizing one of the quantities in equation () through (6). Hence there are three best fitting lines that we could find. The third norm E ( f ) is the traditional choice because it is much easier to minimize computationall.
FIDIG THE LEAST SQUARES LIES Let x, be a set of points ( where x are distinct). The least square line f ( x) B is the line minimize the RMS error E ( f ). ( x, ) ( x, ) ( x, ) ( x, ) The quantit E ( f ) will be minimum if and onl if the quantit ( E ( f )) ( B) is minimum Theorem Suppose that x, are points. The coefficients of the least square line B are the solution of the following linear sstem x A x B x x A B...(7)
Proof Where E( A, B) B The minimum value of E( A, B ) is determined b setting the partial derivatives E( A, B) E( A, B) and equal to zero and solving these equation for A and B. A B E( A, B) A B x Bx x ( ) ( )...(8) E( A, B) ( B ) ( Bx )...(9) B from (8) and (9) x A x B x x A B
Example Find the least squares line B for the following data and evaluate E ( f ) x -6-6 7 5 f( x ) 7.6.. -. According to the above table x f( x ) x x e f ( x ) ( e ) -6-6 7 5 7.6.. -. 6 6 - -......6.6.. Where =5 then 7 8-8. 8 A B= -8 A 5B= 7 solve x sstem to find A= -.6 and B=. B.6x. and E( f)..8 5 5
THE POWER FIT m Theorem Suppose that x, squares power curve points, where x are distinct. The coefficients A of the least m is given b Proof, where m x A x m E( A) m m x E m m x A A m x Example Find the power fits and for the following data and use ( ) determine which curve is best. x..6.9. 5. 7.5.6. 9 5 5 x x for A and for A 5 5 6 x x 6
Establish following table x x x x 6 x x x..6.9. 5. 7.5.6. 9. 5.9 6.76 8.. 8.67 7.576.8.768 6 7.98 5.697 7.78.7 6 8. 8.95 59.8 7.7. 9.675 7.656. 9.56.8 9.55 86.56 5.6 6.59 65.66 89.5 7.95 9.56 7.95 9.56 for A.687 and for A.59 65.66 89.5 f ( x).687 x and g( x).59x Find best curve fit using E ( f ) x f( x ) gx ( ) e f ( x ) e g( x ) e e..6.9. 5. 7.5.6. 9. 6.78 8.9..9 7.7.7 7.8.7.9 9..68..8..7.8.....75.7.6..99...59..89 8.9.8 for.687 x E ( f ) 8.9.97 and for.59 x E ( f ).8.85 5 5 the best power fit is.59x 7
DATA LIEARIZATIO METHOD FOR Ce Suppose that we are given points x, and we want to fit an exponential curve Ce...() The first step is to tae logarithm of both sides ln ln( Ce ) ln C ln e then ln ln C...() Then sa Y ln, X x, and B lnc from () Y AX B Then use X A X B X Y X A B Y to find A, B and C Example Use data linearization method and find the exponential fit Ce for the following data x.5.5.5 5 7.5 where, Ce then ln lnc let Y ln, x X and B lnc 8
Establish table x X Y ln XY X.5.5.5 5 7.5.5.96.5.69.5.96.56.87 8.6 9 6 6.96 6.9 =5 AB=6.9 -x A 5B=6.98 A=.9 A=.9 B=.57.57 lnc B.57 C e.579 Ce.579e.9x 9
CHAGE OF VARIABLES FOR DATA LIEARIZATIO Function =f(x) A B x Linearized form Y=AXB A B x Change of variables and constants X, Y x D x C x C D D C Y, A, B D D B B Y, X x x B A B x Y, X x Aln x B Aln x B X ln x, Y Ce ln ln C Y ln, X x, B lnc A Cx ln ln ln A x C Y ln, X ln x, B lnc B B X x, Y Cxe Dx ln B x Y ln, X x x L L ln lnc Ce L Y ln, X x, B lnc
Example : Fit a curve of the form A Cx to the following data x 5 and determine E ( f ) A A then Cx Cx ln Aln x ln C A Cx where Y ln, X ln x, B ln C x X ln x Y ln X XY 5.98.69.86.8.96.98.97.5..796.68.685.7 =.685 A.796 B =.7.796 A B =.68 solve x sstem then Where -.85 A= -.75 -------- A=.9889 and B=.9996.989.9996 A.989 and B ln C C e C e.77 f ( x).77x ow find E ( f ) using f(x) and given data B
x ( ) f x e f ( x ) e 5 5.8.8...779.66.9.9.7.85 E( f).85.5 EXERCISE : Let a x a x Find the curve fit for the function using the following table and determine E ( f ) x.5. -.6.78.66.8 EXERCISE : Find the curve fit f ( x) Cxe B with f (), for the points (-,), (, 6) and (,9) using the least square technique and determine E ( f ).
LEAST SQUARE PARABOLA Theorem: Suppose that x, coefficients of the least squares parabola, are points, where the abscissas are disdinct. The f ( x) Bx C...() are the solution values A,B and C of the linear sstem, x A x B x C x x A x B x C x x A x B C...() Proof: The coefficients A,B and C will minimize the quantit, The partial derivatives,, E A B C Bx C E, A Bx C x x A x B x C x E Bx C x, x A x B x C x B E Bx C, x A x B C C
Example: Find the least squares parabola fort he four points,,,,, and, x x^ x^ x^ (x)() (x^)() - 9-7 8-9 7 8 6 6 6 56 8 8 9 5 5 5 79 The linear sstem for finding A,B and C becomes x A x B x C x x A x B x C x x A x B C 5A 5B 9C 79 5A 9B C 5 9A B C 8
ow we should solve x sstem. Using Cramer s Rule, 5 5 9 5 9 78 9 79 5 9 5 9 585 585 A.786 8 78 5 79 9 5 5 6 6 B.995 9 8 78 5 5 79 5 9 5 788 788 C.8559 9 8 78 Thus, the least-square parabola is.786 x.995 x.8559 5