Question

Solve using Matlab Use the forward Euler method, Vi+,-Vi+(4+1-tinti ,Vi) for i= 0,1,2, , taking yo y(to) to be the initial condition, to approxi

0 0
Add a comment Improve this question Transcribed image text
Answer #1

clc;clear all;
format long
t0=0;
tf=2;
f=@(t,y) y-t^2+1;
fact=@(t) (t+1)^2-exp(t)/2;
yact=fact(2);
k=1:1:20;
N=2.^k;
h=(tf-t0)./(N-1);
m=length(h);

for j=1:m
    y0=0.5;
    t=t0:h(j):tf;
    mm=length(t);
    for i=1:mm
         y(i)=y0+h(j)*f(t(i),y0);
         y0=y(i);
    end
   err(j)=abs(y0-yact);

end
plot(h,err)
set(gca, 'XDir','reverse')

xlabel('h')
ylabel('error')
axis([0 2 0 5])

Figure 1 File Edit View Insert Tools Desktop Window Help 4.5 3.5 2.5 0.5 2 1.8 1.6 1.4 1.2 1 0.8 0.6 0.4 0.2 0

Add a comment
Know the answer?
Add Answer to:
Solve using Matlab Use the forward Euler method, Vi+,-Vi+(4+1-tinti ,Vi) for i= 0,1,2, , taking yo y(to) to be the initial condition, to approximate the solution at t-2 of the IVP y'=y-t2 + 1, 0-...
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