Question

In: Advanced Math

For the initial-value problem, ?'(?) = ?? sin(5?) , ?(0) = 0.5, Use the Euler Method...

  1. For the initial-value problem, ?'(?) = ?? sin(5?) , ?(0) = 0.5,
  2. Use the Euler Method with step size of 0.1 to calculate the approximate solution for the

differential equation for the initial condition y(0) = 0.5 and plot the result on the direction

field graph you produced in paragraph 1. Then do the same for the results of using the Euler Method with step sizes of 0.01 and then 0.005.

  1. For the initial-value problem in paragraph 2 above, ?'(?) = ?? sin(5?) , ?(0) = 0.5,

find the approximate the value of y when x = 4 using the Euler Method for each of the three different step sizes you used in paragraph 2.

Type or write:
“For the Euler Method with a step size of 0.1, y(4) =”, followed by the answer accurate

to five decimal places.
“For the Euler Method with a step size of 0.01, y(4) =”, followed by the answer accurate

to five decimal places.
“For the Euler Method with a step size of 0.005, y(4) =”, followed by the answer accurate

to five decimal places.

  1. Use the fourth-order Runge-Kutta Method with step sizes of 0.1, 0.01, and 0.005 to calculate approximate solutions for the same initial-value problem as paragraphs 2 and 3 and plot these approximate solutions on the direction field graph.
    • Attach a direction field graph showing the fourth-order Runge-Kutta Method results using a step size of 0.1.
    • Attach a second direction field graph showing the fourth-order Runge-Kutta Method results using a step size of 0.01.
    • Attach a third direction field graph showing the fourth-order Runge-Kutta Method results using a step size of 0.005.
    • Type or write a brief explanation of what happens with the plots as the step size is reduced.
  2. For the initial-value problem in paragraphs 2 and 3 above, find the approximate the value of y when x = 4 using the fourth-order Runge-Kutta Method for each of the three different step sizes you used in paragraph 4.

Type or write:
“For the fourth-order Runge-Kutta Method with a step size of 0.1, y(4) =”, followed by

the answer accurate to five decimal places.
“For the fourth-order Runge-Kutta Method with a step size of 0.01, y(4) =”, followed by

the answer accurate to five decimal places.
“For the fourth-order Runge-Kutta Method with a step size of 0.005, y(4) =”, followed by

the answer accurate to five decimal places.

Solutions

Expert Solution

%Matlab code for numerical solution of ode using RK4 method
clear all
close all
%function for which Solution have to do
fun=@(x,y) exp(y).*sin(5*x);
%initial condition
xinit=0; yinit=0.5;
xend=4;
%all step sizes
hh=[0.1 0.01 0.005];
for i=1:3
    h=hh(i);
    [x_elr,y_elr]=euler_method(fun,yinit,xinit,xend,h);
    fprintf('\tUsing Euler, for h=%1.3f value of x(%2.2f) is %f\n',h,x_elr(end),y_elr(end))
    [x_rk4,y_rk4]=RK4(fun,yinit,xinit,xend,h);
    fprintf('\tUsing RK4, for h=%1.3f value of x(%2.2f) is %f\n',h,x_rk4(end),y_rk4(end))
  
end

plot(x_rk4,y_rk4,'linewidth',2)
hold on
plot(x_elr,y_elr,'--')

ylabel('x')
xlabel('y(x)')
title('x vs. y(x) plot')
legend('RK4 Solution','Euler Solution','location','best')

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%Matlab code for Euler's forward
function [t_result,y1_result] = euler_method(f,y0,t0,tend,h)
%function for Euler equation solution
  
    %all step size
    N=(tend-t0)/h;
    %Initial values

    %t end values
    tn=t0:h:tend;
    % Euler steps
    y1_result(1)=y0;
    t_result(1)=t0;
    fprintf('\n\tFor step size %2.2f\n',h)
    for i=1:length(tn)-1
        t_result(i+1)= t_result(i)+h;
        y1_result(i+1)=y1_result(i)+h*double(f(t_result(i),y1_result(i)));
        %fprintf('At x=%2.2f y(%2.2f)=%f\n',t_result(i+1),t_result(i+1),y1_result(i+1))
    end
end

