Question

This Question: 1 pt Consider the initial value problem below to answer to following. a) Approximate the value of y(T) using E
0 0
Add a comment Improve this question Transcribed image text
Answer #1


SMatlab code for Eulers forward clear all close all %function for Euler equation solution f-e (t,y) -Y %exact solution y_exta) Approximate solution for del(t)-0.4 is y(4.00,-0.00604. b) The error in approximation to y(T) is 0.012269. c) Approximate

%%Matlab code for Euler's forward
clear all
close all
%function for Euler equation solution
f=@(t,y) -y;
%exact solution
y_ext=@(t) exp(-t);
%Initial values
t0=0; %initial t
y0=1; %initial y
%t_end values
t_end=4;
    %step size
    h=0.4;
    %x end values

    tn=t0:h:t_end;
    % Euler steps
    y_result(1)=y0;
    t_result(1)=t0;
    %loop for Euler method
        for i=1:length(tn)
            t_result(i+1)= t_result(i)+h;
            y_result(i+1)= y_result(i)+h*double(f(t_result(i),y_result(i)));
          
        end
fprintf('\ta) Approximate solution for del(t)=%0.1f is y(%2.2f)=%2.6f.\n',h,t_result(end-1),y_result(end-1))
err1=y_ext(t_end)-y_result(end-1);
fprintf('\tb) The error in approximation to y(T) is %2.6f.\n',err1);
%step size
    h=0.2;
    %x end values

    tn=t0:h:t_end;
    % Euler steps
    y_result(1)=y0;
    t_result(1)=t0;
    %loop for Euler method
        for i=1:length(tn)
            t_result(i+1)= t_result(i)+h;
            y_result(i+1)= y_result(i)+h*double(f(t_result(i),y_result(i)));
        end
fprintf('\tc) Approximate solution for del(t)=%0.1f is y(%2.2f)=%2.6f.\n',h,t_result(end-1),y_result(end-1))
err1=y_ext(t_end)-y_result(end-1);
fprintf('\t The error in approximation to y(T) is %2.6f.\n',err1);

fprintf('\td) halving the time steps results approximately halving the error.\n ')


%%%%%%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%%%%%%%%%

Add a comment
Know the answer?
Add Answer to:
This Question: 1 pt Consider the initial value problem below to answer to following. a) Approximate...
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
  • Consider the initial value problem below to answer to following. a) Find the approximations to y(0.3)...

    Consider the initial value problem below to answer to following. a) Find the approximations to y(0.3) and y(0.6) using Euler's method with time steps of At 0.3, 0.15, 0.075, and 0.0375 b) Using the exact solution given, compute the errors in the Euler approximations at t 0.3 and t 0.6. c) Which time step results in the more accurate approximation? Explain your observations. d) In general, how does halving the time step affect the error at t 0.3 and t...

  • Consider the initial value problem below to answer to following. a) Find the approximations to y(0.2)...

    Consider the initial value problem below to answer to following. a) Find the approximations to y(0.2) and y(0.4) using Euler's method with time steps of At 0.2, 0.1, 0.05, and 0.025 b) Using the exact solution given, compute the errors in the Euler approximations at t 0.2 and t 0.4. c) Which time step results in the more accurate approximation? Explain your observations. d) In general, how does halving the time step affect the error at t 0.2 and t...

  • Please explain and provide answers for parts a-c. Please round to five decimal places for all. Th...

    Please explain and provide answers for parts a-c. Please round to five decimal places for all. Thanks! omework: Week 09 Section 8.2 Homework 9 of 10 (10 complee) core: 0.2 of 1 pt 8.2.33 Consider the initial value problem below to answer to following a) Approximate the value of y(T) using Euler's method with the given time step on the interval [0,TI. b) Using the exact solution given, find the error in the approximation to y(T) (only at the right...

  • Consider the initial value problem y (t)-(o)-2. a. Use Euler's method with At-0.1 to compute appr...

    Please help with all the parts to the question Consider the initial value problem y (t)-(o)-2. a. Use Euler's method with At-0.1 to compute approximations to y(0.1) and y(0.2) b. Use Euler's method with Δ-0.05 to compute approximations to y(0.1) and y(02) 4 C. The exact solution of this initial value problem is y·71+4, for t>--Compute the errors on the approximations to y(0.2) found in parts (a) and (b). Which approximation gives the smaller error? a. y(0.1)s (Type an integer...

  • A use Euler's method with each of the following step sizes to estimate the value of y 0.4 where y...

    a use Euler's method with each of the following step sizes to estimate the value of y 0.4 where y is the solution of the initial value problem y -y, y 0 3 カー0.4 0.4) (i) y10.4) (in) h= 0.1 b we know that the exact solution of the initial value problem n part a s yー3e ra , as accurately as you can the graph of y e r 4 together with the Euler approximations using the step sizes...

  • Consider the following initial value problem: 1. Use Euler's explicit scheme to solve the above initial value probl...

    Consider the following initial value problem: 1. Use Euler's explicit scheme to solve the above initial value problem with time step h= 0.5. Express all the computed results with a precision of three decimal places. 2. The analytical or exact solution is compute the absolute error at each tivalue. Express all the computed results with a precision of three decimal places. 3. Write a matlab function that solves the above (IVP) using (RK2.M) for arbitrary time-step h. y(t) ly(0) 3...

  • Consider the initial value problem y′=sin(πt),y(3)=3. Use Euler's Method with five steps to approximate y(4) to...

    Consider the initial value problem y′=sin(πt),y(3)=3. Use Euler's Method with five steps to approximate y(4) to six decimal places (do not round intermediate results).

  • VOX) + Consider the initial value problem y' - 2x - 3y + 1, y(1) 9....

    VOX) + Consider the initial value problem y' - 2x - 3y + 1, y(1) 9. The analytic solution is 1 2 74 + -3x - 1) 3 9 (a) Find a formula involving c and h for the local truncation error in the nth step if Euler's method is used. (b) Find a bound for the local truncation error in each step ith-0.1 is used to approximate y(1.5). (Proceed as in Example 1 of Section 6.1.) (c) Approximate y(1.5)...

  • Consider the initial-value problem y' = 2x - 3y + 1, y(1) = 9. The analytic...

    Consider the initial-value problem y' = 2x - 3y + 1, y(1) = 9. The analytic solution is 1 2 74 -X + e-3(x - 1) 9 (a) Find a formula involving c and h for the local truncation error in the nth step if Euler's method is used. (b) Find a bound for the local truncation error in each step if h = 0.1 is used to approximate y(1.5). (Proceed as in Example 1 of Section 6.1.) (c) Approximate...

  • Consider the following initial value problem: 1. Use Euler's explicit scheme to solve the above initial value probl...

    Consider the following initial value problem: 1. Use Euler's explicit scheme to solve the above initial value problem with time step h= 0.5. Express all the computed results with a precision of three decimal places. 2. The analytical or exact solution is compute the absolute error at each ti value. Express all the computed results with a precision of three decimal places. 3. Write a matlab function that solves the above (IVP) using (RK2.M) for arbitrary time-step h. 0.3t 43...

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