Question

5. Consider the following second order IVP y2y te - t, 0 t1 y(0)/(0) 0 = ( y(t). Transform the above IVP to system of first o


(c) Compare the results to the actual solution y(t) = %et - te 2e t - 2.
5. Consider the following second order IVP y2y te - t, 0 t1 y(0)/(0) 0 = ( y(t). Transform the above IVP to system of first order (a) Let u(t)y(t) and u2(t) IVP of u and u2. (b) Find y(t) by solving the system with h 0.1
(c) Compare the results to the actual solution y(t) = %et - te 2e t - 2.
0 0
Add a comment Improve this question Transcribed image text
Answer #1


5. -t te (02,5 Let dy dt dt duy 2. dtr P. dy Tuitiol ondition ui o O 2- dt uing Euler metho d NO -21 dt -tet2et-t2 3.t Lo

Matlab code for system of ODE using Eulers forward clear all close all &All Parameters 8functions for Euler equation solutioy-ul (0)- 0.000000 yext 0.000000 After 1 iteration y=u1 (0.10) = 0.000000 y ext 0.000009 After 2 iteration 000000 yul (0 yexty(t) vs. t plot 0.18 Euler solufon Exact Solution 0.16 0.14 0.12 0.1 0.08 0.06 004 0.02 0 n 1 02 03 0 4 0.5 0.6 0.9 t Publish

%%Matlab code for system of ODE using Euler's forward
clear all
close all
%All Parameters

%functions for Euler equation solution
f=@(u1,u2,t) u2;
g=@(u1,u2,t) 2*u2-u1+t*exp(t)-t;
%all step size
h=0.1;
%Initial values
u10=0;
u20=0;
t0=0;

%t end values
tend=1;
tn=t0:h:tend;
% Euler steps

u1_result(1)=u10;
u2_result(1)=u20;
t_result(1)=t0;

%exact solution
y_ext=@(t) (1/6).*t.^3.*exp(t)-t.*exp(t)+2.*exp(t)-t-2;     
        fprintf('\t y=u1(0)= %f\n',u1_result(1))
        fprintf('\t y_ext= %f\n\n',y_ext(t_result(1)))
    for i=1:length(tn)-1

        t_result(i+1)= t_result(i)+h;
        u1_result(i+1)=u1_result(i)+h*double(f(u1_result(i),u2_result(i),t_result(i)));
        u2_result(i+1)=u2_result(i)+h*double(g(u1_result(i),u2_result(i),t_result(i)));
        fprintf('After %d iteration \n',i)
        fprintf('\t y=u1(%2.2f)= %f\n',t_result(i+1),u1_result(i+1))
        fprintf('\t y_ext= %f\n\n',y_ext(t_result(i+1)))
      
    end
    %plotting the solution
    hold on
    plot(t_result,u1_result)
    plot(t_result,y_ext(t_result))
  
    xlabel('t')
    ylabel('y(t)')
    title('y(t) vs. t plot')
    legend('Euler solution','Exact Solution')
    box on
    grid on
    %%%%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%%%%%

Add a comment
Know the answer?
Add Answer to:
5. Consider the following second order IVP y2y te - t, 0 t1 y(0)/(0) 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