You are on page 1of 7

BCHE-

FA17-
[Year]
2019

Mat Lab PROJECT

PROJECT REPORT
1. HAMZA TAHIR
2. ALI HAIDER
3. RAFAQAT ALI
4. USAMA ATHAR
5. ANAS MUSTAFA
6. TAHIR RASHEED

THE UNIVERSITY OF FAISALABAD | CHEMICAL ENINEERING DEPARTMENT


The University of Faisalabad

Contents
1. Introduction:........................................................................................................................................2
1.1. Interpolation:...............................................................................................................................2
2. Lagrange Interpolation:.......................................................................................................................2
2.1. Formula:......................................................................................................................................2
2.2. Applications:............................................................................................................................3
3. Significance:.........................................................................................................................................3
4. Benefits:...............................................................................................................................................3
5. Limitations:..........................................................................................................................................3
6. Advantages:.........................................................................................................................................4
7. Disadvantages:.....................................................................................................................................4
8. Mathematically solved example by Lagrange’s Interpolation method:...............................................4
9. Lagrange interpolation formulation coding in Matlab:........................................................................5

1|Page
The University of Faisalabad

1. Introduction:
1.1. Interpolation:
Many times , data is given at discrete points such as, x,y0,0 , x,y (1,1) ......, x,y(n,n), . So, how
then does (x, y) one find the values of y at any other values of x?

Well, a continuous functions  xf  can be used to represent the n 1 data values with  xf 
passing through n 1 points .Then one can find the value of y at any other value of x . This is
called interpolation.
“The process of finding a value between two points on a line or curve.”
There are number of interpolation methods available i.e., Newton’s forwards and backward
methods, Aitken’s method and Lagrange method is to use polynomial fits to available value to
interpolate between those values. If there are (N) data values, a polynomial of degree N+1 can
be found that will pass through all the points.

2. Lagrange Interpolation:
Lagrange’s method is applicable to problems where the independence variable occurs with
equal and unequal intervals, but preferably this formula is applied in a situation where there
are unequal intervals in the given independence series. let the values of the independence
variables (x) are given as a, b, c, d, .... etc., and the corresponding values of the function
(dependent variable) as f(a), f(b), f(c), f(d), ...

2.1. Formula:

The formula was first published by Waring (1779), rediscovered by Euler in 1783, and published
by Lagrange in 1795 (1988). When constructing interpolating polynomials, there is a tradeoff
between having a better fit and having a smooth well-behaved fitting function.

2|Page
The University of Faisalabad

2.2. Applications:
Calculus provides so many tools that can be used to understand the behavior of function, but in
most cases it is necessary for these functions to be continuous and differentiable.
This presents a problem in most “real” application, in which function is used to model
relationship between quantities, but our only knowledge of these function consist of a set of
discrete data points, where the data is obtained from measurement. Therefore, we need to be
able to construct continuous function based on discrete data.
The problem of constructing such as a continuous function is called data fitting.
A special case of data fitting known as interpolation.

3. Significance:
An alternate method of interpolation is to use polynomial fits to the available values to
interpolate between those values. If there are N data values, a polynomial of degree N-1 can be
found that will pass through all the points.
The Lagrange polynomials provide a convenient alternative to solving the simultaneous
equations that result from requiring the polynomials to pass through the data values. This is a
particularly convenient way to interpolate among tabulated values with polynomials.

4. Benefits:
Lagrange polynomials are awesome and easy to compute; you do not need to solve any linear
system (as I first thought when asked to create a polynomial that will pass through a set of
points).
By construction the polynomial will pass through every point you want but in order to do this
you need a high order polynomial. For instance, if you want the polynomial to pass three points
you simply need at least a second order polynomial (assuming the three points are not
collinear) and in general if you want the polynomial to pass through “n” points you need a
polynomial of order “n-1”.

5. Limitations:

The obvious problem is that a higher order polynomial is huge. If I have 100 nodes, then it will
be a 99th degree polynomial. The values are unpredictable and will be wildly inaccurate
between nodes. There is practically no advantage to using it other than it being intellectually
simple.

3|Page
The University of Faisalabad

6. Advantages:

 An advantage of Lagrange Iinterpolation is that the method does not need evenly
spaced values in x. However, it is usually preferable to search for the nearest value in
the table and then use the lowest-order interpolation consistent with the functional
form of the data.
 The formula is simple and easy to remember.
 There is no need to construct the divided difference table.
 The application of the formula is not speedy.

7. Disadvantages:

 There is always a chance to committing some error.


 The calculation provides no check whether the functional values used the taken
correctly or not.

8. Mathematically solved example by Lagrange’s Interpolation method:


X = [1 3 4 6]
Y = [4 7 8 11]
Solution:

Using Lagrange formula:

( x−3)(x−4 )( x−6) ( x−1)(x−4)( x−6) ( x−1)( x−3)(x −6)


f ( x)= ×4+ ×7+ ×8+
(1−3)(1−4)(1−6) (3−1)(3−4)(3−6) ( 4−1)( 4−3)(4−6)
( x−1)(x−3)(x−4)
× 11
( 6−1)(6−3)(6−4)
Put x=5 in above equation

(5−3)(5−4)(5−6) (5−1)(5−4 )(5−6) (5−1)(5−3)(5−6)


f (5)= ×4+ ×7+ ×8+
(1−3)(1−4 )(1−6) (3−1)(3−4 )(3−6) ( 4−1)(4−3)( 4−6)
(5−1)(5−3)(5−4)
× 11
(6−1)(6−3)(6−4)

(2)(1)(−1) (4 )(1)(−1) ( 4)(2)( 1) ( 4)(2)(1)


f (5)= ×4+ ×7+ ×8+ × 11
(−2)(−3)(−5) (2)(−1)(−3) ( 3)(1)(2) (5)(3)(2)
f (5) = 0.266 -4.667 + 10.667 + 2.93333

4|Page
The University of Faisalabad

f (5) = 9.2

9. Lagrange interpolation formulation coding in Matlab:

X = [1 3 4 6] ;
Y = [4 7 8 11] ;
n = length(x) - 1;

xp = 5;

sm = 0;
for i = 1 : n+1
pr = 1;
for j = 1 : n+1
if j ~= i
pr = pr * (xp - x (j))/(x (i) - x (j));
end
end
sm = sm + y (i) * pr;
end
yp = sm

yp = 9.2

5|Page
The University of Faisalabad

6|Page

You might also like