dv/dt = p(t) v + q(t)
Where,
p(t) = 5(1+t)
and,
q(t) = (1+t)e-t
The initial value is, v(0) = 1; and the time period is 0 < t < 10.
Implicit Euler approach is unconditionally stable. The implementation of Implicit Euler scheme may be represented as,
v_n+1 = (v_n + hq_n+1) / (1 + hp_n+1)
MATLAB program:
v_n+1 = (v_n + hq_n+1) / (1 + hp_n+1)
The following MATLAB program implements this scheme:
MATLAB program:
close all;
clc;
y1(1) = 0; % Initial condition
h = 0.1; % Time step
t1(1) = 0;
i = 1;
% Implementation of the Implicit Euler approach
while (t1(i) <= 30)
q=(1+t1(i))*exp(-t1(i));
p= 5*(1+t1(i));
y1(i+1) = (y1(i)+(h*q))/(1+h*p);
t1(i+1) = t1(i) + h;
i = i + 1;
end
plot(t1,y1,'-o')
hold on
Program Output:
The following plot shows the progression of the solution as the time increases.
clc;
y1(1) = 0; % Initial condition
h = 0.1; % Time step
t1(1) = 0;
i = 1;
% Implementation of the Implicit Euler approach
while (t1(i) <= 30)
q=(1+t1(i))*exp(-t1(i));
p= 5*(1+t1(i));
y1(i+1) = (y1(i)+(h*q))/(1+h*p);
t1(i+1) = t1(i) + h;
i = i + 1;
end
plot(t1,y1,'-o')
hold on
Program Output:
The following plot shows the progression of the solution as the time increases.
No comments:
Post a Comment