LECTURE 3
2/20/16
MOTIVATION
Data is usually given as a discrete set of values of a continuous domain. One
usual problem that one faces in this situation is when asked to extract data when
no value is given in that point.
2/20/16
2/20/16
Curve Fitting
1) Generate a single curve that will follow the pattern taken as a group. Not all
points will be points on the curve.
2) Generate a single curve/or a series of curves that will contain each point of the
group.
2/20/16
2/20/16
2/20/16
2/20/16
2/20/16
2/20/16
Regression Coefficient
is at times called the regression coefficient. The closer r it is to 1, the more linear
the data is. r =1 implies that the regression line totally contains all the data set.
2/20/16
Regression Coefficient
is at times called the regression coefficient. The closer r it is to 1, the more linear
the data is. r =1 implies that the regression line totally contains all the data set.
2/20/16
Regression Coefficient
is at times called the regression coefficient. The closer r it is to 1, the more linear
the data is. r =1 implies that the regression line totally contains all the data set.
2/20/16
2/20/16
Polynomial Regression
We can extend the technique we used in the linear case to derive a formula for
quadratic regression (and for higher order regression)
This involves solving a system of 3 equations and 3 unknowns.
2/20/16
Polynomial Regression
Find a quadratic formula that can fit the following data.
2/20/16
Polynomial Regression
2/20/16
Polynomial Regression
2/20/16
Polynomial Regression
2/20/16
Interpolation
Given n+1 points, there exists only one nth degree polynomial that passes
through points. Interpolation is the process of identifying the specific polynomial
that passes through all of the n+1 points.
2/20/16
Interpolation
Linear
Interpolation: Given the formula for the line containing these two points
is:
2/20/16
Interpolation
Quadratic Interpolation: The standard form of a quadratic polynomial is:
:
This can be written to:
Where:
2/20/16
Interpolation
2/20/16
Interpolation (example)
Find the quadratic function that passes through the following points: -(2,-3), (1,2), (2,-7)
2/20/16
Interpolation (example)
Find the quadratic function that passes through the following points: -(2,-3), (1,2), (2,-7)
2/20/16
2/20/16
2/20/16
2/20/16
2/20/16
Lagrange Interpolating
Polynomials
x x0
x x1
f1 ( x )
f ( x0 )
f ( x1 )
x0 x1
x1 x0
Lo (x)
L1 ( x)
x x1 x x2
f 2 ( x)
f ( x0 )
x0 x1 x0 x 2
x x0 x x2
f ( x1 )
x1 x0 x1 x 2
x x0 x x1
f ( x2 )
x2 x0 x2 x1
Lo ( x) , j 0
L1 ( x) , j 1
L2 ( x) , j 2
Lagrange Interpolating
Polynomials - Example
Use a Lagrange interpolating polynomial of
the first and second order to evaluate ln(2)
on the basis of the data:
x0 1
x1 4
x2 6
f ( x 0) ln(1) 0
f ( x1) ln( 4) 1.386294
f ( x 2) ln(6) 1.791760
x x1
x x0
f 1( x)
f ( x 0)
f ( x1)
x 0 x1
x1 x 0
24
2 1
f 1(2)
0
1.386294 0.4620981
1 4
4 1
x x1 x x2
x 4 x 6
Lo ( x )
xo x1 xo x2 0 4 0 6
x xo x x2 x 0 x 6
L1 ( x )
x1 xo x1 x2 4 0 4 6
x xo x x1 x 0 x 4
L2 ( x )
x2 xo x2 x1 6 0 6 4
f n ( x ) Li ( x ) f ( xi )
i 0
Li ( x )
j 0
x xj
xi x j
(2 4)( 2 6)
f 2 (2)
0
(1 4)(1 6)
(2 1)( 2 6)
1.386294
(4 1)( 4 6)
(2 1)( 2 4)
1.791760 0.5658444
(6 1)(6 4)
( j i)
Secret Sharing
An (n, k) secret sharing scheme is a scheme where n people receives a part of a
secret, If atleast k persons agree to share their part of the secret, then the secret
should be easily recovered.
1) Knowledge of less than k shares wont make it easier to determine the original
secret.
2) Knowledge of at least k shares would make it easy to compute/determine the
original secret.
2/20/16
Secret Sharing
8 people
2/20/16
Secret Sharing
6 shares
2/20/16
Secret Sharing
6 shares
2/20/16
Illustration
2/20/16
Secret Sharing
The Trusted Third Party (who
knows the secret d) will generate
a (k-1) degree polynomial whose
constant term is d, i.e.
2/20/16
Secret Sharing
The Trusted Third Party (who
knows the secret d) will generate
a (k-1) degree polynomial whose
constant term is d, i.e.
2/20/16
Secret Sharing
The Trusted Third Party (who
knows the secret d) will generate
a (k-1) degree polynomial whose
constant term is d, i.e.
2/20/16
Secret Sharing
Any 6 people who shares i and p(i)
can reconstruct the polynomial
either using Lagrange Polynomial
or Newtons Polynomial.
2/20/16
Secret Sharing
New members can easily be
added because the trusted third
party can just generate new
shares
from
the
original
polynomial.
2/20/16
Spline Interpolation
In the previous section, we fitted n data sets on a
single n-1 degree polynomial.
Spline functions connecting polynomials between
consecutive subsets of point.
2/20/16
Spline Functions
Usually we use polynomials as spline functions
Easy to evaluate
Easy to differentiate
Easy to integrate
2/20/16
Linear Splines
Given x0 , y0 , x1 , y1 ,......, x n 1 , y n 1 x n , y n , fit linear splines to the data. This simply involves
forming the consecutive data through straight lines. So if the above data is given in an ascending
order, the linear splines are given by yi f ( xi )
Figure : Linear splines
2/20/16
Linear Splines
2/20/16
Linear Splines
The upward velocity of a rocket is given as a function of time in Table 1. Find the
velocity at t=16 seconds using linear splines.
time (s)
0
10
15
20
22.5
30
vel (m/s)
0
227.04
362.78
517.35
602.97
901.67
2/20/16
Quadratic Splines
Given x0 , y0 , x1 , y1 ,......, x n 1 , y n 1 , x n , y n , fit quadratic splines through the data. The splines
are given by
f ( x ) a1 x 2 b1 x c1 ,
a 2 x 2 b2 x c2 ,
x 0 x x1
x1 x x 2
.
.
.
a n x 2 bn x cn ,
x n1 x x n
2/20/16
Quadratic Splines
Each quadratic spline goes through two consecutive data points
2
a1 x 0 b1 x 0 c1 f ( x0 )
a1 x12 b1 x1 c1 f ( x1 )
.
.
2
a i xi 1 bi xi 1 ci f ( xi 1 )
2
a i xi bi xi c i f ( xi )
.
.
2
a n x n 1 bn x n1 c n f ( xn 1 )
2
a n x n bn xn cn f ( x n )
This condition gives 2n equations
2/20/16
Quadratic Splines
The first derivatives of two quadratic splines are continuous at the interior points.
For example, the derivative of the first spline
a1 x 2 b1 x c1 is
2 a1 x b1
2 a2 x b2
2/20/16
Quadratic Splines
Similarly at the other interior points,
2a 2 x 2 b2 2a3 x 2 b3 0
.
.
.
2ai xi bi 2ai 1 xi bi 1 0
.
.
.
2a n 1 x n 1 bn 1 2a n x n1 bn 0
We have (n-1) such equations. The total number of equations is (2n) (n 1) (3n 1) .
We can assume that the first spline is linear, that is a1 0
2/20/16
t
s
0
10
15
20
22.5
30
v(t)
m/s
0
227.0
4
362.7
8
517.3
5
602.9
7
901.6
7
v(t)
m/s
0
227.0
4
362.7
8
517.3
5
602.9
7
901.6
7
Solution
0 t 10
a 2 t b2 t c 2 , 10 t 15
2
a3t b3t c3 , 15 t 20
2
a 4 t b4 t c 4 , 20 t 22.5
2
a5 t b5 t c5 ,
2
22.5 t 30
a1 (0) b1 (0) c1 0
2
a1 (10) b1 (10) c1 227.04
2
m/s
10
227.04
15
362.78
20
22.5
30
517.35
602.97
901.67
a 2 t b2 t c 2 ,10 t 15
2
d
2
a1t b1t c1
dt
t 10
d
2
a2t b2t c2
dt
2a1t b1 t 10 2a2t b2 t 10
2a1 10 b1 2a2 10 b2
20a1 b1 20a2 b2 0
t 10
At t=15
At t=20
At t=22.5
Last Equation
a1 0
bcaii
Coefficients of Spline
i
1
2
3
4
5
ai
bi
ci
0
22.704
0
0.8888 4.928 88.88
35.66
0.1356
141.61
1.6048
554.55
33.956
0.2088 28.86
9
152.13