0% found this document useful (0 votes)
8 views51 pages

Numeric Chap 3

Chapter 3 discusses curve fitting techniques, including linear regression, polynomial regression, and interpolation methods. It covers the quantification of errors in linear regression, linearization of non-linear models, and provides examples for practical application. The chapter also introduces Newton's and Lagrange's interpolating polynomials for estimating values between data points.

Uploaded by

bekithelegend27
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views51 pages

Numeric Chap 3

Chapter 3 discusses curve fitting techniques, including linear regression, polynomial regression, and interpolation methods. It covers the quantification of errors in linear regression, linearization of non-linear models, and provides examples for practical application. The chapter also introduces Newton's and Lagrange's interpolating polynomials for estimating values between data points.

Uploaded by

bekithelegend27
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 51

Chapter 3: Curve Fitting – Contents

– Introduction
• Functions of Curve Fitting
• Types of Curve Fitting
– Linear Regression
• Quantification of Error of Linear Regression
– Linearization of Non-linear Models
– Polynomial Regression
– Interpolation
• Linear Interpolation
• Quadratic Interpolation
• Cubic Interpolation 1
Functions of Curve Fitting
1. You may require estimates at points b/n the data of
discrete values.
– techniques to fit curves to such data to obtain intermediate
estimates.
2. To make a simplified version of a complicated
function.
– compute values of the function at a number of discrete values
along the range of interest.
– then, a simpler function may be derived to fit these values.
• Both of these applications are known as Curve Fitting.

2
Types of Curve Fitting
• There are two general approaches for curve fitting based
on the amount of error associated with the data.
1. Where the data exhibits a significant error, derive a
single curve that represents the general trend of the
data.
– Because any individual data point may be incorrect, we make
no effort to intersect every point.
– Rather, the curve is designed to follow the pattern of the
points taken as a group.
– One approach of this nature is called least-squares regression
(Fig. 3.1a).
2. Where the data is known to be very precise, fit a curve
that passes directly through each of the points. 3
Types of Curve Fitting
– The estimation of values between well-known discrete points
is called Interpolation (Fig. 3.1b and c).

(a) Linear Regression: did not attempt to connect the


points; followed the general upward trend of the data
with a straight-line.
(b) Linear Interpolation: used straight-line segments to
connect the points (very common practice in eng’g).
(c) Curvilinear Interpolation: used curves to try to
4
capture the data.
Least-squares Regression
• Linear Regression: how to fit the “best” straight-line
through a set of uncertain data points.
• Some criterion must be devised to establish a basis for the fit
• Choose a straight-line that minimizes the discrepancy b/n the
data points and the line
• Minimize the sum of the squares of the residuals b/n the
measured y and the y calculated with the linear model

…. (a)
• This criterion yields a unique line for a given set of data.
• To determine values for a0 and a1, Eq. (a) is differentiated wrt
each coefficient:
… (b)
5
Least-squares Regression
• All summations are from i = 1 to n.
• Setting the derivatives equal to zero will result in a
minimum Sr.

…. (c)
• Since we can express the equations as a set of
two simultaneous linear equations with two unknowns
(a0 & a1):
…. (d)
The equations can be solved simultaneously as,
and … (e, f)
6
Example 3.1: Linear Regression
• Fit a straight-line to the x and y values in the table
below.
x y
1 0.5
2 2.5
3 2.0
4 4.0
5 3.5
6 6.0
7 5.5

7
Example 3.1: Linear Regression
• Soln.

8
Example 3.1: Linear Regression

• Any line other than the one computed in


Example 3.1 results in a larger sum of
the squares of the residuals. 9
Quantification of Error of Linear Regression
• Use analogy with Statistics:
– Central Tendency – mean, median, mode
– Dispersion of Data – Standard Deviation, Coefficient of Variation.

10
Quantification of Error of Linear Regression
• The analogy can be extended to the determination of “Standard
Deviation” for the regression line as:

11
Improvement Due to Linear Regression
• Improvement

12
Improvement Due to Linear Regression
• Improvement

13
Example 3.2: Estimation of error for the linear least-squares fit
• Compute the total standard deviation, the standard error of the
estimate, and the correlation coefficient for the data in Example
3.1.

14
Example 3.2: Estimation of error for the linear least-squares fit
• Example 3.2

15
Example 3.3: Linear Regression
• Fit a straight line to the x and y values in the table
below. Compute the Total Standard Deviation, Standard
Error of Estimate and the Coefficient of Determination.

x y
10 25
20 70
30 380
40 550
50 610
60 1220
70 830
80 1450 16
Example 3.3: Linear Regression
• Soln.

