Question
i really just need help with part c and d. thank you!
(a)Use Euler method to find the difference equation for the following IVP (initial value problem). Please Type your work. (Du
0 0
Add a comment Improve this question Transcribed image text
Answer #1

(c) and (d)

%% Matlab code %%

clc;
close all;
clear all;
format long;
f=@(t,y)y*(1-y);
y(1)=0.01;

%%%% Exact solution
[t1 y1]=ode45(f,[0 9],y(1));
figure;
plot(t1,y1,'*');
hold on
% Eular therom
M=[32 64 128];
T=9;
fprintf(' M Max error \n' );
for n=1:length(M)
k=T/M(n);
t=0:k:T;
for h=1:length(t)-1
y(h+1)=y(h)+k*f(t(h),y(h));
end
plot(t,y);
hold on
%%% Exact solution
[t y2]=ode45(f,t,y(1));
Mer=max(abs(y2-y'));
fprintf(' %d %f \n',M(n),Mer);
end

legend('Exact solution','M=30','M=64','M=128');
xlabel('t');
ylabel('y(t)');

OUTPUT:

media%2F80f%2F80fed97b-84d7-4cce-a306-b8

M Max error
32 0.109855   
64 0.056016   
128 0.028231

Add a comment
Know the answer?
Add Answer to:
(a)Use Euler method to find the difference equation for the following IVP (initial value problem)...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT