Using Matlab Plot the function f(x)= e^x and the Maclaurin’s series expansion Using 6 terms, 8 terms and 10 terms
27 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Using Matlab Plot the function f(x)= e^x and the Maclaurin’s series expansion Using 6 terms, 8 terms and 10 terms
0 comentarios
Respuestas (1)
DUY Nguyen
el 3 de Mzo. de 2023
You can check this!
% Define the function and its Maclaurin series expansion
f = @(x) exp(x);
m6 = @(x) 1 + x + x.^2/2 + x.^3/6 + x.^4/24 + x.^5/120;
m8 = @(x) 1 + x + x.^2/2 + x.^3/6 + x.^4/24 + x.^5/120 + x.^6/720 + x.^7/5040;
m10 = @(x) 1 + x + x.^2/2 + x.^3/6 + x.^4/24 + x.^5/120 + x.^6/720 + x.^7/5040 + x.^8/40320 + x.^9/362880;
% Define the range of x values to plot
x = linspace(-3, 3, 100);
% Plot the function and its Maclaurin series expansions
plot(x, f(x), 'LineWidth', 2); hold on;
plot(x, m6(x), 'LineWidth', 2);
plot(x, m8(x), 'LineWidth', 2);
plot(x, m10(x), 'LineWidth', 2);
% Add a legend and labels
legend('f(x)', 'Maclaurin series (6 terms)', 'Maclaurin series (8 terms)', 'Maclaurin series (10 terms)');
xlabel('x');
ylabel('y');
title('Function f(x) = e^x and its Maclaurin series expansion');
0 comentarios
Ver también
Categorías
Más información sobre Function Creation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!