%%Matlab function for Runge Kutta Method
function [t_rk,y_rk]=RK4(f,yinit,tinit,tend,h)
    % RK4 method
    % h amount of intervals
    t=tinit;         % initial t
    y=yinit;         % initial y
    t_eval=tend;     % at what point we have to evaluate
    n=(t_eval-t)/h; % Number of steps
    t_rk(1)=t;
    y_rk(1)=y;
    for i=1:n
    %RK4 Steps
       k1=h*double(f(t,y));
       k2=h*double(f((t+h/2),(y+k1/2)));
       k3=h*double(f((t+h/2),(y+k2/2)));
       k4=h*double(f((t+h),(y+k3)));
       dy=(1/6)*(k1+2*k2+2*k3+k4);
       t=t+h;
       y=y+dy;
       t_rk(i+1)=t;
       y_rk(i+1)=y;
    end
end
%%%%%%%%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%%%%%%%%%%%


Related Solutions

Calculate the Euler method approximation to the solution of the initial value problem at the given...
Calculate the Euler method approximation to the solution of the initial value problem at the given x-values. Compare your results to the exact solution at these x-values. y' = y+y^2; y(1) = -1, x = 1.2, 1.4, 1.6, 1.8
Initial Value Problem. Use Indeterminate Coefficients method for this problem: y'' - 4y = sin(x) where:...
Initial Value Problem. Use Indeterminate Coefficients method for this problem: y'' - 4y = sin(x) where: y(0) = 4 and y'(0) = 8
Find the solution of the initial-value problem. y'' + y = 3 + 5 sin(x), y(0)...
Find the solution of the initial-value problem. y'' + y = 3 + 5 sin(x), y(0) = 5, y'(0) = 8
Use the method of Undetermined Coefficients to find the solution of the initial value value problem:...
Use the method of Undetermined Coefficients to find the solution of the initial value value problem: y'' + 8y' + 20y = 9cos(2t) - 18e-4t, y(0) = 5. y'(0) = 0
Consider the following initial value problem. y''−4y = 0, y(0) = 0, y'(0) = 5 (a)...
Consider the following initial value problem. y''−4y = 0, y(0) = 0, y'(0) = 5 (a) Solve the IVP using the characteristic equation method from chapter 4. (b) Solve the IVP using the Laplace transform method from chapter 7. (Hint: If you don’t have the same final answer for each part, you’ve done something wrong.)
Consider the following initial value problem dy/dt = 3 − 2*t − 0.5*y, y (0) =...
Consider the following initial value problem dy/dt = 3 − 2*t − 0.5*y, y (0) = 1 We would like to find an approximation solution with the step size h = 0.05. What is the approximation of y(0.1)?
Consider the initial value problem given below. y'=x+4cos(xy), Y(0)=0 Use the improved​ Euler's method subroutine with...
Consider the initial value problem given below. y'=x+4cos(xy), Y(0)=0 Use the improved​ Euler's method subroutine with step size h=0.3 to approximate the solution to the initial value problem at points x= 0.0,0.3,0.6.....3.0
(3 pts) Solve the initial value problem 25y′′−20y′+4y=0, y(5)=0, y′(5)=−e2. (3 pts) Solve the initial value...
(3 pts) Solve the initial value problem 25y′′−20y′+4y=0, y(5)=0, y′(5)=−e2. (3 pts) Solve the initial value problem y′′ − 2√2y′ + 2y = 0, y(√2) = e2, y′(√2) = 2√2e2. Consider the second order linear equation t2y′′+2ty′−2y=0, t>0. (a) (1 pt) Show that y1(t) = t−2 is a solution. (b) (3 pt) Use the variation of parameters method to obtain a second solution and a general solution.
Use the Laplace transform to solve the given initial value problem. y′′−12y′−13y=0; y(0)=5, y′(0)= 23 Enclose...
Use the Laplace transform to solve the given initial value problem. y′′−12y′−13y=0; y(0)=5, y′(0)= 23 Enclose arguments of functions in parentheses. For example, sin(2x). y=      Differential Equations
Solve the initial value problem below using the method of Laplace transforms. ty''-4ty'+4y=20, y(0)=5 y'(0)=-6
Solve the initial value problem below using the method of Laplace transforms. ty''-4ty'+4y=20, y(0)=5 y'(0)=-6
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT