Homework Solution: For the questions below, use MATLAB to solve the ODE using the Runge-Kutta numerical metho…

    4. For the questions below, use MATLAB to solve the ODE using the Runge-Kutta numerical methods. Use step sizes h-0.1 and h-0.05 to approximate to five decimal places the values x(1) and y(1). Compare the approximations with the actual values. x(0) = 0 y(0) = 0 x, = x + 2y y = x + e-t x(t) =름 (2e21-2c + 6e-t)
    For the questions below, use MATLAB to solve the ODE using the Runge-Kutta numerical methods. Use step sizes h = 0.1 and h = 0.05 to approximate to five decimal places the values x(1) and y(1). Compare the approximations with the actual values. X' = x + 2 y x(0) = 0 y' = x + e^-t y(0) = 0 x(t) = 1/9 (2e^2t - 2e^-t + 6e^-t) y(t) = 1/9(e^2t - e^-t + 6te^-t)

    Expert Answer

     
    %% 4
    % Solve x'= x + 2y  with x0=0,y'= x+ e-twith y(0)=0

    4. Restraint the questions underneath, authentication MATLAB to work-out the ODE using the Runge-Kutta numerical methods. Authentication tramp greatnesss h-0.1 and h-0.05 to approach to five decimal places the treasures x(1) and y(1). Compare the approximations with the objective treasures. x(0) = 0 y(0) = 0 x, = x + 2y y = x + e-t x(t) =름 (2e21-2c + 6e-t)

    Restraint the questions underneath, authentication MATLAB to work-out the ODE using the Runge-Kutta numerical methods. Authentication tramp greatnesss h = 0.1 and h = 0.05 to approach to five decimal places the treasures x(1) and y(1). Compare the approximations with the objective treasures. X’ = x + 2 y x(0) = 0 y’ = x + e^-t y(0) = 0 x(t) = 1/9 (2e^2t – 2e^-t + 6e^-t) y(t) = 1/9(e^2t – e^-t + 6te^-t)

    Expert Counterpart

     

    %% 4
    % Work-out x'= x + 2y  with x0=0,y'= x+ e-twith y(0)=0
    y0 = 0;                  % Initial Requisite
    h=0.1;                   % Time tramp
    t = 0:h:0.05;               % t goes from 0 to 2 seconds.
    yexact = x+ e ** -t     % Exact key (in public we will not perceive this
    ystar = zeros(size(t));  % Preallocate adorn (good-tempered coding exercitation)
    
    ystar(1) = y0;           % Initial requisite gives key at t=0.
    restraint i=1:(length(t)-1)
      k1 = 1/9(2*e ** 2*t - 2*e** -t + 6^ e** -t) ;             % Approx restraint y gives approx restraint deriv
      y1 = 1/9(e ** 2*t - e** -t + 6^t* e** -t);
    
            % Included treasure
      k2 = x+2*y;                    % Approx deriv at included treasure.
      ystar(i+1) = x+e**-t; % Approach key at next treasure of y
    end