17
Linearization of Non-linear Relationships
• Linear regression provides a powerful technique for
fitting a best line to data.
• However, it is predicated on the fact that the relationship
b/n the dependent and independent variables is linear.
• This is not always the case, and the first step in any
regression analysis should be to plot and visually inspect
the data to ascertain whether a linear model applies.

• Fig. 3.7 (a) Data ill-suited for linear least-squares regression, (b) Parabola is preferable.
18
Linearization of Non-linear Relationships
• Exponential Model

19
Linearization of Non-linear Relationships
• Power Eqn. and Saturation-growth-rate Eqn.

20
Linearization of Non-linear Relationships
• Exponential Eqn. and Power Eqn. Transformations

21
Linearization of Non-linear Relationships
• Saturation-growth-rate Eqn. Transformations

22
Linearization of Non-linear Relationships
• Exponential Eqn. and Power Eqn. Transformations

23
Linearization of Non-linear Relationships
• Saturation-growth-rate Eqn. Transformations

24
Example 3.4: Linearization of Non-linear Eqns.
• Fit a power equation to the data given below by using
linear transformation

x y
1 0.5
2 1.7
3 3.4
4 5.7
5 8.4

25
Example 3.4: Linearization of Non-linear Eqns.
• Soln

26
Example 3.4: Linearization of Non-linear Eqns.
• Soln

27
Example 3.5: Linearization of Non-linear Eqns.
• A

28
Example 3.5: Linearization of Non-linear Eqns.
• Soln.

29
Example 3.5: Linearization of Non-linear Eqns.
• Soln.

30
Polynomial Regression
• PR

31
Polynomial Regression
• PR

32
Polynomial Regression
• PR

33
Example 3.6: Polynomial Regression
• Fit a 2nd – order polynomial (m = 2) to the data given
below.
x y
0 2.1
1 7.7
2 13.6
3 27.2
4 40.9
5 61.1

34
Example 3.6: Polynomial Regression
• Soln.

35
Example 3.6: Polynomial Regression
• Soln.

36
Interpolation
• Interpolation can be used to:
– estimate intermediate values between precise data points;
– approximate a complicated function by a polynomial function which is
simple to differentiate and integrate
• For n + 1 data points, there is one and only one polynomial of
order n that passes through all the points.
– there is only one straight line that connects two points
– only one parabola connects a set of three points
• Polynomial Interpolation consists of determining a unique nth-
order polynomial that fits n + 1 data points.
• The polynomial then provides a formula to compute intermediate
values.

37
Interpolation
• there are a variety of mathematical formats in which nth-order
polynomial can be expressed;
• two alternatives that are well-suited for computer implementation:
Newton and Lagrange Interpolating Polynomials.
• Newton Interpolating Polynomials: Linear Interpolation

• The notation f1(x) designates that this is


a first-order interpolating polynomial.
• : this term is the slope of the
line and a finite-divided-difference
approximation of 1st derivative
38
Example 3.7: Linear Interpolation
• Estimate the natural logarithm of 2 using linear interpolation.
First, perform the computation by interpolating b/n ln 1 = 0 and
ln 6 = 1.791759. Then, repeat the procedure, but use a smaller
interval from ln 1 = 0 to ln 4 = 1.386294.
• Note that the true value of ln 2 ≈ 0.6931472.
Solution:
f(x) = ln x, where x = 2, x0 = 1, x1 = 6

εt = 48.3%.
• Using smaller interval from x0 = 1 to x1 = 4 yields
εt = 33.3%.

• Thus, using the smaller interval reduces the % relative error, εt .


39
Example 3.7: Linear Interpolation
• Two linear interpolations to estimate ln 2

40
Quadratic Interpolation
• For more accurate results, introduce some curvature into the line
connecting the points
• For three data points, use a 2nd-order polynomial
• One convenient form for this purpose is
f2(x) = b0 + b1(x − x0) + b2(x − x0)(x − x1)
f2(x) = b0 + b1x − b1x0 + b2x2 + b2x0x1 − b2xx0 − b2xx1
or, collecting terms,
f2(x) = a0 + a1x + a2x2
• a0 = b0 − b1x0 + b2x0x1
• a1 = b1 − b2x0 − b2x1
• a2 = b2
• Recall that the general form of nth-order polynomial is:
f(x) = a0 + a1x + a2x2 +· · ·+anxn 41
Quadratic Interpolation
• A simple procedure can be used to determine the values of the
coefficients, b0 , b1, b2.
• b0 can be computed with x = x0 → b0 = f(x0)
• b1 can be computed with x = x1 →

