0% found this document useful (0 votes)
1 views

LAB 4

The document outlines the guidelines and submission format for Experiment 4 of the MAT1011 course, focusing on Taylor's Expansion for one and two variables. It includes detailed instructions for writing MATLAB code to find the Taylor series expansion of specified functions, along with input and output examples. The submission must be in a single PDF file, adhering strictly to the provided format to avoid mark deductions.

Uploaded by

mzrcfh9my5
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

LAB 4

The document outlines the guidelines and submission format for Experiment 4 of the MAT1011 course, focusing on Taylor's Expansion for one and two variables. It includes detailed instructions for writing MATLAB code to find the Taylor series expansion of specified functions, along with input and output examples. The submission must be in a single PDF file, adhering strictly to the provided format to avoid mark deductions.

Uploaded by

mzrcfh9my5
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

FS 2020-21

• Course: MAT1011(CFE) - ELA


• Regd. No. 20BCT0066
• Name: N.JAYANTH
• Slot: L43 + L44

Last Date of submission: 11.01.2021

Experiment 4: Taylor’s Expansion for One / Two Variables

Guidelines for Submission:

• Download this sheet, and write your answers in detail neatly without any corrections.
In case of graphical answer, create the image file of it and paste it in the answer, where
ever needed
• Write your name and do the signature on the top of every page
• Take the snap shot of the title page and the filled-in answer sheet carefully which should
be clearly visible, and make a single pdf file only
• Then upload it through the lab log-in portal.
• Do not send different image files or zipped files. Do not send the answer sheet to my
mail
• Follow the guidelines strictly. Any deviation from the above instructions will lead to the
reduction in marks

Submission Format:
(a) Aim of the Experiment
(b) Definitions, Mathematical formulas or brief concept related to the exercise
(c) Matlab Code
(d) Input
(e) Output (including the graphical representation)
Uploading of answers in any other format is not acceptable
Regd. No. 20BCT0066 Name: N.JAYANTH Sign.

Exercise 1 (3 marks). Write a Matlab to find the Taylor’s series expansion of f ( x) about the
point x = a upto the third degree term and visualize them. Use the code for f ( x) = e x and x = 1.

Answers:

Aim:- To a MATLAB code to find the Taylor's series expansion of a function


about a point x=a upto the third degree term and visualize them.

MATLAB Code:-

clc
clear
close all

syms x

f(x) = input('Enter f(x)= ');


a = input('Enter x = ');
n = input('Number of terms n = ' );

Tf(x) = f(a);
for i= 1:n-1
Df(x) = diff(f,x,i);
Tf(x) = Tf(x) + (1/factorial(i))*((x-a)^i)*Df(a);
end

disp('Taylors Series of f(x) is: ')


disp(char(Tf))

fplot(f,[a-2,a+2])
hold on
grid on
fplot(Tf,[a-2,a+2])
title(['Taylors series of f(x) =',char(fa)])
legend('f(x)','Taylors Series of f(x)')

Matlab Experiment 4 2 MAT1011


Regd. No. 20BCT0066 Name: N.JAYANTH Sign.

Answer (Continued...)

Input:-

Enter f(x)=
exp(x)
Enter x =
1
Number of terms n =
3

Output:-

Taylors Series of f(x) is:


exp(1) + exp(1)*(x - 1) + (exp(1)*(x - 1)^2)/

GRAPH :

Matlab Experiment 4 3 MAT1011


Regd. No. 20BCT0066 Name: N.JAYANTH Sign.

Exercise 2 (3 marks). Write a Matlab to find the Taylor’s series expansion of f ( x, y) near the
x
¡
point a, b) ¡upto the
¢ third degree term and visualize them. Use the code for f ( x, y) = e cos y
π
and (a, b) = − 1, 4 .

Answers:

Aim:- To write a MATLAB code to find the Taylor's series expansion of a function near
a point upto the third degree term and visualize them.

TAYLOR'S EXPANSION OF TWO VARIABLES :

Matlab Experiment 4 4 MAT1011


Regd. No. 20BCT0066 Name: N.JAYANTH Sign.

Answer (Continued...)

MATLAB Code:-

clc
clear
close all

syms x y

f(x,y) = input('Enter the function : ');


a = input('Enter the value of a: ');
b = input('Enter the value of b: ');

fx(x,y) = diff(f,x); fy(x,y)= diff(f,y);


fxx(x,y) = diff(fx,x); fxy(x,y) = diff(fx,y); fyy(x,y) = diff(fy,y);
fxxx(x,y) = diff(fxx,x);fxxy(x,y) = diff(fxx,y); fxyy(x,y) = diff(fxy,y); fyyy(x,y)= diff(fyy,y);

temp = f(a,b) + (1/factorial(1))((fx(a,b)(x-a))+(fy(a,b)*(y-b)))...


+ (1/factorial(2))((fx(a,b)(x-a)^2)+2*fxy(a,b)(x-a)(y-b)+(fyy(a,b)*(y-b)^2))...
+ (1/factorial(3))((fxxx(a,b)(x-a)^3)+ (fyyy(a,b)(y-b)^3) + 3(x-a)^2*(y-b)fxxy(a,b) +
3(x-a)*(y-b)^2*fxyy(a,b));
disp(char(temp))
subplot(1,2,1);
fsurf(f)
title('Graph of input function')
xlabel('x-axis')
ylabel('y-axis')
subplot(1,2,2)
fsurf(f)
title('Graph of taylor series function')
xlabel('x-axis')
ylabel('y-axis')

Input:-

Enter the function:


exp(x)*cos(y)
Enter the value of a:
-1
Enter the value of b:
pi/4

Output:-

(2^(1/2)exp(-1))/2 - (2^(1/2)*exp(-1)(y - pi/4)^2)/4 + (2^(1/2)exp(-1)(y - pi/4)^3)/12 +


(2^(1/2)exp(-1)(x + 1)^2)/4 + (2^(1/2)exp(-1)(x + 1)^3)/12 - (2^(1/2)exp(-1)(y - pi/4))/2 +
(2^(1/2)exp(-1)(x + 1))/2 - (2^(1/2)exp(-1)(3*x + 3)(y - pi/4)^2)/12 -
(2^(1/2)*exp(-1)(y - pi/4)(x + 1))/2 - (2^(1/2)*exp(-1)(y - pi/4)*(x + 1)^2)/4

Matlab Experiment 4 5 MAT1011


Regd. No. 20BCT0066 Name: N.JAYANTH Sign.

Answer (Continued...)

GRAPH :

Matlab Experiment 4 6 MAT1011

You might also like