You are on page 1of 68

Numerical Methods (CIE-301)

Unit-1
(Introductory Material)
Dr. Muhammad Majid Gulzar (CIE-KFUPM)
Contents (Unit-1):
1) Significant Figures (Sec 3.1)

2) Accuracy and Precision (Sec 3.2)

3) Error Definitions (Sec 3.3)

4) Round-off Errors (Sec 3.4)

5) Taylor Series (Sec 4.1, Only 4.1.1 and 4.1.2)

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Significant Figures (Sec 3.1)
Significant Figures:
 It means “interesting or important digits” and not just any digits.

 Significant digit of a number is any given digit of the number


except possibly for 0’s to the left of 1st non zero digit that serves
only to fix the position of decimal point.

𝟑𝟑 and 𝟕𝟕 Significant Figures

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Significant Figures:
 It means “interesting or important digits” and not just any digits.
 3.14159 has six significant digits (All the numbers give you useful
information)
 1000 has one significant digit (only the 1 is interesting; you don't know
anything for sure about the hundreds, tens, or units places; the zeroes may just
be placeholders; they may have rounded something off to get this value)
 1000.0 has five significant digits (The ".0" tells us something interesting about
the presumed accuracy of the measurement being made: that the measurement
is accurate to the tenths place, but that there happen to be zero tenths)
Dr. Muhammad Majid Gulzar (CIE-KFUPM)
Significant Figures:
 It means “interesting or important digits” and not just any digits.
 0.00035 has two significant digits (Only the 3 and 5 tell us something; the
other zeroes are placeholders, only providing information about relative size)
 0.000350 has three significant digits (that last zero tells us that the
measurement was made accurate to that last digit, which just happened to have
a value of zero)
 1006 has four significant digits (the 1 and 6 are interesting, and we have to
count the zeroes, because they're between the two interesting numbers)
Dr. Muhammad Majid Gulzar (CIE-KFUPM)
Significant Figures:
 It means “interesting or important digits” and not just any digits.
 560 has two significant digits (The last zero is just a placeholder)
 560. (Notice the "point" after the zero) has three significant digits (the decimal
point tells us that the measurement was made to the nearest unit, so the zero is
not just a placeholder)
 560.0 has four significant digits (The zero in the tenths place means that the
measurement was made accurate to the tenths place, and that there just happen
to be zero tenths; the 5 and 6 give useful information, and the other zero is
between significant digits, and must therefore also be counted)
Dr. Muhammad Majid Gulzar (CIE-KFUPM)
Significant Figures (Class Activity):
 Round 𝟕𝟕𝟕𝟕𝟕𝟕, 𝟑𝟑𝟑𝟑𝟑𝟑 to four, three, and two significant digits:

 Rounding to Significant Figures:


 742,400 (four significant digits)
 742,000 (three significant digits)
 740,000 (two significant digits)

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Significant Figures (Class Activity):
 Round 𝟎𝟎. 𝟎𝟎𝟎𝟎𝟎𝟎𝟎𝟎𝟎𝟎 to four, three, and two significant digits:

 Rounding to Significant Figures:


 0.07284 (four significant digits)
 0.0728 (three significant digits)
 0.073 (two significant digits)

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Significant Figures (Class Activity):
 Round 𝟐𝟐𝟐𝟐𝟐𝟐. 𝟒𝟒𝟒𝟒 to four, three, and two significant digits:

 Rounding to Significant Figures:


 231.5 (four significant digits)
 231 (three significant digits)
 230 (two significant digits)

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Accuracy and Precision (Sec 3.2)
Accuracy and Precision:
 Two types of solutions/values: True and Approximate / Estimate
 Accuracy is related to closeness to the true value
 Precision is related to the closeness to other estimated values

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Accuracy and Precision:

(a) Inaccurate & Imprecise

(b) Accurate & Imprecise

(c) Inaccurate & Precise

(d) Accurate and Precise

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Error Definitions (Sec 3.3)
Error Definitions:
 Two types of errors: True and Approximate error
 True Error can be computed if the true value is known
 Approximate Error can be computed if the true value is not known

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Error Definitions:
 True Error can be computed if the true value is known

Absolute True Error = 𝐸𝐸𝑡𝑡 = true value − approximate value

true value − approximate value


Absolute True Percent Relative Error = 𝜀𝜀t = × 100
true value

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Error Definitions (Example):
Suppose that you have the task of measuring the lengths of a bridge and a rivet and come up
with 9999 and 9 𝑐𝑐𝑐𝑐, respectively. If the true values are 10000 and 10 𝑐𝑐𝑐𝑐, respectively, for
each case compute

(a) The true error

(b) The true percent relative error

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Error Definitions (Example):
(a) The true error

Absolute True Error = 𝐸𝐸𝑡𝑡 = true value − approximate value

For Bridge, 𝐸𝐸𝑡𝑡 = 10000 − 9999 = 𝟏𝟏 𝒄𝒄𝒄𝒄

For Rivet, 𝐸𝐸𝑡𝑡 = 10 − 9 = 𝟏𝟏 𝒄𝒄𝒄𝒄

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Error Definitions (Example):
(a) The true percent relative error

true value − approximate value


Absolute True Percent Relative Error = 𝜀𝜀t = × 100
true value

10000 − 9999
For Bridge, 𝜀𝜀t = × 100 = 𝟎𝟎. 𝟎𝟎𝟎𝟎 %
10000

10 − 9
For Rivet, 𝜀𝜀t = × 100 = 𝟏𝟏𝟎𝟎 %
10

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Error Definitions (Example):
 Although both measurements have an error of 1 𝑐𝑐𝑐𝑐, the relative error
for the rivet is much greater.

 We would conclude that we have done an adequate job of measuring


the bridge, whereas our estimate for the rivet leaves something to be
desired.

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Error Definitions:
 Approximate Error can be computed if the true value is not known

Approximate Absolute Error = 𝐸𝐸𝑎𝑎 = current approximate − previous approximate

current approximate − previous approximate


Approximate Absolute Percent Relative Error = 𝜀𝜀𝑎𝑎 = × 100
current approximate

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Error Definitions:
 The result is assumed to be within the prespecified acceptable level
(𝜀𝜀𝑠𝑠 ), if the given relationship holds
𝜀𝜀𝑎𝑎 < 𝜀𝜀𝑠𝑠

 It can be assured that the result is correct to at least 𝑛𝑛 significant


figures, if the following criterion is met
𝜀𝜀𝑠𝑠 = 0.5 × 102−𝑛𝑛 %

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Maclaurin Series Expansion:
 In mathematics, functions can often be represented by infinite series.
For example, the exponential function can be computed using

𝑛𝑛
𝑥𝑥 2 𝑥𝑥 3 𝑥𝑥 𝑛𝑛 𝑥𝑥 𝑛𝑛
𝑒𝑒 𝑥𝑥 = 1 + 𝑥𝑥 + + +⋯+ , 𝑒𝑒 𝑥𝑥 ≅ �
2 3! 𝑛𝑛! 𝑛𝑛!
𝑖𝑖=0

 Thus, as more terms are added in sequence, the approximation


becomes a better and better estimate of the true value of 𝑒𝑒 𝑥𝑥 .

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Maclaurin Series Expansion (Example):
Starting with the simplest version, 𝑒𝑒 𝑥𝑥 = 1, add terms one at a time to estimate 𝑒𝑒 0.5 . After
each new term is added, compute the true and approximate percent relative errors. Note that
the true value is 𝑒𝑒 0.5 = 1.648721 . . . . . Add terms until the absolute value of the
approximate error estimate 𝜀𝜀𝑎𝑎 falls below a prespecified error criterion 𝜀𝜀𝑠𝑠 conforming to
three significant figures.

𝑛𝑛
𝑥𝑥 2 𝑥𝑥 3 𝑥𝑥 𝑛𝑛 𝑥𝑥 𝑛𝑛
𝑒𝑒 𝑥𝑥 = 1 + 𝑥𝑥 + + +⋯+ , 𝑒𝑒 𝑥𝑥 ≅ �
2 3! 𝑛𝑛! 𝑛𝑛!
𝑖𝑖=0

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Maclaurin Series Expansion (Example):
𝑛𝑛
𝑥𝑥 2 𝑥𝑥 3 𝑥𝑥 𝑛𝑛 𝑥𝑥 𝑛𝑛
𝑒𝑒 𝑥𝑥 = 1 + 𝑥𝑥 + + +⋯+ , 𝑒𝑒 𝑥𝑥 ≅ �
2 3! 𝑛𝑛! 𝑛𝑛!
𝑖𝑖=0

𝜀𝜀𝑠𝑠 = 0.5 × 102−𝑛𝑛 % = 0.5 × 102−3 % = 𝟎𝟎. 𝟎𝟎𝟎𝟎%


 Thus, we will add terms to the series until 𝜀𝜀𝑎𝑎 falls below this level.
1𝑠𝑠𝑠𝑠 Estimate, 𝑒𝑒 𝑥𝑥 = 𝟏𝟏
2𝑛𝑛𝑛𝑛 Estimate, 𝑒𝑒 𝑥𝑥 = 1 + 𝑥𝑥 = 1 + 0.5 = 𝟏𝟏. 𝟓𝟓

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Maclaurin Series Expansion (Example):
True Value, 𝑒𝑒 0.5 = 𝟏𝟏. 𝟔𝟔𝟔𝟔𝟔𝟔𝟔𝟔𝟔𝟔𝟔𝟔 . . . .
1𝑠𝑠𝑠𝑠 Estimate, 𝑒𝑒 𝑥𝑥 = 𝟏𝟏
2𝑛𝑛𝑛𝑛 Estimate, 𝑒𝑒 𝑥𝑥 = 1 + 𝑥𝑥 = 1 + 0.5 = 𝟏𝟏. 𝟓𝟓

true value −approximate value 1.648721−1.5


𝜀𝜀t = × 100 = × 100 = 𝟗𝟗. 𝟎𝟎𝟎𝟎%
true value 1.648721

current approximate −previous approximate 1.5−1


𝜀𝜀𝑎𝑎 = × 100= × 100 = 𝟑𝟑𝟑𝟑. 𝟑𝟑%
current approximate 1.5

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Maclaurin Series Expansion (Example):

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Round-off Errors (Sec 3.4)
Round-off Errors:
𝝅𝝅: 𝟑𝟑. 𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏 …

 Rounding: replace the number by the nearest machine number


 Round 𝜋𝜋 to 6 significant digits: 3.14159 | 265... Approx to 3.14159
 Round 𝜋𝜋 to 5 significant digits: 3.1415 | 9265... Approx to 3.1416
 Round 𝜋𝜋 to 4 significant digits: 3.141 | 59265... Approx to 3.142

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Round-off Errors:
𝝅𝝅: 𝟑𝟑. 𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏 …

 Chopping: throw all extra digits


 Chop 𝜋𝜋 to 6 significant digits: 3.14159 | 265... Approx to 3.14159
 Chop 𝜋𝜋 to 5 significant digits: 3.1415 | 9265... Approx to 3.1415
 Chop 𝜋𝜋 to 4 significant digits: 3.141 | 59265... Approx to 3.141

 An error introduced by rounding or chopping is always referred to as


round-off error (rounding error) regardless whether we chop or round.
Dr. Muhammad Majid Gulzar (CIE-KFUPM)
Round-off Errors:

True = 1.1681

0 1 2

 Rounding (1.2)
 Chopping (1.1)

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Computer Representation of Numbers:
 Computers retain only a fixed number of significant figures during a
calculation.

 Computers use a base-2 representation, they cannot precisely represent


certain exact base-10 numbers.

 Numbers that can be exactly represented are called machine numbers.

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Computer Representation of Numbers:
 Number System:

 Integer Representation:
 Positive=0
 Negative=1

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Underflow and Overflow:
 Underflow, if in a computation a number outside this range occurs and
it is smaller

 Overflow, if in a computation a number outside this range occurs and


it is larger.

 In case of underflow, the result is usually set to zero and computations


continue. Overflow causes the computer to halt.

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Computer Representation of Numbers:
 In the decimal notation every real number is represented by a finite or
infinite sequence of decimal digits.
 For machine computation, the number must be replaced by number of finitely
many digits.
 Most digital computers have two ways of representing numbers called Fixed
Point & Floating Points.

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Fixed Point Representation:
 Fixed Point, all numbers are given with a fixed number of decimal
places.

 62.358
 1.0000
 0.0713

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Floating Point Representation:
 Floating Points, significant digits kept fixed where as decimal point is
floating as seen from the exponent.
± 0. d1 d 2 d 3 d 4 × 10n
sign mantissa exponent

 0.6238 × 103 = 6.238 × 102


d1 ≠ 0, n : integer
 0.1714 × 10−13 = 1.714 × 10−14

 264.1 × 10−7 = 2.641 × 10−5 ± 0. 1 b2 b3 b4 × 2 n


sign mantissa exponent

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Floating Point Representation (Example):
Create a hypothetical floating-point number set for a machine that stores information using
7-bit words. Employ the first bit for the sign of the number, the next three for the sign and
the magnitude of the exponent, and the last three for the magnitude of the mantissa.

Answer = +𝟎𝟎. 𝟓𝟓 × 𝟐𝟐−𝟑𝟑


Taylor Series (Sec 4.1, Only 4.1.1 and 4.1.2)
Taylor Series:
 Motivation:
3×10−2
 We can easily compute expressions like .
2(𝑥𝑥+4)

 How do we compute 4.1, sin( 0.6)?

 We can use the definition to compute sin( 0.6). Is this a practical way?

A
B
0.6

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Taylor Series:
 Taylor series provides a means to predict a function value at 𝑥𝑥𝑖𝑖+1 in terms of the function value
and its derivatives at 𝑥𝑥𝑖𝑖 .

 In particular, any smooth function can be approximated as a polynomial. The Taylor Series
expansion of 𝑓𝑓 𝑥𝑥 about 𝑥𝑥0 with step size h = 𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 .


1 (𝑘𝑘) 𝑓𝑓 ′′ (𝑥𝑥𝑖𝑖 ) 𝑓𝑓 ′′′ (𝑥𝑥𝑖𝑖 )
𝑒𝑒 𝑥𝑥 𝑘𝑘 ′
= � 𝑓𝑓 (𝑥𝑥0 )(𝑥𝑥 − 𝑥𝑥0 ) = 𝑓𝑓(𝑥𝑥𝑖𝑖 ) + 𝑓𝑓 (𝑥𝑥𝑖𝑖 )(𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 ) + 2
(𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 ) + (𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 )3 +. . .
𝑘𝑘! 2! 3!
𝑘𝑘=0

 Maclaurin Series is a special case of Taylor Series with 𝑥𝑥𝑖𝑖 = 0.

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Taylor Series (Example-1):
Obtain Taylor Series expansion of 𝑓𝑓(𝑥𝑥) = 𝑒𝑒 𝑥𝑥 about 𝑥𝑥 = 0.

𝑓𝑓 𝑥𝑥 = 𝑒𝑒 𝑥𝑥 𝑓𝑓(0) = 1
𝑓𝑓 ′ 𝑥𝑥 = 𝑒𝑒 𝑥𝑥 𝑓𝑓′(0) = 1
𝑓𝑓 ′′ 𝑥𝑥 = 𝑒𝑒 𝑥𝑥 𝑓𝑓 ′′ (0) = 1
𝑓𝑓 𝑘𝑘 𝑥𝑥 = 𝑒𝑒 𝑥𝑥 𝑓𝑓 𝑘𝑘 0 =1 𝑓𝑓𝑓𝑓𝑓𝑓 𝑘𝑘 ≥ 1


1 𝑓𝑓 ′′ (𝑥𝑥 ) 𝑓𝑓 ′′′ (𝑥𝑥 )
𝑖𝑖 𝑖𝑖
𝑒𝑒 𝑥𝑥 = � 𝑓𝑓 (𝑘𝑘) (𝑥𝑥0 )(𝑥𝑥 − 𝑥𝑥0 )𝑘𝑘 = 𝑓𝑓(𝑥𝑥𝑖𝑖 ) + 𝑓𝑓 ′ (𝑥𝑥𝑖𝑖 )(𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 ) + (𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 )2 + (𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 )3 +. . .
𝑘𝑘! 2! 3!
𝑘𝑘=0

1 1 𝑥𝑥𝑘𝑘
𝑒𝑒 𝑥𝑥 = 1 + 1(𝑥𝑥) + (𝑥𝑥)2 + (𝑥𝑥)3 +⋯= ∑∞
𝑘𝑘=0 𝑘𝑘! (The series converges for x < ∞)
2! 3!

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


3

2.5
exp(x)
1+x+0.5x 2
2

1+x

1.5

1
1

0.5

0
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Taylor Series (Example-2):
Obtain Taylor Series expansion of 𝑓𝑓(𝑥𝑥) = sin(𝑥𝑥) about 𝑥𝑥 = 0.

𝑓𝑓 𝑥𝑥 = sin(𝑥𝑥) 𝑓𝑓(0) = 0
𝑓𝑓 ′ 𝑥𝑥 = cos 𝑥𝑥 𝑓𝑓′(0) = 1
𝑓𝑓 ′′ 𝑥𝑥 = − sin 𝑥𝑥 𝑓𝑓 ′′ (0) = 0
𝑓𝑓 ′′′ 𝑥𝑥 = − cos 𝑥𝑥 𝑓𝑓 ′′′ 0 = −1


1 (𝑘𝑘) 𝑘𝑘 ′ 𝑓𝑓 ′′ (𝑥𝑥𝑖𝑖 ) 2 𝑓𝑓 ′′′ (𝑥𝑥𝑖𝑖 )
sin(𝑥𝑥) = � 𝑓𝑓 (𝑥𝑥0 )(𝑥𝑥 − 𝑥𝑥0 ) = 𝑓𝑓(𝑥𝑥𝑖𝑖 ) + 𝑓𝑓 (𝑥𝑥𝑖𝑖 )(𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 ) + (𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 ) + (𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 )3 +. . .
𝑘𝑘! 2! 3!
𝑘𝑘=0

𝑥𝑥 3 𝑥𝑥 5 𝑥𝑥 7
sin 𝑥𝑥 = 𝑥𝑥 − + − + ⋯ (The series converges for x < ∞)
3! 5! 7!

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


4

3
x

1 x-x 3/3!+x 5/5!

0 sin(x)

-1
x-x 3/3!

-2

-3

-4
-4 -3 -2 -1 0 1 2 3 4

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Taylor Series (Class Activity):
Obtain Taylor Series expansion of 𝑓𝑓(𝑥𝑥) = cos(𝑥𝑥) about 𝑥𝑥 = 0.


′′ ′′′
1 (𝑘𝑘) 𝑘𝑘 ′
𝑓𝑓 (𝑥𝑥𝑖𝑖 ) 2
𝑓𝑓 (𝑥𝑥𝑖𝑖 )
cos(𝑥𝑥) = � 𝑓𝑓 (𝑥𝑥0 )(𝑥𝑥 − 𝑥𝑥0 ) = 𝑓𝑓(𝑥𝑥𝑖𝑖 ) + 𝑓𝑓 (𝑥𝑥𝑖𝑖 )(𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 ) + (𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 ) + (𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 )3 +. . .
𝑘𝑘! 2! 3!
𝑘𝑘=0

𝑥𝑥 2 𝑥𝑥 4 𝑥𝑥 6
cos 𝑥𝑥 = 1 − + − +⋯ (The series converges for x < ∞)
2! 4! 6!

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Taylor Series:
 Convergence of Taylor Series (Observations, Example: 1&2):
 The Taylor series converges fast (few terms are needed) when 𝑥𝑥 is near the
point of expansion.

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Taylor Series (Example-3):
1
Obtain Taylor Series expansion of 𝑓𝑓(𝑥𝑥) = about 𝑥𝑥 = 0.
1−𝑥𝑥

1
𝑓𝑓 𝑥𝑥 = 𝑓𝑓(0) = 1
1 − 𝑥𝑥

1
𝑓𝑓 ′ 𝑥𝑥 = 2
𝑓𝑓′(0) = 1
1 − 𝑥𝑥

2
𝑓𝑓 ′′ 𝑥𝑥 = 3
𝑓𝑓 ′′ (0) = 2
1 − 𝑥𝑥

6
𝑓𝑓 ′′′ 𝑥𝑥 = 4
𝑓𝑓 ′′′ 0 = 6
1 − 𝑥𝑥

∞ 2 𝑥𝑥 3 𝑥𝑥
1 1 (𝑘𝑘) 𝑓𝑓 0 𝑓𝑓 0
= � 𝑓𝑓 (𝑥𝑥0 )(𝑥𝑥 − 𝑥𝑥0 )𝑘𝑘 = 𝑓𝑓(𝑥𝑥0 ) + 𝑓𝑓 ′ (𝑥𝑥0 )(𝑥𝑥 − 𝑥𝑥0 ) + (𝑥𝑥 − 𝑥𝑥0 )2 + (𝑥𝑥 − 𝑥𝑥0 )3 + ⋯
1 − 𝑥𝑥 𝑘𝑘! 2! 3!
𝑘𝑘=0

1
= 1 + 𝑥𝑥 + 𝑥𝑥 2 + 𝑥𝑥 3 +. . . .
1 − 𝑥𝑥

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Taylor Series:
 Convergence of Taylor Series (Observations, Example: 3):
 Can we apply Taylor Series for 𝑥𝑥 > 1?
 How many terms are needed to get good approximation?

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Taylor Series:
 How many terms are enough?
 In general, the nth-order Taylor series expansion will be exact for an nth-order
polynomial.
 For other differentiable and continuous functions, such as exponentials and
sinusoids, a finite number of terms will not yield an exact estimate.
 In most cases, the inclusion of only a few terms will result in an
approximation that is close enough to the true value for practical purposes.

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Taylor Series (Example-4):
Use Taylor series expansions with 𝑛𝑛 = 0 𝑡𝑡𝑡𝑡 6 to approximate 𝑓𝑓 𝑥𝑥 = cos(𝑥𝑥) at 𝑥𝑥𝑖𝑖+1 = 𝜋𝜋⁄3 on the
basis of the value of 𝑓𝑓(𝑥𝑥) and its derivatives at 𝑥𝑥𝑖𝑖 = 𝜋𝜋⁄4. Note that this means that ℎ = 𝜋𝜋⁄3 −
𝜋𝜋⁄4 = 𝜋𝜋⁄12.

1 (𝑘𝑘) 𝑘𝑘 ′
𝑓𝑓 ′′ (𝑥𝑥𝑖𝑖 ) 2
𝑓𝑓 ′′′ (𝑥𝑥𝑖𝑖 )
𝑓𝑓(𝑥𝑥𝑖𝑖+1 ) = � 𝑓𝑓 (𝑥𝑥0 )(𝑥𝑥 − 𝑥𝑥0 ) = 𝑓𝑓(𝑥𝑥𝑖𝑖 ) + 𝑓𝑓 (𝑥𝑥𝑖𝑖 )(𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 ) + (𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 ) + (𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 )3 +. . .
𝑘𝑘! 2! 3!
𝑘𝑘=0

For zero-order approximation (𝑛𝑛 = 0) Given Data:


𝑓𝑓(𝑥𝑥𝑖𝑖+1 ) = 𝑓𝑓(𝑥𝑥𝑖𝑖 ) 𝜋𝜋 𝜋𝜋
𝑥𝑥𝑖𝑖+1 = 𝑥𝑥𝑖𝑖 =
3 4
𝜋𝜋 𝜋𝜋 𝜋𝜋 𝜋𝜋
𝑓𝑓 ≅ 𝑓𝑓 = 𝑐𝑐𝑐𝑐𝑐𝑐 = 0.707106781 ℎ= 𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 =
3 4 4 12

True value of cos 𝑥𝑥 can be calculated using calculator: cos(𝜋𝜋⁄3) = 0.5

% relative error =

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Taylor Series (Example-4):
Use Taylor series expansions with 𝑛𝑛 = 0 𝑡𝑡𝑡𝑡 6 to approximate 𝑓𝑓 𝑥𝑥 = cos(𝑥𝑥) at 𝑥𝑥𝑖𝑖+1 = 𝜋𝜋⁄3 on the
basis of the value of 𝑓𝑓(𝑥𝑥) and its derivatives at 𝑥𝑥𝑖𝑖 = 𝜋𝜋⁄4. Note that this means that ℎ = 𝜋𝜋⁄3 −
𝜋𝜋⁄4 = 𝜋𝜋⁄12.

1 (𝑘𝑘) 𝑘𝑘 ′
𝑓𝑓 ′′ (𝑥𝑥𝑖𝑖 ) 2
𝑓𝑓 ′′′ (𝑥𝑥𝑖𝑖 )
𝑓𝑓(𝑥𝑥𝑖𝑖+1 ) = � 𝑓𝑓 (𝑥𝑥0 )(𝑥𝑥 − 𝑥𝑥0 ) = 𝑓𝑓(𝑥𝑥𝑖𝑖 ) + 𝑓𝑓 (𝑥𝑥𝑖𝑖 )(𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 ) + (𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 ) + (𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 )3 +. . .
𝑘𝑘! 2! 3!
𝑘𝑘=0

For first-order approximation (𝑛𝑛 = 1) 𝑓𝑓 𝑥𝑥 = cos(𝑥𝑥) Given Data:


𝑓𝑓 𝑥𝑥𝑖𝑖+1 = 𝑓𝑓 𝑥𝑥𝑖𝑖 + 𝑓𝑓 ′ (𝑥𝑥𝑖𝑖 )(𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 ) 𝑓𝑓 ′ 𝑥𝑥𝑖𝑖 = −sin(𝑥𝑥) 𝑥𝑥𝑖𝑖+1 =
𝜋𝜋
𝑥𝑥𝑖𝑖 =
𝜋𝜋
3 4
𝜋𝜋 𝜋𝜋 𝜋𝜋 𝜋𝜋 𝜋𝜋
𝑓𝑓 ≅ 𝑐𝑐𝑐𝑐𝑐𝑐 − 𝑠𝑠𝑠𝑠𝑠𝑠 = 0.521986659 ℎ= 𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 =
3 4 4 12 12

% relative error =

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Taylor Series (Example-4):
Use Taylor series expansions with 𝑛𝑛 = 0 𝑡𝑡𝑡𝑡 6 to approximate 𝑓𝑓 𝑥𝑥 = cos(𝑥𝑥) at 𝑥𝑥𝑖𝑖+1 = 𝜋𝜋⁄3 on the
basis of the value of 𝑓𝑓(𝑥𝑥) and its derivatives at 𝑥𝑥𝑖𝑖 = 𝜋𝜋⁄4. Note that this means that ℎ = 𝜋𝜋⁄3 −
𝜋𝜋⁄4 = 𝜋𝜋⁄12.

1 (𝑘𝑘) 𝑘𝑘 ′
𝑓𝑓 ′′ (𝑥𝑥𝑖𝑖 ) 2
𝑓𝑓 ′′′ (𝑥𝑥𝑖𝑖 )
𝑓𝑓(𝑥𝑥𝑖𝑖+1 ) = � 𝑓𝑓 (𝑥𝑥0 )(𝑥𝑥 − 𝑥𝑥0 ) = 𝑓𝑓(𝑥𝑥𝑖𝑖 ) + 𝑓𝑓 (𝑥𝑥𝑖𝑖 )(𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 ) + (𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 ) + (𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 )3 +. . .
𝑘𝑘! 2! 3!
𝑘𝑘=0

For second-order approximation (𝑛𝑛 = 2) 𝑓𝑓 𝑥𝑥 = cos(𝑥𝑥) Given Data:


𝑓𝑓 ′′ (𝑥𝑥𝑖𝑖 ) 𝑓𝑓 ′ 𝑥𝑥 = − sin 𝑥𝑥 𝑥𝑥𝑖𝑖+1 =
𝜋𝜋
𝑥𝑥𝑖𝑖 =
𝜋𝜋
𝑓𝑓 𝑥𝑥𝑖𝑖+1 = 𝑓𝑓 𝑥𝑥𝑖𝑖 + 𝑓𝑓 ′ 𝑥𝑥𝑖𝑖 𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 + (𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 )2 3 4
2!
𝑓𝑓 ′′ 𝑥𝑥 = −cos(𝑥𝑥) 𝜋𝜋
𝜋𝜋 𝜋𝜋 𝜋𝜋 𝜋𝜋 cos(𝜋𝜋⁄4) 𝜋𝜋 2 ℎ= 𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 =
12
𝑓𝑓 ≅ 𝑐𝑐𝑐𝑐𝑐𝑐 − 𝑠𝑠𝑠𝑠𝑠𝑠 − = 0.497754491
3 4 4 12 2 12

% relative error =

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Taylor Series (Example-4):

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Taylor Series (Example-5):
Use zero- through fourth-order Taylor series expansions to approximate the function from 𝑥𝑥𝑖𝑖 = 0
with ℎ = 1. That is, predict the function’s value at 𝑥𝑥𝑖𝑖+1 = 1.

1 (𝑘𝑘) 𝑘𝑘 ′
𝑓𝑓 ′′ (𝑥𝑥𝑖𝑖 ) 2
𝑓𝑓 ′′′ (𝑥𝑥𝑖𝑖 )
𝑓𝑓(𝑥𝑥𝑖𝑖+1 ) = � 𝑓𝑓 (𝑥𝑥0 )(𝑥𝑥 − 𝑥𝑥0 ) = 𝑓𝑓(𝑥𝑥𝑖𝑖 ) + 𝑓𝑓 (𝑥𝑥𝑖𝑖 )(𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 ) + (𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 ) + (𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 )3 +. . .
𝑘𝑘! 2! 3!
𝑘𝑘=0

For zero-order approximation (𝑛𝑛 = 0) Given Data:


𝑓𝑓(𝑥𝑥𝑖𝑖+1 ) = 𝑓𝑓(𝑥𝑥𝑖𝑖 ) 𝑥𝑥𝑖𝑖+1 = 1 𝑥𝑥𝑖𝑖 = 0

𝑓𝑓 1 ≅ 𝑓𝑓 0 = 1.2 ℎ= 𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 = 1

True value:

𝐸𝐸𝑡𝑡 = true value − approximate value = 0.2 − 1.2 = −1.0

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Taylor Series (Example-5):
Use zero- through fourth-order Taylor series expansions to approximate the function from 𝑥𝑥𝑖𝑖 = 0
with ℎ = 1. That is, predict the function’s value at 𝑥𝑥𝑖𝑖+1 = 1.

1 (𝑘𝑘) 𝑘𝑘 ′
𝑓𝑓 ′′ (𝑥𝑥𝑖𝑖 ) 2
𝑓𝑓 ′′′ (𝑥𝑥𝑖𝑖 )
𝑓𝑓(𝑥𝑥𝑖𝑖+1 ) = � 𝑓𝑓 (𝑥𝑥0 )(𝑥𝑥 − 𝑥𝑥0 ) = 𝑓𝑓(𝑥𝑥𝑖𝑖 ) + 𝑓𝑓 (𝑥𝑥𝑖𝑖 )(𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 ) + (𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 ) + (𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 )3 +. . .
𝑘𝑘! 2! 3!
𝑘𝑘=0

For first-order approximation (𝑛𝑛 = 1) Given Data:


𝑓𝑓 𝑥𝑥𝑖𝑖+1 = 𝑓𝑓 𝑥𝑥𝑖𝑖 + 𝑓𝑓 ′ (𝑥𝑥𝑖𝑖 )(𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 ) 𝑥𝑥𝑖𝑖+1 = 1 𝑥𝑥𝑖𝑖 = 0

𝑓𝑓 1 ≅ 𝑓𝑓 0 = 1.2 − 0.25 1 = 0.95 ℎ= 𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 = 1

𝐸𝐸𝑡𝑡 = true value − approximate value = 0.2 − 0.95 = −0.75

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Taylor Series (Example-5):
Use zero- through fourth-order Taylor series expansions to approximate the function from 𝑥𝑥𝑖𝑖 = 0
with ℎ = 1. That is, predict the function’s value at 𝑥𝑥𝑖𝑖+1 = 1.

1 (𝑘𝑘) 𝑘𝑘 ′
𝑓𝑓 ′′ (𝑥𝑥𝑖𝑖 ) 2
𝑓𝑓 ′′′ (𝑥𝑥𝑖𝑖 )
𝑓𝑓(𝑥𝑥𝑖𝑖+1 ) = � 𝑓𝑓 (𝑥𝑥0 )(𝑥𝑥 − 𝑥𝑥0 ) = 𝑓𝑓(𝑥𝑥𝑖𝑖 ) + 𝑓𝑓 (𝑥𝑥𝑖𝑖 )(𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 ) + (𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 ) + (𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 )3 +. . .
𝑘𝑘! 2! 3!
𝑘𝑘=0

For second-order approximation (𝑛𝑛 = 2) Given Data:


𝑓𝑓 ′′ (𝑥𝑥𝑖𝑖 ) 𝑥𝑥𝑖𝑖+1 = 1 𝑥𝑥𝑖𝑖 = 0
𝑓𝑓 𝑥𝑥𝑖𝑖+1 = 𝑓𝑓 𝑥𝑥𝑖𝑖 + 𝑓𝑓 ′ 𝑥𝑥𝑖𝑖 𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 + (𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 )2
2!
ℎ= 𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 = 1
𝑓𝑓 1 ≅ 𝑓𝑓 0 = 1.2 − 0.25 1 − 0.5(1)2 = 0.45

𝐸𝐸𝑡𝑡 = true value − approximate value = 0.2 − 0.45 = −0.25

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Taylor Series (Example-5):
Use zero- through fourth-order Taylor series expansions to approximate the function from 𝑥𝑥𝑖𝑖 = 0
with ℎ = 1. That is, predict the function’s value at 𝑥𝑥𝑖𝑖+1 = 1.

1 (𝑘𝑘) 𝑘𝑘 ′
𝑓𝑓 ′′ (𝑥𝑥𝑖𝑖 ) 2
𝑓𝑓 ′′′ (𝑥𝑥𝑖𝑖 )
𝑓𝑓(𝑥𝑥𝑖𝑖+1 ) = � 𝑓𝑓 (𝑥𝑥0 )(𝑥𝑥 − 𝑥𝑥0 ) = 𝑓𝑓(𝑥𝑥𝑖𝑖 ) + 𝑓𝑓 (𝑥𝑥𝑖𝑖 )(𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 ) + (𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 ) + (𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 )3 +. . .
𝑘𝑘! 2! 3!
𝑘𝑘=0

For third & fourth-order approximation (𝑛𝑛 = 3, 4) Given Data:

𝑥𝑥𝑖𝑖+1 = 1 𝑥𝑥𝑖𝑖 = 0

ℎ= 𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 = 1

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Taylor Series (Example-5):

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Taylor Series (Remainder):

1 (𝑘𝑘) 𝑘𝑘 ′
𝑓𝑓 ′′ (𝑥𝑥𝑖𝑖 ) 2
𝑓𝑓 ′′′ (𝑥𝑥𝑖𝑖 )
𝑓𝑓(𝑥𝑥𝑖𝑖+1 ) = � 𝑓𝑓 (𝑥𝑥0 )(𝑥𝑥 − 𝑥𝑥0 ) = 𝑓𝑓(𝑥𝑥𝑖𝑖 ) + 𝑓𝑓 (𝑥𝑥𝑖𝑖 )(𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 ) + (𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 ) + (𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 )3 +. . .
𝑘𝑘! 2! 3!
𝑘𝑘=0

 For zero-order Taylor Series expansion

 For first-order Taylor Series expansion

 For nth-order Taylor Series expansion

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Taylor Series (Example-6):
Employ the first-order Taylor series to approximate the function 𝑓𝑓 𝑥𝑥 = 𝑥𝑥 𝑚𝑚 for various values of the
exponent 𝑚𝑚 and the step size ℎ.
For first-order approximation (𝑛𝑛 = 1) Given Data:
𝑚𝑚= 1 𝑡𝑡𝑡𝑡 4
𝑓𝑓(𝑥𝑥𝑖𝑖+1 ) = 𝑓𝑓(𝑥𝑥𝑖𝑖 ) + 𝑓𝑓 ′ (𝑥𝑥𝑖𝑖 )(𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 ) 𝑥𝑥= 1 𝑡𝑡𝑡𝑡 2
𝑓𝑓(𝑥𝑥𝑖𝑖+1 ) = 𝑓𝑓(𝑥𝑥𝑖𝑖 ) + 𝑚𝑚𝑥𝑥𝑖𝑖 𝑚𝑚−1 (ℎ) 𝑓𝑓 𝑥𝑥𝑖𝑖 = 𝑥𝑥𝑖𝑖 𝑚𝑚 𝑥𝑥𝑖𝑖 = 1
𝑥𝑥𝑖𝑖+1 = 2
For 𝑚𝑚 = 1, 𝑥𝑥𝑖𝑖 = 1, 𝑥𝑥𝑖𝑖+1 = 2, ℎ = 1 𝑓𝑓 ′ 𝑥𝑥𝑖𝑖 = 𝑚𝑚𝑥𝑥𝑖𝑖 𝑚𝑚−1 = 1
ℎ= 1
Using Taylor series 𝑓𝑓 2 = 1 1 + 1 1 0(1) = 2 𝑓𝑓 ′′ 𝑥𝑥𝑖𝑖 = 0

For 𝑚𝑚 = 1, 𝑥𝑥 = 2

Actual Value 𝑓𝑓 2 = 𝑥𝑥 𝑚𝑚 = 21 = 2

Remainder is 0, either from actual value or from formula (As higher orders are 0)

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Taylor Series (Example-6):
Employ the first-order Taylor series to approximate the function 𝑓𝑓 𝑥𝑥 = 𝑥𝑥 𝑚𝑚 for various values of the
exponent 𝑚𝑚 and the step size ℎ.
For first-order approximation (𝑛𝑛 = 1) Given Data:
𝑚𝑚= 1 𝑡𝑡𝑡𝑡 4
𝑓𝑓(𝑥𝑥𝑖𝑖+1 ) = 𝑓𝑓(𝑥𝑥𝑖𝑖 ) + 𝑓𝑓 ′ (𝑥𝑥𝑖𝑖 )(𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 ) 𝑥𝑥= 1 𝑡𝑡𝑡𝑡 2
𝑓𝑓(𝑥𝑥𝑖𝑖+1 ) = 𝑓𝑓(𝑥𝑥𝑖𝑖 ) + 𝑚𝑚𝑥𝑥𝑖𝑖 𝑚𝑚−1 (ℎ) 𝑓𝑓 𝑥𝑥𝑖𝑖 = 𝑥𝑥𝑖𝑖 𝑚𝑚 𝑥𝑥𝑖𝑖 = 1
𝑥𝑥𝑖𝑖+1 = 2
For 𝑚𝑚 = 2, 𝑥𝑥𝑖𝑖 = 1, 𝑥𝑥𝑖𝑖+1 = 2, ℎ = 1 𝑓𝑓 ′ 𝑥𝑥𝑖𝑖 = 𝑚𝑚𝑥𝑥𝑖𝑖 𝑚𝑚−1 = 2𝑥𝑥𝑖𝑖
ℎ= 1
Using Taylor series 𝑓𝑓 2 = 1 2 +2 1 2_1(1) =3 𝑓𝑓 ′′ 𝑥𝑥𝑖𝑖 = 2
𝑓𝑓 (3) 𝑥𝑥𝑖𝑖 = 0
For 𝑚𝑚 = 2, 𝑥𝑥 = 2

Actual Value 𝑓𝑓 2 = 𝑥𝑥 𝑚𝑚 = 22 = 4

Remainder is 1, either from actual value or from formula

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Taylor Series (Example-6):
Employ the first-order Taylor series to approximate the function 𝑓𝑓 𝑥𝑥 = 𝑥𝑥 𝑚𝑚 for various values of the
exponent 𝑚𝑚 and the step size ℎ.
For first-order approximation (𝑛𝑛 = 1) Given Data:
𝑚𝑚= 1 𝑡𝑡𝑡𝑡 4
𝑓𝑓(𝑥𝑥𝑖𝑖+1 ) = 𝑓𝑓(𝑥𝑥𝑖𝑖 ) + 𝑓𝑓 ′ (𝑥𝑥𝑖𝑖 )(𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 ) 𝑥𝑥= 1 𝑡𝑡𝑡𝑡 2
𝑓𝑓(𝑥𝑥𝑖𝑖+1 ) = 𝑓𝑓(𝑥𝑥𝑖𝑖 ) + 𝑚𝑚𝑥𝑥𝑖𝑖 𝑚𝑚−1 (ℎ) 𝑓𝑓 𝑥𝑥𝑖𝑖 = 𝑥𝑥𝑖𝑖 𝑚𝑚 𝑥𝑥𝑖𝑖 = 1
𝑥𝑥𝑖𝑖+1 = 2
For 𝑚𝑚 = 3, 𝑥𝑥𝑖𝑖 = 1, 𝑥𝑥𝑖𝑖+1 = 2, ℎ = 1 𝑓𝑓 ′ 𝑥𝑥𝑖𝑖 = 𝑚𝑚𝑥𝑥𝑖𝑖 𝑚𝑚−1 = 3𝑥𝑥𝑖𝑖 2
ℎ= 1
Using Taylor series 𝑓𝑓 2 = 1 3 +3 1 3_1(1) =4 𝑓𝑓 ′′ 𝑥𝑥𝑖𝑖 = 6𝑥𝑥𝑖𝑖
𝑓𝑓 (3) 𝑥𝑥𝑖𝑖 = 6
For 𝑚𝑚 = 3, 𝑥𝑥 = 2
𝑓𝑓 (4) 𝑥𝑥𝑖𝑖 = 0
Actual Value 𝑓𝑓 2 = 𝑥𝑥 𝑚𝑚 = 23 = 8

Remainder is 4, either from actual value or from formula

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Taylor Series (Example-6):
Employ the first-order Taylor series to approximate the function 𝑓𝑓 𝑥𝑥 = 𝑥𝑥 𝑚𝑚 for various values of the
exponent 𝑚𝑚 and the step size ℎ.
For first-order approximation (𝑛𝑛 = 1) Given Data:
𝑚𝑚= 1 𝑡𝑡𝑡𝑡 4
𝑓𝑓(𝑥𝑥𝑖𝑖+1 ) = 𝑓𝑓(𝑥𝑥𝑖𝑖 ) + 𝑓𝑓 ′ (𝑥𝑥𝑖𝑖 )(𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 ) 𝑥𝑥= 1 𝑡𝑡𝑡𝑡 2
𝑓𝑓(𝑥𝑥𝑖𝑖+1 ) = 𝑓𝑓(𝑥𝑥𝑖𝑖 ) + 𝑚𝑚𝑥𝑥𝑖𝑖 𝑚𝑚−1 (ℎ) 𝑓𝑓 𝑥𝑥𝑖𝑖 = 𝑥𝑥𝑖𝑖 𝑚𝑚 𝑥𝑥𝑖𝑖 = 1
𝑥𝑥𝑖𝑖+1 = 2
For 𝑚𝑚 = 4, 𝑥𝑥𝑖𝑖 = 1, 𝑥𝑥𝑖𝑖+1 = 2, ℎ = 1 𝑓𝑓 ′ 𝑥𝑥𝑖𝑖 = 𝑚𝑚𝑥𝑥𝑖𝑖 𝑚𝑚−1 = 4𝑥𝑥𝑖𝑖 3
ℎ= 1
Using Taylor series 𝑓𝑓 2 = 1 4 +4 1 4_1(1) =5 𝑓𝑓 ′′ 𝑥𝑥𝑖𝑖 = 12𝑥𝑥𝑖𝑖 2

𝑓𝑓 (3) 𝑥𝑥𝑖𝑖 = 24𝑥𝑥𝑖𝑖


For 𝑚𝑚 = 3, 𝑥𝑥 = 2
𝑓𝑓 (4) 𝑥𝑥𝑖𝑖 = 24
Actual Value 𝑓𝑓 2 = 𝑥𝑥 𝑚𝑚 = 24 = 16
𝑓𝑓 (5) 𝑥𝑥𝑖𝑖 = 0
Remainder is 11, either from actual value or from formula

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Taylor Series (Example-6):
 Observations, Example: 6:
 Increase in non-linearity of the function, increases the error for the same order of the Taylor
series.

 𝑅𝑅1 will decrease as ℎ is reduced.

Dr. Muhammad Majid Gulzar (CIE-KFUPM)


Taylor Series Expansion (Some Example):

Dr. Muhammad Majid Gulzar (CIE-KFUPM)

You might also like