matlab 展示 泰勒级数近似
clc;
clear;
syms x;
f = sin(x)/x;
xpoint = 2;
ypoint = subs(f, x, xpoint);
T6 = taylor(f, x, xpoint, Order=3);
fp = fplot(f, 'b-');
fp.LineWidth = 3;
hold on;
ft=fplot(T6, 'm--');
ft.LineWidth = 2;
scatter(xpoint, ypoint, 300, "filled", 'r');
hold on;
hold off;
xlim([-4 4]);
grid on;
legend("sin(x)/x", ...
"approximation of sin(x)/x", ...
"x=2", Location="northeast")
title("Taylor Series Expansion")
clear;
syms x;
f = sin(x)/x;
xpoint = 2;
ypoint = subs(f, x, xpoint);
T6 = taylor(f, x, xpoint, Order=3);
fp = fplot(f, 'b-');
fp.LineWidth = 3;
hold on;
ft=fplot(T6, 'm--');
ft.LineWidth = 2;
scatter(xpoint, ypoint, 300, "filled", 'r');
hold on;
hold off;
xlim([-4 4]);
grid on;
legend("sin(x)/x", ...
"approximation of sin(x)/x", ...
"x=2", Location="northeast")
title("Taylor Series Expansion")
评论已关闭