Polynomial Approximation

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

Numerical Methods

Polynomial Approximation

Universidad Panamericana Numerical Methods Dr. José Herrera Santos 1


Polynomial approximation for a known function
Consider a function f(x) for which, a
polynomial approximation in x = x0 is
f ( x) sought:

PN ( x) = c0 + c1 x + c2 x 2 + ... + cn x N
In order to simplify the algebra, the
following form for the polynomial is used:
( x0 , f ( x0 ))
PN ( x) = b0 + b1 ( x − x0 ) + b2 ( x − x0 ) 2 + ... + bn ( x − x0 ) N

If f(x) must be equal to Pn(x), then the n derivatives of both in x = x0 must be equal

PN(0) ( x) = b0 + b1 ( x − x0 ) + b2 ( x − x0 ) 2 + ... + bn ( x − x0 ) N → PN(0) ( x0 ) = b0


PN(1) ( x) = 1  b1 + 2  b2 ( x − x0 ) + 3  b3 ( x − x0 ) 2 + ... + N  bn ( x − x0 ) N −1 → PN(1) ( x0 ) = 1  b1
PN(2) ( x) = 1  2b2 + 2  3b3 ( x − x0 )1 + ... + (N − 1)  N  bn ( x − x0 ) N − 2 → PN(2) ( x0 ) = 1 2b2
PN(3) ( x) = 1  2  3b3 + ... + (N − 2)  (N − 1)  N  bn ( x − x0 ) N −3 → PN(3) ( x0 ) = 1  2  3b3

PN( k ) ( x) = 1  2  ...  (k − 1)  k  bk + ... + (N − k + 1)  ...  (N − 1)  N  bn ( x − x0 ) N − k → PN(k) ( x0 ) = k !bk

Universidad Panamericana Numerical Methods Dr. José Herrera Santos 2


Polynomial approximation for a known function
The coefficients of the polynomial are found from the last equation:

f ( k ) ( x0 )
P ( x0 ) = f
(k)
N
(k )
( x0 ) → bk =
k!

Therefore:

Polynomial approximation of degree n for the


N (k )
f ( x0 )
PN ( x) =  ( x − x0 )
k function f(x). As the evaluation point get away
k =0 k! from x0, more terms are necessary to have a
good approximation

f ( x)  PN ( x)
Remember that the number of terms is always
finite no matter how many of them are

f ( k ) ( x0 ) calculated. The series expansion is expected to
f ( x) =  ( x − x0 )
k

k! be equal to f(x) only if there an infinite number


k =0
of terms

Universidad Panamericana Numerical Methods Dr. José Herrera Santos 3


Taylor’s Theorem

Assume that f  C n +1[a, b] and let x0  [a, b]. Then, for every x  (a, b), there exist a number
c = c( x) (the number c depends on the value of x) that lies between x 0 and x such that

f ( x) = PN ( x) + RN ( x)

where,
N
f ( k ) ( x0 )
PN ( x) =  ( x − x0 )
k

k =0 k!
is the Taylor's polynomial of degree N around x0 and RN ( x) is the error of the approximation

Calculation of the error.


RN ( x) = f ( x) − PN ( x)
Notice that in x = x0 , RN ( x0 ) = 0

f ( N +1) (c)
( x - x0 )
N +1
RN ( x) = Estimation of the error
( N + 1)!

Universidad Panamericana Numerical Methods Dr. José Herrera Santos 4


Example 1

f ( x) = e x

Find the Taylor′s series for 𝑥0 = 0 up to 𝑁 = 15


For every single polynomial, evaluate 𝑥 = 1 and
calculate the error of the approximation

Universidad Panamericana Numerical Methods Dr. José Herrera Santos 5


Example 1 – cont.

Universidad Panamericana Numerical Methods Dr. José Herrera Santos 6


Example 2
f ( x) = Sin( x) + Cos (2 x)

Find the Taylor′s series for 𝑥0 = 0 up to 𝑁 = 15


For every single polynomial, evaluate 𝑥 = 1 and
calculate the error of the approximation

Universidad Panamericana Numerical Methods Dr. José Herrera Santos 7


Example 2 – cont.

Universidad Panamericana Numerical Methods Dr. José Herrera Santos 8


Problem

For the function 𝑓 𝑥 = 𝑒 𝑥

a) Find the polynomial approximation of degree 3 with center in 𝑥 = 1


b) Find the polynomial approximation of degree 4 with center in 𝑥 = 1
c) Find the polynomial approximation of degree 2 with center in 𝑥 = 3
d) For the cases a) , b) and c), calculate the relative error in x = 2

Universidad Panamericana Numerical Methods Dr. José Herrera Santos 9

You might also like