Docsity

Undetermined-Coefficients-and-Splines, Lecture notes of Mathematical Analysis

Toggle sidebar
bg1
Splines
Spline interpolation is a different interpolation method in which a
piecewise polynomial function fits the given points known as the spline.
A spline is a composite function composed of n low-degree
polynomials each of which fits in the interval between xi – 1 and xi, (i = 1,
…, n).
The term spline was coined after a draftsman's device of drawing
a smooth curve through given points using a thin flexible strip (called a
spline). Knots are the points where two connecting splines meet. Since
the connecting polynomials can be of any degree, there are various
types of splines: linear, quadratic, cubic, quartic, quintic, among
others.
Linear Splines
It has two parameters. Given (x0, y0), (x1, y1), …, (xn – 1 , yn – 1), (xn, yn),
fit linear splines (refer to the figure) to the data. This is as simple as
forming the consecutive data with straight lines.
The linear splines are given by
f
(
x
)
=f
(
x0
)
+f
(
x1
)
−f
(
x0
)
x1−x0
(
x−x0
)
, x0≤ x ≤ x1
¿f
(
x1
)
+f
(
x2
)
−f
(
x1
)
x2−x1
(
x−x1
)
, x1≤ x ≤ x2
⋮
Module III Solving Linear and NonLinear Equations
(Milan, Basa, and Bacungan, 2021)
Note:
A spline function of degree k exists if there are points a = x0 < x1 < … < xn = b
such that s is a polynomial of degree at most k on each of the intervals [xj – 1; xj] for j
= 1, …, n and s has continuous k – 1 derivatives. To put it another way, s Є Ck – 1[a,
b]. For k = 1, 2, 3, or 4, we call spline a linear, quadratic, cubic, or quartic spline,
respectively. The numbers x0, …, xn are called knots and the points x1, …, xn – 1 are
called interior knots.
Linear Splines
145
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download Undetermined-Coefficients-and-Splines and more Lecture notes Mathematical Analysis in PDF only on Docsity!

Splines

Spline interpolation is a different interpolation method in which a

piecewise polynomial function fits the given points known as the spline.

A spline is a composite function composed of n low-degree

polynomials each of which fits in the interval between x i – 1

and x i

, (i = 1,

…, n).

The term spline was coined after a draftsman's device of drawing

a smooth curve through given points using a thin flexible strip (called a

spline ). Knots are the points where two connecting splines meet. Since

the connecting polynomials can be of any degree, there are various

types of splines: linear, quadratic, cubic, quartic, quintic, among

others.

Linear Splines

