Use Euler\'s method with h = 0.2 to approximate thesolution of the differential
ID: 2939805 • Letter: U
Question
Use Euler's method with h = 0.2 to approximate thesolution of the differential equationdy/dx = xy with y(0)=2.0 at x = 1.
Note: your answer must agree with the computed answer to at least 3digits. You should enter at least 4 or 5 digits. If an answerterminates in an exact answer, e.g. 1.50, then enter this answereven if it is fewer than the indicated number of digits.
Use Euler's method with h = 0.2 to approximate thesolution of the differential equation
dy/dx = xy with y(0)=2.0 at x = 1.
Note: your answer must agree with the computed answer to at least 3digits. You should enter at least 4 or 5 digits. If an answerterminates in an exact answer, e.g. 1.50, then enter this answereven if it is fewer than the indicated number of digits.
Explanation / Answer
h=0.2;
tmax=1.0;
t(1)= 0;
n=(tmax-t(1))/h;
y(1)=2;
tout=t(1);
yout=y(1).';
disp(' tiEULER')
disp('~~~~~~~~~~~~~~~~~~~~~~~')
for i=1:(n+1)
t(i+1)=t(1)+i*h;
%
k1=h*f(t(i),y(i));
y(i+1)=y(i)+k1;
%
tout=[tout;t(i)];
yout=[yout,y(i).'];
fprintf ('%5.2f%17.4f ',t(i),y(i));
end
function yz=f(t,y)
yz=t*y;
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.