Question

Problem # 2 P-2 Solve the following IVP equation with step size h-0.25: dv = 7угх, y( 2.05)--(.388586800880232 dx Compare the
0 0
Add a comment Improve this question Transcribed image text
Answer #1

%%% Matlab code %%

clc;
close all;
clear all;
format long
f=@(x,y) 7*y^2*x^3;
y(1)=-0.388586880232;
x(1)=2.05;
h=0.025;
x=x(1):h:4;
for n=1:length(x)-1

y(n+1)=y(n)+h*f(x(n),y(n));
  

end

%%%Exact solution
ye=-1./(7/4*x.^4-85/3);
  
%%%Error vector
err=abs(y-ye);
plot(x,y,'*');
hold on
plot(x,ye)
hold on
plot(x,err);
xlabel('x');
legend('Eular method','Exact solution','Error vector');
grid on

OUTPUT:

0.1 Eular method Exact solution Error vector 0.05 0.05 -0.1 0.15 -0.2 -0.25 0.3 0.35 -0.4 2 2.2 2.4 2.6 2.8 33.2 3.4 3.6 3.8

Add a comment
Know the answer?
Add Answer to:
Problem # 2 P-2 Solve the following IVP equation with step size h-0.25: dv = 7угх,...
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