It has two parameters. Given (x 0

, y 0

), (x 1

, y 1

), …, (x n – 1

, y n – 1

), (x n

, y n

fit linear splines (refer to the figure) to the data. This is as simple as

forming the consecutive data with straight lines.

The linear splines are given by

f ( x )= f

x

0

f

x

1

− f

x

0

x

1

− x

0

x − x

0

, x

0

≤ x ≤ x

1

¿ f

x

1

f

x

2

− f

x

1

x

2

− x

1

x − x

1

, x

1

≤ x ≤ x

2

Module III Solving Linear and NonLinear Equations

Note:

A spline function of degree k exists if there are points a = x

0

< x

1

< … < x

n

= b

such that s is a polynomial of degree at most k on each of the intervals [x

j – 1

; x

j

] for j

= 1, …, n and s has continuous k – 1 derivatives. To put it another way, s Є C

k – 1

[a,

b]. For k = 1, 2, 3, or 4, we call spline a linear, quadratic, cubic, or quartic spline,

respectively. The numbers x

0

, …, x

n

are called knots and the points x

1

, …, x

n – 1

are

called interior knots.

Linear Splines

¿ f

x

n − 1

f

x

n

− f

x

n − 1

x

n

− x

n − 1

x − x

n − 1

, x

n − 1

≤ x ≤ x

n

Example:

A robot arm equipped with a rapid laser scanner inspects the

quality of holes drilled in a 15" x 10" rectangular plate. The centers of

the holes in the plate describe the path the arm must take, and the

center of the holes are located on a Cartesian coordinate system (with

the origin at the bottom left corner of the plate) specified in Table 1.

Table 1. The coordinates of the holes on the plate.

x (in.) 2.00 4.25 5.25 7.81 9.20 10.

y (in.) 7.20 7.10 6.00 5.00 3.50 5.

a. What is the value of y at x 4.00 using linear splines if the laser

travels in a straight line from x = 2.00 to x = 4.25?

b. Determine the robot's path if it follows linear splines.

c. Determine the length of the path taken by the robot while

following linear splines.

Solution:

a. Since we want to find the value of y at x = 4.00 , we must select

the two data points closest to x = 4.00 that also bracket x = 4.

in order to evaluate it. The two numbers are x 0

= 2.00 and x 1

Then

x 0

= 2.00 , y( x 0

x 1

= 4.25, y( x 1

gives

y ( x )= y

x

0

y

x

1

− y

x

0

x

1

− x

0

x − x

0

( x −2.00 )

Thus

y ( x )=7.20+(−0.044444)( x −2.00) ,

2.00 ≤ x ≤ 4.

At x = 4.

y ( 4.00) =7.20+(−0.044444 ) ( 4.00−2.00 )=7.111112∈.

Module III Solving Linear and NonLinear Equations

Note:

The terms of in the above functions are simply slopes between , , where m denotes

the slope of the lines.

It consists of three parameters. A quadratic spline interpolation

method fits a continuous function better than a linear spline.

A quadratic polynomial approximates the data between two

consecutive data points in these splines. Given (x 0

, y 0

), (x 1

, y 1

), …, (x n – 1

y n – 1

), (x n

, y n

), fit quadratic splines (refer to the figure) to the data.

A Quadratic Spline is the creation of a set of quadratic polynomial

functions, which follow the format

f

x

= a x

2

  • b x + c

where a, b, and c are the values obtained while performing the

splines to create the desired functions.

The splines are given by

f

x

= a

1

x

2

  • b

1

x + c

1

, x

0

≤ x ≤ x

1

¿ a

2

x

2

  • b

2

x + c

2

, x

1

≤ x ≤ x

2

¿ a

n

x

2

  • b

n

x + c

n

, x

n − 1

≤ x ≤ x

n

So, how does one go about determining the coefficients of these

quadratic splines? There are 3n of these coefficients such as

a i

, i = 1, 2, 3, …, n

b

i

, i = 1, 2, 3, …, n

c i

, i = 1, 2, 3, …, n

To find 3n unknowns, one must first create 3n equations and then

solve them all at the same time. These 3n equations can be found by

doing the following.

  1. Each quadratic spline traverses two consecutive data points.

Module III Solving Linear and NonLinear Equations

Quadratic Splines

… …

(x

n

, y

n

)

a

n

x

2

+b

n

x + c

n

(x

n–

, y

n–

)

(x

0

, y

0

)

(x

1

, y

1

)

(x

2

, y

2

)

(x

3

, y

3

)

a

1

x

0

2

  • b

1

x

0

  • c

1

= f ( x

0

a

1

x

1

2

  • b

1

x

1

  • c

1

= f ( x

1

a

i

x

i − 1

2

  • b

i

x

i − 1

  • c

i

= f ( x

i − 1

a

i

x

i

2

  • b

i

x

i

  • c

i

= f ( x

i

a

n

x

n − 1

2

  • b

n

x

n − 1

  • c

n

= f ( x

n − 1

a

n

x

n

2

  • b

n

x

n

  • c

n

= f ( x

n

Because there are n quadratic splines passing through two

consecutive data points, this condition yields 2n equations.

  1. The first derivatives of two quadratic splines are continuous at the

interior points. For instance, consider the derivative of the first

spline

a

1

x

2

  • b

1

x + c

1

is

2 a

1

x + b

1

The derivative of the second spline

a

2

x

2

  • b

2

x + c

2

is

2 a

2

x + b

2

and the two are equal at x = x 1

giving

2 a

1

x

1

  • b

1

= 2 a

2

x

1

  • b

2

2 a

1

x

1

  • b

1

− 2 a

2

x

1

− b

2

Similarly at the other interior parts,

2 a

2

x

2

  • b

2

− 2 a

3

x

2

− b

3

2 a

i

x

i

  • b

i

− 2 a

i + 1

x

i

− b

i + 1

2 a

n − i

x

n − i

  • b

n − i

− 2 a

n

x

n − i

− b

n

Since there are (n – 1) interior points, we have (n – 1) such

equations. The total number of equations so far is (2n) + (n – 1) = (3n –

1) equations. Then we will need one more equation.

We can assume the first spline is linear, that is

a

1

This yields us 3n equations and 3n unknowns. A variety of

techniques for solving simultaneous linear equations can be used to

solve these.

Example:

A robot arm equipped with a rapid laser scanner inspects the

quality of holes drilled in a 15" x 10" rectangular plate. The centers of

the holes in the plate describe the path the arm must take, and the

Module III Solving Linear and NonLinear Equations

  1. At the interior data points of quadratic splines, the derivatives

are continuous.

At x = 4.

2 a

1

x

1

  • b

1

− 2 a

2

x

1

− b

2

2 a

1

(4.25)+ b

1

− 2 a

2

( 4.25)− b

2

[11]

At x = 5.

2 a

2

x

2

  • b

2

− 2 a

3

x

2

− b

3

2 a

2

(5.25)+ b

2

− 2 a

3

(5.25)− b

3

= 0 [12]

At x = 7.

2 a

3

x

3

  • b

3

− 2 a

4

x

3

− b

4

2 a

3

(7.81)+ b

3

− 2 a

4

(7.81)− b

4

[13]

At x = 9.

2 a

4

x

4

  • b

4

− 2 a

5

x

4

− b

5

2 a

4

(9.20)+ b

4

− 2 a

5

(9.20)− b

5

[14]

  1. Assuming the first spline a

1

x

2

  • b

1

x + c

1

is linear,

a

1

[15]

With the desired number of equations, we construct a matrix using

the a i

and b i

multipliers as follows:

To calculate the Matrix size, use the formula (n – 1)*3 where n is the

number of knots. In our case, we n=6, thus, (6 – 1)*3 = 15.

Eq. 1

a

1

2

  • b

1

  • c

1

4 a

1

  • 2 b

1

  • c

1

Eq. 2 a

1

2

  • b

1

( 4.25) + c

1

18.0625 a

1

+4.25 b

1

  • c

1

Eq. 3

a

2

2

  • b

2

  • c

2

18.0625 a

2

  • 4.25 b

2

  • c

2

Eq. 4

a

2

2

  • b

2

  • c

2

27.5625 a

2

+5.25 b

2

  • c

2

Eq. 5 a

3

2

  • b

3

( 5.25) + c

3

27.5625 a

3

+5.25 b

3

  • c

3

Eq. 6

a

3

2

  • b

3

  • c

3

a

3

+7.81 b

3

  • c

3

Eq. 7

a

4

2

  • b

4

  • c

4

60.9961 a

4

+7.81 b

4

  • c

4

Eq. 8 a

4

2

  • b

4

  • c

4

84.64 a

4

+9.20 b

4

  • c

4

Eq. 9

a

5

2

  • b

5

  • c

5

84.64 a

5

  • 9.20 b

5

  • c

5

Eq.

10

a

5

2

  • b

5

  • c

5

112.36 a

5

+10.60 b

5

  • c

5

Eq.

11

2 a

1

(4.25)+ b

1

− 2 a

2

( 4.25)− b

2

8.5 a

1

  • b

1

−8.5 a

2

− b

2

Eq. 2 a

2

(5.25)+ b

2

− 2 a

3

(5.25)− b

3

= 0 10.5 a

2

  • b

2

−10.5 a

3

− b

3

Module III Solving Linear and NonLinear Equations

12

Eq.13 2 a

3

(7.81)+ b

3

− 2 a

4

(7.81)− b

4

15.62 a

3

  • b

3

−15.62 a

4

− b

4

Eq.

14

2 a

4

(9.20)+ b

4

− 2 a

5

(9.20)− b

5

18.4 a

4

  • b

4

−18.4 a

5

− b

5

Eq.

15

a

1

= 0 a

1

Plotting the numerical coefficients of the 15 equations, we have

[

]

[

a

1

b

1

c

1

a

2

b

2

c

2

a

3

b

3

c

3

a

4

b

4

c

4

a

5

b

5

c

5

]

[

]

The 15 unknowns are determined by solving the above 15 equations.

i = 1

We obtain

b

1

∧ c

1

for using eq. 1 and 2

4 a

1

  • 2 b

1

  • c

1

18.0625 a

1

+4.25 b

1

  • c

1

Since

a

1

, we have

2 b

1

  • c

1

4.25 b

1

  • c

1

Same process in Gaussian Elimination , we determine the proper

coefficient to eliminate one term from the equation. In our case,

we eliminate

c

1

by multiplying (-1) to eq. 1 and add to eq. 2

Module III Solving Linear and NonLinear Equations

We eliminate

c

2

by multiplying (-1) to eq. 3 and add to eq. 4

(18.0625 a ¿

¿ 2 + 4.25 b

2

  • c

2

¿−18.0625 a

2

−4.25 b

2

− c

2

−18.0625 a

2

−4.25 b

2

− c

2

+27.5625 a

2

+5.25 b

2

  • c

2

9.5 a

2

  • b

2

9.5 a

2

  • b

2

We eliminate

b

2

by multiplying (1) to

−8.5 a

2

− b

2

and add

to

9.5 a

2

  • b

2

, then obtain

a

2

−8.5 a

2

− b

2

¿−8.5 a

2

− b

2

−8.5 a

2

− b

2

+9.5 a

2

  • b

2

a

2

a

2

To obtain

b

1

we use

−8.5 a

2

− b

2

−8.5 a

2

− b

2

=0.044444 where a

2

¿−8.5 (−1.055556)− b

2

¿ 8.972226− b

2

¿− b

2

¿− b

2

¿ b

2

or

use

9.5 a

2

  • b

2

9.5 a

2

  • b

2

=−1.1 0 where a

2

¿ 9.5(−1.055556)+ b

2

¿−10.027782+ b

2

¿ b

2

¿ b

2

Solve for

c

2

, we obtain

Using eq. 3

18.0625 a

2

+4.25 b

2

  • c

2

18.0625 (−1.055556) +4.25 (8.927782)+ c

2

−19.065980+37.943073+ c

2

c

2

Using eq. 4

27.5625 a

2

+5.25 b

2

  • c

2

Module III Solving Linear and NonLinear Equations

27.5625 (−1.055556) +5.25(8.927782)+ c

2

−29.093762+46.870855+ c

2

c

2

i = 3

We obtain

a

3

, b

3

, ∧ c

3

for Using eq. 5, 6, and 12

27.5625 a

3

+5.25 b

3

  • c

3

a

3

+7.81 b

3

  • c

3

10.5 a

2

  • b

2

−10.5 a

3

− b

3

We begin by simplifying equation 12 before eliminating terms.

10.5 a

2

  • b

2

−10.5 a

3

− b

3

where a

2

=−1.055556∧ b

2

10.5(−1.055556)+(8.927782)−8.5 a

2

− b

2

−11.083338+8.927782−10.5 a

3

− b

3

−10.5 a

3

− b

3

We eliminate

c

3

by multiplying (-1) to eq. 5 and add to eq. 6

(27.5625 a

3

+5.25 b

3

  • c

3

¿− 27_._ 5625 a

3

− 5 .25 b

3

− c

3

− 27_._ 5625 a

3

− 5 .25 b

3

− c

3

a

3

+7.81 b

3

  • c

3

33.4336 a

2

+2.56 b

3

33.4336 a

3

+2.56 b

3

We eliminate

b

3

by multiplying (2.56)

to

−10.5 a

3

− b

3

and add to

33.4336 a

3

+2.56 b

3

then obtain

a

3

−10.5 a

3

− b

3

−26.88 a

3

−2.56 b

3

−26.88 a

3

−2.56 b

3

+33.4336 a

3

+2.56 b

3

¿ 6.5536 a

3

¿ 6.5536 a

3

¿ a

3

Module III Solving Linear and NonLinear Equations

i a i

b i

c i

Therefore, the splines are given by

y

x

= a

1

x

2

  • b

1

x + c

1

, 2.00 ≤ x ≤ 4.

¿ a

2

x

2

  • b

2

x + c

2

, 4.25 ≤ x ≤ 5.

¿ a

3

x

2

  • b

3

x + c

3

, 5.25 ≤ x ≤ 7.

¿ a

4

x

2

  • b

4

x + c

4

, 7.81 ≤ x ≤ 9.

¿ a

5

x

2

  • b

5

x + c

5

, 9.20 ≤ x ≤ 10.

y ( x )=−0.044444 x +7.2889 , 2.00 ≤ x ≤ 4.

¿− 1 .055556 x

2

  • 8.927782 x −11.777093 , 4.25 ≤ x ≤ 5.

¿ 0.689426 x

2

−9.394529 x + 36.31897 , 5.25 ≤ x ≤ 7.

¿−1.765066 x

2

+28.944636 x −113.395465 , 7.81 ≤ x ≤ 9.

¿ 3.288576 x

2

−64.042376 x +314.344787 , 9.20 ≤ x ≤ 10.

What is the value of y at x = 4.00 using quadratic splines?

Since x = 4.00 , we use the spline

y ( x )=−0.044444 x +7.2889 ,

y ( 4.00) =−0.044444 x +7.

Module III Solving Linear and NonLinear Equations

A. Fit the following data

x 3.0 4.5 7.0 9.

f(x) 2.5 1.0 2.5 0.

and approximate the value at x = 5 applying the following

polynomial interpolation methods:

  1. Lagrange Interpolation,
  2. Divided Differences, and
  3. Splines

Think...