Numerical Methods Midterms
Numerical Methods Midterms
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.
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
*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
Page 6 of 26
AKLAN STATE UNIVERSITY
College of Engineering & Architecture
Kalibo, Aklan
*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)
Page 7 of 26
AKLAN STATE UNIVERSITY
College of Engineering & Architecture
Kalibo, Aklan
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).
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
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
Page 9 of 26
AKLAN STATE UNIVERSITY
College of Engineering & Architecture
Kalibo, Aklan
0.04396 ( 0.92764−0.95 )
x 1=0.95− −3
−1.958 x 10 −0.04396
= 0.92859
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
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
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.
cos √ x
f ' ( x )= −1
√x
Let x-1 = 1…
Page 12 of 26
AKLAN STATE UNIVERSITY
College of Engineering & Architecture
Kalibo, Aklan
ASSIGNMENT No. 2:
1. Estimate the root of f(x) = e-x – x.
2. Determine the roots of f(t) = t3 – 5t2 + 7t – 3.
Page 13 of 26
AKLAN STATE UNIVERSITY
College of Engineering & Architecture
Kalibo, Aklan
ALTERNATIVES
1. Newton’s Interpolating Polynomials
2. Lagrange’s Interpolating Polynomials
A. LINEAR INTERPOLATION
-simplest form of interpolation
-connect two data points with a straight line
f ( x 1 )−f ( x 0 ) f i ( x )−f ( x 0 )
=
x 1−x 0 x−x 0
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
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
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
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
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 )
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).
Page 18 of 26
AKLAN STATE UNIVERSITY
College of Engineering & Architecture
Kalibo, Aklan
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.
Page 20 of 26
AKLAN STATE UNIVERSITY
College of Engineering & Architecture
Kalibo, Aklan
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
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 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
*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
c. CUBIC SPLINES
-spline interpolation using third-order polynomials
3 2
f i ( x )=ai x +b i x + c i x +d i
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
( 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
Page 24 of 26
AKLAN STATE UNIVERSITY
College of Engineering & Architecture
Kalibo, Aklan
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
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
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