Taylor's series method to solve first order first degree ODE
54 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Can someone help with how to solve first order first degree ODE using Taylor's series method? I am able to find derivatives but unable to substitute the values at given initial condition.
I have typed the code as below,
clear
clc
syms x y(x)
x0 = 0;
y0 = 1;
y1 = x^2*y-1;
y2 = diff(y1);
y3 = diff(y2);
y4 = diff(y3);
y10 = subs(y1,x,0);
y20 = subs(y2,x,0);
y30 = subs(y3,x,0);
y40 = subs(y4,x,0);
%Taylor's Method
y = y0 + (x-x0)*y10 +(((x-x0)^2)/2)*y20 + (((x-x0)^3)/6)*y30 + (((x-x0)^4)/24)*y40
And the output is as below.
substitution at x=0 is not working. Kindly help.
0 Commenti
Risposte (1)
VBBV
il 27 Mag 2023
Modificato: VBBV
il 27 Mag 2023
Use taylor function
clear
clc
syms x y(x)
x0 = 0;
y0 = 1;
y1 = x^2*y-1;
y2 = diff(y1);
y3 = diff(y2);
y4 = diff(y3);
y10 = subs(y1,x,0);
y20 = subs(y2,x,0);
y30 = subs(y3,x,0);
y40 = subs(y4,x,0);
%Taylor's Method
% y = y0 + (x-x0)*y10 +(((x-x0)^2)/2)*y20 + (((x-x0)^3)/6)*y30 + (((x-x0)^4)/24)*y40
% use taylor
y = y0+taylor(x^2*y-1,x,'ExpansionPoint',0)
3 Commenti
VBBV
il 27 Mag 2023
clear
clc
syms x y(x)
x0 = 0;
y0 = 1;
y1 = x^2*y-1;
y2 = diff(y1);
y3 = diff(y2);
y4 = diff(y3);
y10 = subs(y1,x,0)
y20 = subs(y2,x,0)
y30 = subs(y3,x,0)
y40 = subs(y4,x,0)
%Taylor's Method
% y = y0 + (x-x0)*y10 +(((x-x0)^2)/2)*y20 + (((x-x0)^3)/6)*y30 + (((x-x0)^4)/24)*y40
% use taylor
y = y0+taylor(x^2*y-1,x,'ExpansionPoint',0)
y = subs(y,x,0)
Can you tell why coefficients are not considered correctly ?
Vedere anche
Categorie
Scopri di più su Calculus in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!