Expand f (x, y) =e^xln(1 + y) in terms of x and y up to the terms of 3rd degree using Taylor series.
52 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
clear
clc
close all
syms x y
f=input('Enter the function f(x,y): ')
I=input('Enter the point[a,b] at which Taylor series is sought: ');
a=I(1);b=I(2);
n=input('Enter the order of series:');
tayser=taylor(f,[x,y],[a,b],'order',n)
subplot(1,2,1);
ezsurf(f); %Function plot
subplot(1,2,2);
ezsurf(tayser); % Taylors series of f
5 commentaires
Réponses (1)
Hari
le 2 Oct 2023
Hi,
I understand you are facing difficulty in expanding the function using Taylor series up to the terms of 3rd degree.
I assume that the expansion is centered around the point . To expand the function using Taylor series, we need to calculate the partial derivatives of with respect to x and y, and evaluate them at . Then, we can use these derivatives to construct the terms of the expansion.
Here is a sample code to do that:
syms x y;
% Define the function
f = exp(x)*log(1 + y);
% Calculate the partial derivatives
f_x = diff(f, x);
f_y = diff(f, y);
f_xx = diff(f_x, x);
f_yy = diff(f_y, y);
f_xy = diff(f_x, y);
% Evaluate the derivatives at (a, b) = (0, 0)
a = 0;
b = 0;
f_x_a_b = subs(f_x, [x, y], [a, b]);
f_y_a_b = subs(f_y, [x, y], [a, b]);
f_xx_a_b = subs(f_xx, [x, y], [a, b]);
f_yy_a_b = subs(f_yy, [x, y], [a, b]);
f_xy_a_b = subs(f_xy, [x, y], [a, b]);
% Construct the terms of the expansion
expansion = 1 + x + y + (1/2)*f_xx_a_b*x^2 + (1/2)*f_yy_a_b*y^2 + f_xy_a_b*x*y;
% Display the expansion
disp(expansion);
Refer to the documentation of "Symbolic Math Toolbox" for more information on how to express and solve mathematical equations in MATLAB.
Hope this helps!
0 commentaires
Voir également
Catégories
En savoir plus sur Equation Solving dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!