Having troubles trying to finish this code to plot the graph for this taylor ser
ID: 1715754 • Letter: H
Question
Having troubles trying to finish this code to plot the graph for this taylor series. This is the code I have thus far. Just need help getting it to plot in MATLAB.
format short
syms x;
y = -0.1*x.^4 - 0.15.*x.^3 - 0.5*x.^2 - 0.25*x + 1.2;
y1 = diff(y,x,1);
y2 = diff(y, x, 2); %%2nd order derivative; same as y2 = diff(y1, x, 1)
disp(subs(y, 0))
disp(subs(y1, 0))
disp(subs(y2, 0)/factorial(2))
disp(subs(diff(y, x, 3), 0)/factorial(3))
disp(subs(diff(y, x, 4), 0)/factorial(4))
format short
syms x;
y = -0.1*x.^4 - 0.15.*x.^3 - 0.5*x.^2 - 0.25*x + 1.2;
y1 = diff(y,x,1);
y2 = diff(y, x, 2); %%2nd order derivative; same as y2 = diff(y1, x, 1)
disp(subs(y, 0))
disp(subs(y1, 0))
disp(subs(y2, 0)/factorial(2))
disp(subs(diff(y, x, 3), 0)/factorial(3))
disp(subs(diff(y, x, 4), 0)/factorial(4))
Explanation / Answer
clear all
close all
clc
format short
syms x;
for i=0:1:4
y = -0.1*x.^4 - 0.15.*x.^3 - 0.5*x.^2 - 0.25*x + 1.2;
y = subs(diff(y,x,i),0)/factorial(i);
plot(i,y,'b')
hold on
end
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.