LAB 4
LAB 4
• 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:
MATLAB Code:-
clc
clear
close all
syms x
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
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)')
Answer (Continued...)
Input:-
Enter f(x)=
exp(x)
Enter x =
1
Number of terms n =
3
Output:-
GRAPH :
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.
Answer (Continued...)
MATLAB Code:-
clc
clear
close all
syms x y
Input:-
Output:-
Answer (Continued...)
GRAPH :