Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote