Use Euler\'s method with h = 0.5 to approximatethe solution of the differential
ID: 2939806 • Letter: U
Question
Use Euler's method with h = 0.5 to approximatethe solution of the differential equationdy/dx=3y-2x with y(0)=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.5 to approximatethe solution of the differential equation
dy/dx=3y-2x with y(0)=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.5;
tmax=1.0;
t(1)= 0;
n=(tmax-t(1))/h;
y(1)=0;
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)
Use Euler's method with h = 0.5 to approximatethe solution of the differential equationdy/dx=3y-2x with y(0)=0 at x=1.
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.