0% found this document useful (0 votes)
23 views38 pages

2.1 FULL Content

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

2.1 FULL Content

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

UNIVERSITY INSTITUTE OF

ENGINEERING
DEPARTMENT OF COMPUTER SCIENCE
AND ENGINEERING

Numerical Methods and Optimization Using Python


Course Code- 22CSH-259/22ITH-259 DISCOVER . LEARN . EMPOWER
By: MSC Shivali (12930)
Polynomial Interpolation:

• Polynomial interpolation involves constructing a polynomial function that passes through a


given set of data points.
• The objective is to find a polynomial of the least degree that accurately represents the data.
• The resulting polynomial can be a powerful tool for estimating values between the given data
points, providing a smooth curve that captures the underlying behavior of the data.
• One of the widely used methods for polynomial interpolation is the Lagrange interpolation.
• This method formulates a polynomial as a linear combination of Lagrange basis polynom

2
Curve Fitting:

• Curve fitting, on the other hand, is a broader concept that encompasses various methods to
approximate the shape of a curve based on a set of observed data points.
• While polynomial interpolation is one specific technique for curve fitting, there are other
approaches such as linear regression, spline interpolation, and least squares fitting.
• Curve fitting is particularly valuable when dealing with noisy or incomplete data, as it helps in
uncovering patterns and trends within the dataset.
• The choice of the fitting method depends on the nature of the data and the desired
characteristics of the fitted curve.

3
Interpolation and Curve Fitting
Given the n + 1 data points (xi, yi), i = 0, 1, ... , n, estimate y(x).
Introduction Discrete data sets, or tables of the form

are commonly involved in technical calculations.


The source of the data may be experimental observations or numerical computations.
There is a distinction between interpolation and curve fitting.
In interpolation we construct a curve through the data points.
Thus the curve does not necessarily hit the data points. The difference between interpolation
and curve fitting is illustrated in Figure 3.1

4
Polynomial Interpolation Lagrange’s Method

The simplest form of an interpolant is a polynomial. It is always possible to construct a unique


polynomial of degree n that passes through n + 1 distinct data points. One means of obtaining
this polynomial is the formula of Lagrange,

5
6
7
Newton’s Method
Although Lagrange’s method is conceptually simple, it does not lend itself to an efficient algorithm. A better computational
procedure is obtained with Newton’s method, where the interpolating polynomial is written in the form

8
If the coefficients are computed by hand, it is convenient to work with the format in Table 3.1 (shown for n = 4).
9
The diagonal terms (y0, ∇y1, ∇2y2, ∇3y3, and ∇4 y4) in the table are the coefficients of the polynomial. If the data
points are listed in a different order, the entries in the table will change, but the resultant polynomial will be the same—
recall that a polynomial of degree n interpolating n + 1 distinct data points is unique.

10
Least-Squares Fit
• The task of curve fitting is to find a smooth curve that fits the data points “on the average.”
• This curve should have a simple form (e.g., a low-order polynomial), so as to not reproduce
the noise.
Let f(x) = f(x;a0, a1, ... , am)
• be the function that is to be fitted to the n + 1 data points (xi, yi), i = 0, 1, ... , n.
• The notation implies that we have a function of x that contains m + 1 variable parameters a0,
a1, ... , am, where m < n.
• The form of f(x) is determined beforehand, usually from the theory associated with the
experiment from which the data are obtained.
• The only means of adjusting the fit are the parameters. For example, if the data represent the
displacements yi of an over-damped mass-spring system at time ti, the theory suggests the
choice f(t) = a0te−a1t .
• Thus curve fitting consists of two steps: choosing the form of f(x), followed by computation of
the parameters that produce the best fit to the data.
11
• This brings us to the question: What is meant by the “best” fit? If the noise is confined to the
y-coordinate, the most commonly used measure is the least-squares fit, which minimizes the
function

with respect to each aj . Therefore, the optimal values of the parameters are given by the
solution of the equations

he terms ri = yi − f(xi) in Eq. (3.13) are called residuals; they represent the discrepancy between
the data points and the fitting function at xi. The function S to be minimized is thus the sum of
the squares of the residuals. Equations (3.14) are generally nonlinear in aj and may thus be
difficult to solve. Often the fitting function is chosen as a linear combination of specified
functions fj(x),

12
in which case Eqs. (3.14) are linear. If the fitting function is a polynomial, we have f0(x) = 1, f1(x)
= x, f2(x) = x2, and so on. The spread of the data about the fitting curve is quantified by the
standard deviation, defined a

Note that if n = m, we have interpolation, not curve fitting. In that case both the numerator and
the denominator in Eq. (3.15) are zero, so that σ is ind

13
Fitting a Straight Line

Fitting a straight line


f(x) = a + bx (3.16)

14
15
Fitting Linear Forms
Consider the least-squares fit of the linear form
where each fj(x) is a predetermined function of x, called a basis function. Substitution in Eq.
(3.13) yields

16
Polynomial Fit

only low-order polynomials are useful in curve fitting. Polynomials of high order are not recommended, because
they tend to reproduce the noise inherent in the data. 17
PolyFit
• The function polyFit in this module sets up and solves the normal equations for the
coefficients of a polynomial of degree m.

18
19
Basic Algebra

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
THANK YOU

38

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy