Report
Report
COLLEGE OF ENGINEERING
Final Project
Taylor Approximation
Majed Alshemmari
Date: 17/2/2023
KING FAISAL UNIVERSITY
COLLEGE OF ENGINEERING
Contents
1. Introduction.................................................................................................................................2
2. Taylor Approximation...................................................................................................................2
3. Linear Approximation...................................................................................................................3
4. Results.........................................................................................................................................3
5. Conclusion....................................................................................................................................5
Appendix A..........................................................................................................................................6
References...........................................................................................................................................7
KING FAISAL UNIVERSITY
COLLEGE OF ENGINEERING
1. Introduction
A Taylor series is a clever way to approximate any function as a polynomial with
an infinite sum of terms. Each term of the Taylor polynomial comes from the
function's derivatives at a single point. This approximation encodes the full
information we need to know about the function. So, we can replace those
functions with one of their appropriate Taylor polynomials, because it is often
easier to manipulate than more complex functions. it helps to evaluate limits and
determine the type of degenerate critical point exactly. also, it can be used to
approximate integrals of complicated functions. In this project, we will compare
the original function and its Taylor approximation of different orders,
Furthermore, we will compare the original function integration to Taylor
approximation integration.
2. Taylor Approximation
As we mentioned in the introduction we need to avoid working with complex
functions, so we use approximations. The simplest used approximation is the
linear or first-order approximation. but it is a bad approximation, So, scientists
found other approximation methods like Taylor.
Let's state the definition of the Taylor polynomial. Let a function f ( x ), with N
derivatives at x=x 0 then Taylor expansion for f of order N in the neighborhood of
x 0 it donate by T N ( x ).
(n )
N
f ( x0 )
T N ( x )=∑ (x−x 0 )2 … ( 1 )
n=0 n!
In special case when x 0=0 it called Maclaurin polynomial then formula 1 which
take the next form
N (n )
f (0 ) 2
T N ( x )=∑ (x ) …(2)
n=0 n!
As we note Taylor polynomials allow us to approximate any function using powers
of x. The accurate approximation increases when we calculate more derivatives if
it exists. Since the Taylor polynomial formula is based on the derivatives of the
KING FAISAL UNIVERSITY
COLLEGE OF ENGINEERING
function, the center point, and the power functions, it changes from one function
to another.
3. Linear Approximation
The idea behind linear approximation it could be difficult to calculate nearby
values of the function and it is much simpler to perform the linear approximation.
This method uses the tangent line to a curve to approximate another point on
that curve. It is a good method to calculate the value of function f near a point
x=a . It also called tangent approximation method. The equation of this tangent
line.
'
L ( x ) =f ( a )+ f ( a ) ( x−a ) … (3)
It is regularly used in the field of optics, also it is used to describe the motion of a
pendulum and the vibrations of a string.
4. Results
We compare the f ( x )=x 2 . sin (x )+ e−x .cos 2 ( x)to its Taylor expansion using MATLAB
code see appendix A.
The results shown in figure 1, the blue curve is the original function, and the red,
orange and violet curves show Taylor approximation of degree 4, 7, 10
respectively. These curves show the approximation of f near to x 0=0 is good
approximation for all degrees, but the accurate of approximation increase when
the degree of Taylor expansion increased, with degree 10 of Taylor expansion, we
note the curve is so close to the original function.
KING FAISAL UNIVERSITY
COLLEGE OF ENGINEERING
80
60
40
f(x)
20
-20
-40
-60
-3 -2 -1 0 1 2 3
x
Also, we compare the integration of f ( x )=x 2 . sin (x )+ e−x .cos 2 ( x) to integration of its
Taylor expansion using MATLAB code see appendix A.
Integration of f(x) & Taylor Approximation
40
F(x)
integration of taylor expansion degree=4
integration of taylor expansion degree=7
integration of taylor expansion degree=10
30
20
10
F(x)
-10
-20
-30
-40
-3 -2 -1 0 1 2 3
x
The results shown in figure 2, the blue curve is the integration of the original
function, the red, orange and violet curves show the integration of Taylor
approximation of degree 4, 7, 10 respectively. These curves show the
approximation of f integration near to x 0=0 , although the accurate of
approximation increase when the degree of Taylor expansion increased, the error
still exists.
5. Conclusion
In this project we discussed the Taylor approximation and the Tangent line
approximation, we show the difference between the two approximations. Then,
we find the Taylor expansion of different degrees for a given function f, and also
find the integration of the function f and the integration of its Taylor expansion of
different degrees, the result show we get the exact value of the function near a
specific point, for the integration we get an approximation value. In the two
cases, the accuracy of the Taylor approximation is increased when the degree is
increased. Thus, Taylor expansion is a good approximation to simplify complex
functions.
KING FAISAL UNIVERSITY
COLLEGE OF ENGINEERING
Appendix A
close all;
clc;
clear;
syms x
x1=linspace(-pi,pi, 100);
fx1= (x1.^2).*sin(x1)+exp(-x1).*(cos(x1).^2);
plot(x1,fx1, 'linewidth' ,2)
grid on
hold on
f= (x^2)*sin(x)+exp(-x)*(cos(x)^2);
T4 = taylor(f,x,'Order',4);
fplot(T4,[-pi pi],'-*','linewidth' ,2)
T7 = taylor(f,x,'Order', 7);
fplot(T7,[-pi pi],'-o','linewidth' ,2)
T10 = taylor(f,x, 'Order', 10);
fplot(T10,[-pi pi],'--','linewidth' ,2)
xlim([-pi pi])
legend('f(x)','Taylor expansion degree=4','Taylor expansion
degree=7','Taylor expansion degree=10')
hold off
xlabel('x')
ylabel('f(x)')
title('f(x) & Taylor Approximation')
%
figure
Ifx=int(f,x);
fplot(Ifx, [-pi pi],'linewidth' ,2)
grid on
hold on
IfT4=int(T4,x);
fplot(IfT4,[-pi pi],'-*','linewidth' ,2)
IfT7=int(T7,x);
fplot(IfT7,[-pi pi],'-o','linewidth' ,2)
IfT10=int(T10,x);
fplot(IfT10,[-pi pi],'--','linewidth' ,2)
legend('F(x)','integration of taylor expansion
degree=4','integration of taylor expansion
degree=7','integration of taylor expansion degree=10')
xlabel('x')
ylabel('F(x)')
title('Integration of f(x) & Taylor Approximation')
KING FAISAL UNIVERSITY
COLLEGE OF ENGINEERING
References
[ ]1عمران قوبا ،التحليل ثاني ،الجزء الثاني ،من منشورات المعهد العالي للعلوم
التطبيقية والتكنولوجيا ،الجمهورية العربية السورية.2017 ،