0% found this document useful (0 votes)
18 views26 pages

Numerical Methods Midterms

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

Numerical Methods Midterms

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

AKLAN STATE UNIVERSITY

College of Engineering & Architecture


Kalibo, Aklan

COVER PAGE

PREFACE

Page 1 of 26
AKLAN STATE UNIVERSITY
College of Engineering & Architecture
Kalibo, Aklan

TABLE OF CONTENTS

Page 2 of 26
AKLAN STATE UNIVERSITY
College of Engineering & Architecture
Kalibo, Aklan

INTRODUCTION
Numerical method has found its value to the practice of engineering way back 1940 when digital
computers were available commercially. Its early development was however slowed down because of the
expensive nature of powerful computers then. Today, with the advent of cheap, powerful and portable
computers, you will be able to utilize the full potentials of this method. There are several other reasons why
you should study numerical methods:
1. Numerical methods are extremely powerful problem-solving tools. They are capable of
handling large systems of equations, nonlinearities, and complicated geometries that are
uncommon in engineering practice and that are often impossible to solve analytically. As such,
they greatly enhance your problem-solving skills.

Page 3 of 26
AKLAN STATE UNIVERSITY
College of Engineering & Architecture
Kalibo, Aklan

2. During your careers, you may often encounter commercially available prepackaged computer
programs that involve numerical methods. The intelligent use of these programs is often
predicated on knowledge of the basic theory underlying the methods.
3. Many problems cannot be approached using prepackaged programs. If you are knowledgeable
with numerical methods and are adept at computer programming, you can design your own
programs to solve problems without having to buy or commission expensive software.
4. Numerical methods are efficient vehicle for learning to use computers. It is well-known that an
effective way to learn programming is to actually write computer programs.
5. Numerical methods will also help you understand mathematics better because thry tend to
reduce complex operations down to basic manipulations.

WEEK No. 2 No. OF HOURS 3


TITLE Roots of Nonlinear Equations Using Bisection and False-Position Methods

INTENDED LEARNING OUTCOMES:


At the end of the topic, you must be able to:
1. Use incremental search method in determining initial guesses.
2. Apply bisection method in determining a root of the equation.
3. Apply false-position method in determining a root of the equation.
4. Compute for the approximate error associated with the computed value of the root.

I. ROOTS OF NONLINEAR EQUATIONS

Page 4 of 26
AKLAN STATE UNIVERSITY
College of Engineering & Architecture
Kalibo, Aklan

INCREMENTAL SEARCH METHOD – one of the two options (the other being the plot of the function) in
determining the two initial guesses bracketing a root. This consists
of starting at one end of the region of interest and then making
function evaluations at small increments across the region. When
the function changes sign, it is assumed that a root falls within the
increment.
BRACKETING METHODS
Methods used to determine root or roots of nonlinear equations.
1. Bisection Method
2. Regula Falsi and Secant Methods
3. Etc.
1. BISECTION METHOD
Alternatively called binary chopping, interval halving, or Bolzano’s method is one of the bracketing
methods of finding a root in which the interval is always divided in half.
 The location of the root is then determined as lying at the midpoint of the
subinterval within which the sign change occurs. The process is repeated to obtain
refined estimates.
 FORMULA:
xU+ x L
x n=
2

WHERE:
x n=nth approximation of a root
x U =upper ( higher ) value of theinitial guesses
x L =lower ( smaller ) value of the initial guesses
 FORMULA: APPROXIMATE ERROR

|x n+1−x n|
ε a= (100 % )
x n +1

 SHORTCOMING
No account is taken of the magnitudes of the function at both xL and xU.

EXAMPLE:
1. Solve for t, with an approximate error of 0.1% in the equation 21t2 + 25t = 56.

GIVEN:
21t2 + 25t = 56
UNKNOWN:
t
SOLUTION:
Using Bisection Method, look for the initial guesses using Incremental Search Method.
Although a manual calculation is possible, the use of computer software is highly advised.
The equation must however be written in standard form to solve for its roots. That is:
f(t) = 0

21t2 + 25t = 56
21t2 + 25t – 56 = 0, therefore
f(t) = 21t2 + 25t – 56 = 0

Page 5 of 26
AKLAN STATE UNIVERSITY
College of Engineering & Architecture
Kalibo, Aklan

THESE WILL COMPOSE tL AND tU.

OBSERVE A CHANGE IN SIGN OF THE


VALUE OF THE FUNCTION.

For the formula:


t U +t L
t 0=
2
1+ 1.2
t 0=
2
¿ 1.1 the initial approximate value of t
For the first approximation:
t U +t L
t 1=
2
The next value of tU and tL will be done this way:

*The next tL is 1.1 and the next tU is 1.2 because the value of the
function has different signs.
1.1+1.2
t 1=
2
¿ 1.15

Computing for the approximate error:


|1.15−1.1|
ε a= ( 100 % )
1.15
¿ 4.348 %

For the second approximation:


t U +t L
t 2=
2

Page 6 of 26
AKLAN STATE UNIVERSITY
College of Engineering & Architecture
Kalibo, Aklan