• b2 can be computed with x = x2 →

• b1 still represents the slope of the line connecting points x0 and x1.
• The last term, b2(x − x0)(x − x1), introduces the 2nd -order
curvature into the formula.

42
Example 3.8: Quadratic Interpolation
• Fit a 2nd-order polynomial to the three points used in Example 3.7
• x0 = 1 f(x0) = 0
• x1 = 4 f(x1) = 1.386294
• x2 = 6 f(x2) = 1.791759
• Use the polynomial to evaluate ln 2.
Solution
• b0 = f(x0) = 0

• f2(x) = 0 + 0.4620981(x − 1) − 0.0518731(x − 1)(x − 4)


• f2(2) = 0.5658444, εt = 18.4%. (TV = ln 2 ≈ 0.6931472.)
43
General Form of Newton’s Interpolating Polynomials
• General form to fit an nth-order polynomial to n + 1 data points
fn(x) = b0 + b1(x − x0)+· · ·+bn(x − x0)(x − x1) · · · (x − xn−1)
• Use data points [x0, f (x0)], [x1, f (x1)], . . . , [xn, f (xn)] and the
following equations to evaluate the coefficients:
• b0 = f(x0)
• b1 = f [x1, x0]
• b2 = f [x2, x1, x0]
• bn = f [xn, xn−1, . . . , x1, x0]
• the bracketed function evaluations are finite divided differences.

• the nth finite divided difference is


44
General Form of Newton’s Interpolating Polynomials
• The interpolating polynomial is
fn(x) = f (x0) + (x − x0) f [x1, x0] + (x − x0)(x − x1) f [x2, x1, x0]
+ · · ·+(x − x0)(x − x1) · · · (x − xn−1) f [xn, xn−1, . . . , x0]
• which is called Newton’s divided-difference interpolating
polynomial.
• It is not necessary that the data points be equally spaced or that
the abscissa values necessarily be in ascending order.
• Also, notice how the Eqs. are recursive—that is, higher-order
differences are computed by taking differences of lower-order
differences (see Fig. below).

45
Example 3.9: NIP
• In Example 3.8, data points at x0 = 1, x1 = 4, and x2 = 6 were used
to estimate ln 2 with a parabola. Now, adding a fourth point
[x3 = 5; f (x3) = 1.609438], estimate ln 2 with a third-order
Newton’s Interpolating Polynomial.
Solution
• The 3rd-order polynomial with n = 3, is
f3(x) = b0 + b1(x − x0) + b2(x − x0)(x − x1) + b3(x − x0)(x − x1)(x − x2)
• The first divided differences for the problem are

46
Example 3.9 Solution: NIP
• The second divided differences are

• The third divided difference is (with n = 3)

• The results for f [x1, x0], f [x2, x1, x0], and f [x3, x2, x1, x0] represent
the coefficients b1, b2, and b3, respectively.
• Along with b0 = f (x0) = 0.0, the cubic Eqn. is
f3(x) = 0 + 0.4620981(x − 1) − 0.05187311(x − 1)(x − 4)
+ 0.007865529(x − 1)(x − 4)(x − 6)
• which can be used to evaluate f3(2) = 0.6287686, εt = 9.3%.
47
Example 3.9 Solution: NIP
• The complete cubic polynomial is shown in Figure below.

The use of cubic interpolation to estimate ln 2

48
Lagrange Interpolating Polynomials
• The Lagrange Interpolating Polynomial is simply a reformulation
of the Newton polynomial that avoids the computation of divided
differences. It can be represented concisely as
• where

• where П designates the “product of.” For example, the linear


version (n = 1) is

• and the second-order version is

49
Lagrange Interpolating Polynomials
• Each term Li (x) will be 1 at x = xi and 0 at all other sample points.
• Thus, each product Li(x) f(xi) takes on the value of f(xi) at the
sample point xi.
• Consequently, the summation of all the products designated by
fn(x) is the unique nth order polynomial that passes exactly
through all n + 1 data points.

50
Example 3.10: Lagrange Interpolating Polynomials
• Use a Lagrange interpolating polynomial of the first and second
order to evaluate ln 2, on the basis of the data given in Ex. 3.8:
• x0 = 1 f(x0) = 0
• x1 = 4 f(x1) = 1.386294
• x2 = 6 f(x2) = 1.791760
Solution
• The 1st-order polynomial can be used to estimate at x = 2,

• The second-order polynomial is developed as

• As expected, both these results agree with those previously 51


obtained using Newton’s interpolating polynomial.

You might also like