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)
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
Ananya  Pai
Ananya Pai le 17 Avr 2022
exp(x)*ln(1+y) ? is this correct ?
when i run the program i am not getting the next line that it is supposed to ask
Torsten
Torsten le 17 Avr 2022
I suggest you first try to make your program work without manual inputs.

Connectez-vous pour commenter.

Réponses (1)

Hari
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!

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by