Using the improved Euler (Huen) method, determine the approximate solution y (t) of the following starting problem:

2 ビュー (過去 30 日間)
Using the improved Euler (Huen) method, determine the approximate solution y (t) of the following starting problem:
dy / dt = y * e ^ 5t, y (0) = 1; t; [0, 0.5]
for time steps: h = ½; h = ¼; h = 1/8; h = 1/16; h = 1/32;
Then solve the above differential equation using the separated variables method. Compare the obtained numerical results on the graph with the exact solution y (t). Calculate the global error en for each of the time steps h and determine on this basis the order of the improved Euler (Huen) method. I have to solve it in Matlab, but I have problem with doing the script. If anyone would provide me to simple code for the solution, it would be really helpfull for me. Thank you for all the answers and tips :)
  4 件のコメント
Walter Roberson
Walter Roberson 2021 年 5 月 28 日
Torsten answered the question. It is too late to delete it now.
Rena Berman
Rena Berman 2021 年 6 月 29 日
(Answers Dev) Restored edit

サインインしてコメントする。

回答 (1 件)

Torsten
Torsten 2021 年 5 月 28 日
編集済み: Jan 2021 年 5 月 28 日
Untested !
function main
H = [1/2 ,1/4,1/8,1/16,1/32];
t0 = 0;
t1 = 0.5;
y0 = 1;
f = @(t,y) y*exp(5*t);
for i= 1:numel(H)
h = H(i);
t = (t0:h:t1).' ;
N = numel(t);
y = zeros(N,1);
y(1) = y0;
for j = 2:N
yhelp = y(j-1) + h*f(t(j-1),y(j-1));
y(j) = 0.5*y(j-1) + 0.5*(yhelp + h*f(t(j),yhelp));
end
T{i} = t;
Y{i} = y;
end
plot(T,Y)
end

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by