The next value of tU and tL will be done this way:

*The next tL is 1.1 and the next tU is 1.15 because the value of the
function has different signs.
1.1+1.15
t 1=
2
¿ 1.125
Computing for the approximate error:
|1.125−1.15|
ε a= ( 100 % )
1.125
¿ 2.222 %

These process is repeated until accuracy requirement or requirements are met. The computation results
may be facilitated using Excel. (Please subscribe to Engr. Boysie T. Tejada Youtube channel through this
link: https://www.youtube.com/channel/UCXFNGTBFuaktEq0bJJjXK6g)

For the answer:

Page 7 of 26
AKLAN STATE UNIVERSITY
College of Engineering & Architecture
Kalibo, Aklan

The answer is 1.14296875 with


an approximate error of 0.06835%.

2. Determine the real roots of f(x) = 5x3 – 5x2 + 6x – 2 using bisection method with an
approximate error of not more than 0.1%
GIVEN:
5x3 – 5x2 + 6x – 2 = 0
UNKNOWN:
x with ε a< 0.1 %
SOLUTION:

ANSWER:
x = 0.4183594
*If it is asked to determine the root correct up to three decimal places,
then the answer will be x = 0.418.

2. FALSE-POSITION METHOD

Exploits the graphical insight that the value of the functions must be taken consideration. It is
facilitated by joining f(xL) and f(xU) using a straight line. The intersection of this line, a secant line
with the x-axis represents an improved estimate of the root.
This method is also known as linear interpolation method, secant method, or regula falsi (Latin
for false position).

Since the two shaded triangles are similar:

Page 8 of 26
AKLAN STATE UNIVERSITY
College of Engineering & Architecture
Kalibo, Aklan

f ( xU ) −f ( x L )
=
xU −x n x n−x L

Which can be simplified as:


f ( x U ) ( x L −x U )
x n=x U −
f ( x L )−f ( xU )

EXAMPLE:
1. Solve for x, in radians if sin x = x3.

GIVEN:
sin x = x3
UNKNOWN:
x
SOLUTION:
x3 – sin x = 0
For the initial iteration:
f ( x U ) ( x L −x U )
x 0=x U −
f ( x L )−f ( xU )
From the incremental search:
xU = 0.95
xL = 0.9
f(xU) = 0.953 – sin 0.95
= 0.04396
f(xL) = 0.93 – sin 0.9
= -0.05433
0.04396 ( 0.9−0.95 )
x 0=0.95−
−0.05433−0.04396
= 0.92764
f(xo) = 0.927643 – sin 0.92764
= -1.958 x 10-3

To analyze the next values of xL and xU…

For the first iteration:


f ( x U ) ( x L −x U )
x 1=x U −
f ( x L ) −f ( x U )

xL = 0.92764 f(xL) = -1.958 x 10-3

Page 9 of 26
AKLAN STATE UNIVERSITY
College of Engineering & Architecture
Kalibo, Aklan

xU = 0.95 f(xU) = 0.04396

0.04396 ( 0.92764−0.95 )
x 1=0.95− −3
−1.958 x 10 −0.04396
= 0.92859

The value of x is 0.92863 correct up to 5 decimal places.

ASSIGNMENT No. 1:
1. Determine the real root(s) of f(x) = -25 + 82x – 90x2 + 44x3 – 8x4 + 0.7x5, correct up to 4
decimal places.
2. Solve for the values of x if 18x2 – 2.75x3 = 3(4 + 7x).
0.8−0.3 x
3. Determine the real root of ( x )= , after 6 iterations.
x
4. Find the smallest positive root of the function x 2|cos √ x|=5, where x is in radians, until the
approximate error is less than 1%.

Page 10 of 26
AKLAN STATE UNIVERSITY
College of Engineering & Architecture
Kalibo, Aklan

WEEK No. 3 No. OF HOURS 3


TITLE Roots of Nonlinear Equations Using Newton-Raphson Method

INTENDED LEARNING OUTCOMES:


At the end of the topic, you must be able to:
1. Use Newton-Raphson method to solve for a root of a nonlinear function.

OPEN METHODS
Methods used to determine root or roots of nonlinear equations.
1. Simple Fixed-Point Iteration
2. Newton-Raphson Method
3. Etc

3. NEWTON-RAPHSON METHOD
Perhaps the most widely used of all root-locating formulas. A tangent line is extended from a
tangent line until it crosses the x-axis. The intersection with the x-axis represents an improved
estimate of the root.
 FORMULA:
f (x )
x n+1=x n −
f ' (x )

 SHORTCOMING:
There are situations where it performs poorly because convergence is
very slow.
EXAMPLE:
3. Determine the positive root of f(z) = z10 – 2.
GIVEN:
f(z) = z10 – 2
UNKNOWN:
z
SOLUTION:
z10 – 2 = 0
The selection of the starting point is arbitrary. In this, example, let the initial guess, z-1 be
0.1.
For the initial value:
f ( z−1)
z 0=z−1−
f ' (z−1)
' 9
f ( z )=10 z
10
0.1 −2
z 0=0.1−
10 ( 0.1 9 )
¿ 200 000 000.1
For the first iteration:
f (z 0)
z 1=z 0−
f ' (z 0)
10
200000000.1 −2
¿ 200000000.1−
10 ( 200000000.19 )
¿ 180 000 000.1

Page 11 of 26
AKLAN STATE UNIVERSITY
College of Engineering & Architecture
Kalibo, Aklan

After 186 iterations, the value of z is 1.071773 correct up to 6 decimal places.

However, if the initial guess was close to the actual value, say 1, then convergence is going to be
faster.

The same answer was obtained after only the fourth iteration.

4. Use Newton-Raphson method to locate the root of f ( x )=2sin √ x−x


GIVEN:
f ( x )=2sin √ x−x
UNKNOWN:
x
SOLUTION:
f ' ( x )=2cos √ x
( ) 1
2 √x
−1

cos √ x
f ' ( x )= −1
√x
Let x-1 = 1…

Page 12 of 26
AKLAN STATE UNIVERSITY
College of Engineering & Architecture
Kalibo, Aklan

For the initial computation…


f ( x −1)
x 0=x−1−
f ' ( x −1)
2 sin √1−1
¿ 1−
cos √ 1
−1
√1
¿ 2.4856

After the 4th iteration, the root is equal to 1.972381

ASSIGNMENT No. 2:
1. Estimate the root of f(x) = e-x – x.
2. Determine the roots of f(t) = t3 – 5t2 + 7t – 3.

WEEK No. 4 No. OF HOURS 3


TITLE Newton’s Interpolating Polynomial

Page 13 of 26
AKLAN STATE UNIVERSITY
College of Engineering & Architecture
Kalibo, Aklan

INTENDED LEARNING OUTCOMES:


At the end of the topic, you must be able to:
1. Estimate intermediate data points using linear and quadratic interpolation.
2. Fit a first- and a second-order Newton’s interpolating polynomial to a set of data points.

II. POLYNOMIAL INTERPOLATION


The most common method used to estimate intermediate values between precise data points.
-consists of determining the unique nth-order polynomial that fits n + 1 data points.

ALTERNATIVES
1. Newton’s Interpolating Polynomials
2. Lagrange’s Interpolating Polynomials

1. NEWTON’S INTERPOLATING POLYNOMIAL

A. LINEAR INTERPOLATION
-simplest form of interpolation
-connect two data points with a straight line

Let fi(x) be the interpolating line

Since there are two similar triangles, then…

f ( x 1 )−f ( x 0 ) f i ( x )−f ( x 0 )
=
x 1−x 0 x−x 0

Solve for the interpolating polynomial


[ f i ( x )−f ( x 0 ) ] ( x 1−x 0 )=[ f ( x 1) −f ( x 0 ) ] ( x−x 0 )
f ( x 1) −f ( x 0 )
f i ( x )=f ( x 0 ) + ( x−x 0 )
x 1−x 0
LINEAR INTERPOLATION FORMULA

EXAMPLE:

Page 14 of 26
AKLAN STATE UNIVERSITY
College of Engineering & Architecture
Kalibo, Aklan

Estimate the natural logarithm of 2 using linear interpolation, given that ln 1 = 0 and ln 6 =
1.791759. Repeat the procedure by using a smaller interval from ln 1 to ln 4 = 1.386294. Note
that the true value of ln 2 is 0.6931472.
GIVEN:
Let the function be f(x) = ln x
FIRST CONDITION:
x0 = 1
f(x0) = 0
x1 = 6
f(x1) = 1.791759
SECOND CONDITION:
x0 = 1
f(x0) = 0
x2 = 4
f(x2) = 1.386294
ln 2 = 0.6931472
UNKNOWN:
f(x) if x = 2
SOLUTION:
FIRST CONDITION:
f ( x 1 ) −f ( x 0 )
f ( x )=ln 2=¿ f ( x 0 ) + ( x −x0 ) ¿
x1 −x 0
1.791759−0
¿ 0+ ( 2−1 )
6−1
¿ 0.3583518
The percent error is…
%ERROR= | 0.3583518−0.6931472
|
0.6931472
(100)
¿ 48.3
SECOND CONDITION:
f ( x 2 ) −f ( x 0 )
f ( x )=ln 2=¿ f ( x 0 ) + ( x −x 0) ¿
x2 −x 0
1.386294−0
¿ 0+ (2−1 )
4−1
¿ 0.462098
The percent error is…
%ERROR= | |
0.462098−0.6931472
0.6931472
( 100)
¿ 33.333

The large errors in either condition were brought about by the fact that a straight line is used to
estimate the curve. The error can however be minimized if the difference between the two data
points is made smaller.

B. QUADRATIC INTERPOLATION
-three data are available
-the interpolating polynomial is a quadratic polynomial or a parabola

f i ( x )=b0 +b1 ( x−x 0 ) +b 2 ( x−x 0 ) ( x−x 1 )


2
¿ b 0+ b1 x −b1 x 0 +b 2 x +b2 x 0 x 1−b 2 x x0 −b2 x x 1
2
f i ( x )=a0 +a1 x+ a2 x

Page 15 of 26
AKLAN STATE UNIVERSITY
College of Engineering & Architecture
Kalibo, Aklan

Where:
a 0=b 0−b1 x 0+ b2 x0 x 1
a 1=b1−b2 x 0 −b2 x 1
a 2=b2

For the coefficients b0, b1, and b2:


b 0=f ( x 0 )
f ( x 1) −f ( x 0 )
b 1=
x 1−x 0
f ( x 2 )−f ( x 1 ) f ( x 1) −f ( x 0 )

x2− x1 x 1−x 0
b 2=
x 2−x 0

EXAMPLE:
5. Fit a second-order polynomial to the three points used in Example 6 and then evaluate ln 2.
GIVEN:
Let the function be f(x) = ln x
Rearranging the values of x…
x0 = 1
f(x0) = 0
x1 = 4
f(x1) = 1.386294
x2 = 6
f(x2) = 1.791759
UNKNOWN:
f(x) if x = 2
SOLUTION:
f ( x )=b0 +b 1 ( x−x 0 ) +b 2 ( x−x 0 ) ( x−x 1 )

b 0=f ( x 0 )
b 0=0
f ( x 1) −f ( x 0 )
b 1=
x 1−x 0
1.386294−0
b 1=
4−1
b 1=0.462098
f ( x 2 )−f ( x 1 ) f ( x 1) −f ( x 0 )

x2− x1 x 1−x 0
b 2=
x 2−x 0
f ( x 2 )−f ( x 1 )
−b1
x2− x1
b 2=
x 2−x 0

1.791759−1.386294
−0.462098
6−4
b 2=
6−1
b 2=−0.0518731

f ( x )=0+0.462098 ( x−1 )−0.0518731 ( x−1 ) ( x−4 ) ANSWER

Page 16 of 26
AKLAN STATE UNIVERSITY
College of Engineering & Architecture
Kalibo, Aklan

When x = 2
f(2) = 0.462098(2 – 1) – 0.0518731(2 – 1)(2 – 4)
f(2) = ln 2 = 0.5658442 ANSWER

2. GENERAL FORM OF NEWTON’S INTERPOLATING POLYNOMIAL


The interpolating polynomial maybe generalized to fit an nth-order polynomial to n + 1 data points.
The nth-order polynomial will be

f n ( x )=b0 +b 1 ( x−x 0 ) +b 2 ( x−x 0 ) ( x−x 1 ) +…+ bn ( x−x 0 ) ( x−x 1 ) … ( x−x n−1)

Where:
b 0=f ( x 0 )
f ( x1 ) −f ( x 0 )
b 1=f ( x 1 , x 0 ) = … … … … . first finite divided difference
x 1−x 0
f ( x 2 )−f ( x 1 ) f ( x 1) −f ( x 0 )

x 2−x 1 x 1−x 0
b 2=f ( x 2 , x 1 , x 0 ) =
x 2−x 0
………………………….
…………………………
……………………….
b n=f ( x n , xn −1 , x n−2 , … , x1 , x 0 )

f ( x n , x n−1 , … , x 1 )−f ( x n−1 , x n−2 , … , x 0 )


¿
x n−x 0

EXAMPLE:
The following data points are given:
x0 = 1, f(x0) = 0
x1 = 4, f(x1) = 1.386294
x2 = 6, f(x2) = 1.791759
x3 = 5, f(x3) = 1.609438
Write the interpolating polynomial and evaluate f(2).
GIVEN:
x0 = 1, f(x0) = 0
x1 = 4, f(x1) = 1.386294
x2 = 6, f(x2) = 1.791759
x3 = 5, f(x3) = 1.609438

UNKNOWN:
a. fi(x) and
b. f(2)
SOLUTION:
Since given are 4 data points, the interpolating polynomial will be a third-order
polynomial…
f i ( x )=b0 +b1 ( x−x 0 ) +b 2 ( x−x 0 ) ( x−x 1 ) +b 3 ( x−x 0 ) ( x−x 1 ) ( x−x 2 )
Compute for the first divided differences
f ( x 1 )−f ( x0 ) 1.386294−0
f ( x1 , x0)= = =0.462098
x 1−x 0 4−1
f ( x 2) −f ( x 1 ) 1.791759−1.386294
f ( x 2 , x1 ) = = =0.202733
x 2−x 1 6−4

Page 17 of 26
AKLAN STATE UNIVERSITY
College of Engineering & Architecture
Kalibo, Aklan

f ( x 3 )−f ( x2 ) 1.609438−1.791759
f ( x 3 , x2 ) = =
x 3−x 2 5−6
¿ 0.182321
Compute for the second divided differences
f ( x 2 , x 1 )−f ( x 1 , x 0 ) 0.202733−0.462098
f ( x 0 , x 1 , x 2) = =
x 2−x 0 6−1
¿−0.051873
f ( x 3 , x 2 )−f ( x 2 , x 1) 0.182321−0.202733
f ( x 1 , x 2 , x3 ) = =
x 3−x 1 5−4
¿−0.020412
Compute for the third divided difference
f ( x 1 , x 2 , x 3 ) −f ( x 0 , x 1 , x 2 )
f ( x 0 , x 1 , x 2 , x 3 )=
x 3 −x0
−0.020412−(−0.051873)
¿
5−1
¿ 0.007865
Note that…
b 0=f ( x 0 ) =0
b 1=f ( x 0 , x 1 ) =0.462098
b 2=f ( x 0 , x 1 , x 2 ) =−0.051873
b 3=f ( x 0 , x1 , x2 , x3 ) =0.007865
a.
f i ( x )=b0 +b1 ( x−x 0 ) +b 2 ( x−x 0 ) ( x−x 1 ) +b 3 ( x−x 0 ) ( x−x 1 ) ( x−x 2 )
f i ( x )=0.462098 ( x−1 )−0.051873 ( x−1 ) ( x−4 ) +0.007865 ( x−1 ) ( x−4 )( x−6 ) ANS

b.
f ( 2 )=0.462098 ( 2−1 )−0.051873 ( 2−1 ) ( 2−4 ) +0.007865 ( 2−1 )( 2−4 )( 2−6 )
f ( 2 )=0.628764 ANSWER

ASSIGNMENT No. 3:

1. Estimate the common logarithm of 10 using linear interpolation between log 8 = 0.9030900 and
log 12 = 1.0791812. Compute the percent relative error based on the true value which is log 10
= 1.
2. Fit a second-order Newton’s interpolating polynomial to estimate log 10 using the data from
Exercise 7 (above) at x = 8, 9 and 11.
3. Given the data

Calculate f(2.8) using Newton’s interpolating polynomial of order 4. Choose the sequence of
the points for your estimate to attain the best possible accuracy. (ANS: If the first 5 data points
were chosen in the same order, f(2.8) = 15.601)
4. Given the ordered pairs: (-2,-3); (0,1); (1,0); (3,22). Use Newton’s interpolating polynomial to
estimate y in the ordered pair (0.5,y).

WEEK No. 5 No. OF HOURS 3


TITLE Lagrange Interpolating Polynomials and Spline Interpolation

Page 18 of 26
AKLAN STATE UNIVERSITY
College of Engineering & Architecture
Kalibo, Aklan

INTENDED LEARNING OUTCOMES:


At the end of the topic, you must be able to:
1. Estimate an intermediate data point using Lagrange polynomial.
2. Fit linear, quadratic, and cubic splines into a set of data points.
3. Interpolate intermediate data points using spline interpolation.

LAGRANGE INTERPOLATING POLYNOMIALS


-a reformulation of Newton’s interpolating polynomial
-avoids the computation of divided differences
-represented concisely as…
n
f n ( x ) = ∑ Li ( x ) f ( x i )
i =0
Where:
n
x−x j
Li ( x ) = ∏
j=0 x i−x j
j ≠i
Note: ∏ designates the “product of.”

For example:
If n = 1…
x− x1 x−x 0
f 1 ( x )= f ( x0 )+ f ( x1)
x 0−x 1 x 1−x 0
If n = 2…
( x−x 1 ) ( x−x 2 ) ( x−x 0 ) ( x−x 2 )
f 2 ( x )= f ( x0 )+ f ( x1)
( x 0−x 1 ) ( x 0−x 2 ) ( x 1−x 0 ) ( x 1−x 2 )
+ ( x−x 0 ) ( x−x 1 )
f ( x2 )
( x 2−x 0 ) ( x 2−x1 )
EXAMPLE:
Given the function f(x) = ln x. Estimate ln 2 using Lagrange interpolating polynomial given
the following data points:
x0 = 1, f(x0) = 0
x1 = 4, f(x1) = 1.386294
x2 = 6, f(x2) = 1.791760
GIVEN:
x0 = 1, f(x0) = 0
x1 = 4, f(x1) = 1.386294
x2 = 6, f(x2) = 1.791759

UNKNOWN:
f(2)
SOLUTION:
( x−x 1 ) ( x−x 2 ) ( x−x 0 ) ( x−x 2 )
f 2 ( x )= f ( x0 )+ f ( x1)
( x 0−x 1 ) ( x 0−x 2 ) ( x 1−x 0 ) ( x 1−x 2 )
+ ( x−x 0 ) ( x−x 1 )
f ( x2 )
( x 2−x 0 ) ( x 2−x1 )
( 2−4 ) ( 2−6 ) ( 2−1 ) ( 2−6 )
f ( 2 )= ( 0) + ( 1.386294 )
(1−4 ) (1−6 ) ( 4−1 ) ( 4−6 )

Page 19 of 26
AKLAN STATE UNIVERSITY
College of Engineering & Architecture
Kalibo, Aklan

+ ( 2−1 ) ( 2−4 )
(1.791759 )
( 6−1 ) ( 6−4 )
f ( 2 )=0.565844 ANSWER

SPLINE INTERPOLATION
-an alternative approach to Newton’s and Lagrange interpolating polynomials
-apply lower-order polynomials to subsets of data points, or the so called spline functions

a. LINEAR SPLINES
-the simplest type of spline
-uses straight lines
f ( x )=f ( x 0 ) +m0 ( x−x 0 ) x0 ≤ x ≤ x1
f ( x )=f ( x 1 ) +m1 ( x−x 1 ) x1 ≤ x ≤ x2
.
.
.
f ( x )=f ( x n−1 ) +mn−1 ( x−x n−1 ) x n−1 ≤ x ≤ x n

Where :
f ( x i+1 ) −f ( x i )
m i= slope of the line connecting two points
x i +1−x i
EXAMPLE:
10. Fit the table with first-order splines and evaluate at x = 5.

x f(x)
3.0 2.5
4.5 1.0
7.0 2.5
9.0 0.5
GIVEN:
x0 = 3.0, f(x0) = 2.5
x1 = 4.5, f(x1) = 1.0
x2 = 7.0, f(x2) = 2.5
x3 = 9.0, f(x3) = 0.5
UNKNOWN:
f(5)
SOLUTION:
a.

b. Since x = 5 is between the interval 4.5 to 7…


f ( x 2 )−f ( x 1)
m 1=
x 2−x 1
2.5−1
¿
7−4.5
¿ 0.6
f ( x )=f ( x 1 ) +m1 ( x−x 1 )

Page 20 of 26
AKLAN STATE UNIVERSITY
College of Engineering & Architecture
Kalibo, Aklan

f ( x )=1+ 0.6 ( x−4.5 )


f ( x )=0.6 x−1.7
f ( 5 )=0.6 ( 5 ) −1.7
f ( 5 )=1.3 ANSWER

b. QUADRATIC SPLINES
-spline interpolation using second-order polynomials
-have continuous first derivatives at the knots
-derive a second-order polynomial for each interval between data points
The representation is generally written as:
2
f 1 ( x )=a1 x +b1 x+ c 1

Note:
For n + 1 data points (I = 0,1, 2, …, n), there are n intervals, and 3n unknowns,
therefore there must be 3n equations.

ILLUSTRATIVE EXAMPLE:
11. Fit the table with quadratic splines and evaluate at x = 5.

x f(x)
3.0 2.5
4.5 1.0
7.0 2.5
9.0 0.5
GIVEN:
x0 = 3.0, f(x0) = 2.5
x1 = 4.5, f(x1) = 1.0
x2 = 7.0, f(x2) = 2.5
x3 = 9.0, f(x3) = 0.5
UNKNOWN:
f(5)
SOLUTION:
A. The function values of adjacent polynomials must be equal at the interior knots.
That is…
2
a i−1 x i−1 +b i−1 x i−1+ ci −1=f ( x i−1) ………………….. EQ1

Page 21 of 26
AKLAN STATE UNIVERSITY
College of Engineering & Architecture
Kalibo, Aklan
2
a i x i−1 + bi x i−1 +c i=f ( x i−1 )…………………………... EQ2

*For i = 2 to n (interior knots only)


*Each provide n – 1 conditions for a total of 2n – 2 conditions.

From the Illustrative Example… number of intervals, n = 4 – 1 = 3; No. of unknowns =


3(3) = 9
For EQ1 and EQ2: No. of equations (conditions) = 2(3) – 2 = 4
For EQ 1:
2
a 2−1 x 2−1 +b 2−1 x 2−1+ c2−1=f ( x 2−1 )
2
a 1 x 1 + b1 x 1 +c 1=f ( x 1 )
2
a 1 ( 4.5 ) + b1 ( 4.5 ) +c 1=1
20.25 a1 + 4.5 b1 +c 1=1 ………………………….eqn1
2
a 3−1 x 3−1 +b 3−1 x 3−1+ c 3−1=f ( x 3−1 )
2
a 2 x 2 + b2 x 2 +c 2=f ( x 2)
49 a2+ 7 b2 +c 2=2.5 ……………………..……….eqn2
For EQ 2:
2
a 2 x 2−1 +b 2 x 2−1+ c 2=f ( x 2−1 )
2
a 2 x 1 + b2 x 1 +c 2=f ( x1 )
2
a 2 ( 4.5 ) + b2 ( 4.5 ) +c 2=1
20.25 a2 + 4.5 b2 +c 2=1 ………………………….eqn3
2
a 3 x 3−1 + b3 x 3−1 +c 3=f ( x 3−1 )
2
a 3 x 2 + b3 x2 +c 3=f ( x 2 )
49 a3 +7 b3 +c 3=2.5 ……………………..….…….eqn4

B. The first and last functions must pass through the end points.
2
a 1 x 0 + b1 x0 + c1=f ( x 0 )…………………………….….. EQ1
2
a n x n +bn x n+ c n=f ( x n )………………………...….….. EQ2

*For 2 more equations.

For EQ 1:
2
a 1 x 0 + b1 x0 + c1=f ( x 0 )
9 a 1+3 b 1+ c 1=2.5 ………………………...……….eqn5
For EQ 2:
2
a 3 x 3 + b3 x3 + c3 =f ( x 3 )
81 a3 +9 b 3+ c 3=0.5 ……………………………….eqn6

C. The first derivatives at the interior knots must be equal.

2 ai−1 xi−1 +b i−1 =2 ai x i−1 +bi

*Number of equations = n - 1
For i = 2:
2 a2−1 x 2−1 +b2−1=2a 2 x 2−1+ b2
2 a1 x1 +b 1=2 a2 x1 +b 2
2 ( 4.5 ) a 1+ b1=2 ( 4.5 ) a 2+ b2
9 a 1+ b1=9 a 2+ b2………………………………………..eqn7

Page 22 of 26
AKLAN STATE UNIVERSITY
College of Engineering & Architecture
Kalibo, Aklan

For i = 3:
2 a3−1 x3−1 +b 3−1=2 a3 x 3−1 +b3
2 a2 x 2+b 2=2 a3 x 2+ b3
2 ( 7 ) a2 +b 2=2 (7 ) a3 +b3
14 a2+ b2=14 a3 +b3 ………………………………………..eqn8
D. Assume that the second derivative is zero at the first point.
a 1=0…………………………………………………..…………..eqn9

The solution will be…


a1 = 0 b1 = -1 c1 = 5.5
a2 = 0.64 b2 = -6.76 c2 = 18.46
a3 = -1.6 b3 = 24.6 c3 = -91.3
The splines will be…
f 1 ( x )=−x +5.5 3.0 ≤ x ≤ 4.5
2
f 2 ( x )=0.64 x −6.76 x+18.46 4.5 ≤ x ≤ 7.0
2
f 3 ( x )=−1.6 x +24.6 x−91.3 7.0 ≤ x ≤ 9.0
It may also be written as…

……a function in three pieces……..


For f(5)…
*located within the second piece so…
2
f ( 5 )=0.64 ( 5 ) −6.76 ( 5 ) +18.46
f ( 5 )=0.66 ANSWER

c. CUBIC SPLINES
-spline interpolation using third-order polynomials
3 2
f i ( x )=ai x +b i x + c i x +d i

*For n + 1 data points (i = 0,1, 2, 3,…)


-there are n intervals
-there are 4n unknowns
*4n conditions to evaluate the unknowns
1. The function values must be equal at the interior knots. (No. of conditions = 2n – 2)
2. The first and last functions must pass through the end points. (No. of conditions = 2)
3. The first derivatives at the interior knots must be equal. (No. of conditions = n – 1)
4. The second derivatives at the interior knots must be equal. (No. of conditions = n – 1)
5. The second derivatives at the end knots are zero. (No. of conditions = 2)

ILLUSTRATIVE EXAMPLE:
12. Fit the table with cubic splines and evaluate at x = 5.

x f(x)
3.0 2.5
4.5 1.0
7.0 2.5
9.0 0.5
GIVEN:
x0 = 3.0, f(x0) = 2.5

Page 23 of 26
AKLAN STATE UNIVERSITY
College of Engineering & Architecture
Kalibo, Aklan

x1 = 4.5, f(x1) = 1.0


x2 = 7.0, f(x2) = 2.5
x3 = 9.0, f(x3) = 0.5
UNKNOWN:
a. f1(x), f2(x), and f3(x)
b. f(5)
SOLUTION:
a.
STEP 1: Employ the equation…

( x i−x i−1 ) f left ({x} rsub {i-1} right ) +2 left ({x} rsub {i+1} - {x} rsub {i-1} right ) f ( x i ) + ( x i+1−x i ) f
6 6
xi +1−x i
[ f ( x i +1) −f ( x i ) ]+
x i−x i−1
[ f ( x i−1 )−f ( x i ) ]
*to determine the second derivatives at the knots
At i = 1 and using x0 = 3, f(x0) = 2.5, x1 = 4.5, f(x1) = 1, x2 = 7, and f(x2) = 2.5:
( x 1−x 1−1 ) f left ({x} rsub {1-1} right ) +2 left ({x} rsub {1+1} - {x} rsub {1-1} right ) f ( x 1 ) + ( x 1+1 −x
6 6
x1 +1−x 1
[ f ( x 1+1 ) −f ( x 1 ) ] +
x 1−x1−1
[ f ( x 1−1 ) −f ( x 1 ) ]

( x 1−x 0 ) f left ({x} rsub {0} right ) +2 left ({x} rsub {2} - {x} rsub {0} right ) f ( x 1 ) + ( x 2−x 1 ) f left ({x
6 6
x2 −x1
[ f ( x 2 )−f ( x1 ) ]+
x 1−x 0
[ f ( x 0 )−f ( x 1 ) ]
( 4.5−3 ) f left ({x} rsub {0} right ) +2 left (7-3 right ) f ( x 1) + ( 7−4.5 ) f left ({x} rsub {2} right )

6 6
( 2.5−1 ) + ( 2.5−1 )
7−4.5 4.5−3
Since f left ({x} rsub {0} right ) =, then…
8 f left ({x} rsub {1} right ) +2.5f ( x 2 ) =9.6 ………………………eqn1
At i = 2 then,
xi-1 = x1 = 4.5 f(x1) = 1
x i = x2 = 7 f(x2) = 2.5
xi+1 = x3 = 9 f(x3) = 0.5
( 2 1)
x −x f left ({x} rsub {1} right ) +2 left ({x} rsub {3} - {x} rsub {1} right ) f ( x 2 ) + ( x 3−x 2 ) f left ({x

6 6
x3 −x2
[ f ( x 3 )−f ( x 2) ] + x −x [ f ( x 1) −f ( x 2 ) ]
2 1

( 7−4.5 ) f left ({x} rsub {1} right ) +2 left (9-4.5 right ) f ( x 2 ) +0=¿

6 6
( 0.5−2.5 ) + ( 1−2.5 )
9−7 7−4.5

2.5 f ( x 1) +9f ( x 2 )=−9.6 ………………..………eqn2

Solving eqn1 and eqn2 simultaneously…


f left ({x} rsub {1} right ) =f ( 4.5 )=1.67909
f left ({x} rsub {2} right ) =f ( 7 )=−1.53308

Page 24 of 26
AKLAN STATE UNIVERSITY
College of Engineering & Architecture
Kalibo, Aklan

STEP 2: Substitute to the equation…

f i left ({x} rsub {i-1} right )} over {6 left ({x} rsub {i} - {x} rsub {i-1} right )} {left ({x} rsub {
f i ( x )=
6 ( x i−x i−1)

[ f ( x i−1 ) f left ({x} rsub {i-1} right ) left ({x} rsub {i} - {x} rsub {i-1} right )} over {6} right ] le
x i−x i−1

For i = 1…

f 1 left ({x} rsub {0} right )} over {6 left ({x} rsub {1} - {x} rsub {0} right )} {left ({x} rsub
f 1 ( x )=
6 ( x 1−x 0 )

[ f ( x 0 ) f left ({x} rsub {0} right ) left ({x} rsub {1} - {x} rsub {0} right )} over {6} right
x 1−x 0

f 1 ( x )=0+
1.67909
6 ( 4.5−3 ) (
( x−3 )3 +
2.5
4.5−3 )
−0 ( 4.5−x )3 +¿

[ 1
4.5−3

1.67909 ( 4.5−3 )
6
( x−3 ) ]
3
f 1 ( x )=0.18657 ( x −3 ) +1.66667 ( 4.5−x )+ 0.24689 ( x −3 ) ANSWER

For i = 2…

f 2 left ({x} rsub {1} right )} over {6 left ({x} rsub {2} - {x} rsub {1} right )} {left ({x} rsub
f 2 ( x )=
6 ( x 2−x 1 )

[ f ( x 1 ) f left ({x} rsub {1} right ) left ({x} rsub {2} - {x} rsub {1} right )} over {6} right
x 2−x 1

1.67909 1.53308
f 2 ( x )= ( 7−x )3− ( x−4.5 )3+ ¿
6 ( 7−4.5 ) 6 ( 7−4.5 )

[ 1
7−4.5

1.67909 ( 7−4.5 )
6 ]
( 7−x ) +¿

[ 2.5
7−4.5
+
1.53308 ( 7−4.5 )
6 ]
( x −4.5 )

3 3
f 2 ( x )=0.11194 (7−x ) −0.10221 ( x−4.5 ) −0.29962 ( 7−x )+1.63878 ( x−4.5 )
ANSWER

For i = 3…

f 3 left ({x} rsub {2} right )} over {6 left ({x} rsub {3} - {x} rsub {2} right )} {left ({x} rsub
f 3 ( x )=
6 ( x 3−x 2 )

Page 25 of 26
AKLAN STATE UNIVERSITY
College of Engineering & Architecture
Kalibo, Aklan

[ f ( x 2 ) f left ({x} rsub {2} right ) left ({x} rsub {3} - {x} rsub {2} right )} over {6} right
x 3−x 2

f 3 ( x )=
−1.53308
6 ( 9−7 )
( 9−x )3 +[ 2.5 1.53308 ( 9−7 )
9−7
+
6 ]
( 9−x ) +¿

0.5
( x−7 )
9−7

3
f 3 ( x )=−0.12776 ( 9−x ) +1.76103 ( 9−x )+ 0.25 ( x−7 ) ANSWER

b. Since x = 5 is between x = 4.5 and x = 7, then evaluate at f2(x).


3 3
f ( 5 )=0.11194 ( 7−5 ) −0.10221 ( 5−4.5 ) −0.29962 ( 7−5 ) +1.63878 ( 5−4.5 )
f ( 5 )=1.10289 ANSWER

ASSIGNMENT No. 4:
1. Given the ordered pairs: (-2,-3); (0,1); (1,0); (3,22). Use Lagrange polynomial to
estimate y in the ordered pair (0.5,y).
2. Given the data

Calculate f(4) using Lagrange polynomial of order 3.

3. Given the following data:

a. Develop linear splines for the first 5 data and predict f(2.2).
b. Develop quadratic splines for the first 5 data and predict f(2.2).
c. Develop cubic splines for the first 3 data and predict f(2.2).

Page 26 of 26

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