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.
%Matlab code for solving 1st order ode using RK4 method and its
plot
clear all
close all
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%function for ode
f=@(t,y) -1.2.*y+7.*exp(-0.3.*t);
fprintf('For the function dy/dt= -1.2.*y+7.*exp(-0.3.*t)
\n')
%All values for solving the equation
%Euler Method for h=0.5
h=0.5;
% amount of intervals
t=0;
% initial t
y=3; %
initial y
t_eval=1.5; % at what
point we have to evaluate
n=(t_eval-t)/h; % Number of steps
t_val1(1)=t;
y_val1(1)=y;
fprintf('y(t) vs. t tabular form Euler Method\n')
fprintf('\tt=%2.2f \t y=%f\n',t,y)
for i=1:n
%Euler STEPS
dy=h*double(f(t,y));
t=t+h;
y=y+dy;
t_val1(i+1)=t;
y_val1(i+1)=y;
fprintf('\tt=%2.2f \t y=%f\n',t,y)
end
fprintf('\n\tThe solution using Euler Method for h=%.2f at t(%.2f)
is %f\n',h,t_val1(end),y_val1(end))
%function for exact solution
f_ext=@(t) (70/9).*exp(-0.3.*t)-(43/9).*exp(-1.2.*t);
fprintf('Exact solution\n')
for j=1:length(t_val1)
y_ext(j)=f_ext(t_val1(j));
fprintf('\tt=%2.2f \t
y=%f\n',t_val1(j),y_ext(j))
end
fprintf('\n\tThe Exact solution at t(%.2f) is %f\n',t_val1(end),y_ext(end))
%Rk2 solution
h=0.5;
% amount of intervals
t_in=0;
% initial t
y_in=3;
% initial y
[t_rk,y_rk]= RK2(f,t_in,y_in,t_eval,h);
fprintf('y(t) vs. t tabular form RK4 Method\n')
for j=1:length(t_rk)
fprintf('\tt=%2.2f \t
y=%f\n',t_rk(j),y_rk(j))
end
fprintf('\n\tThe RK2 solution for h=%f at t(%.2f) is %f\n',h,t_rk(end),y_rk(end))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%RK2 function for solving
function [t_rk,y_rk]= RK2(f,t_in,y_in,t_eval,h)
%h amount of intervals
%t_in initial t
%y_in initial y
%t_eval at what point we have to evaluate
n=(t_eval-t_in)/h; % Number of steps
t_rk(1)=t_in;
y_rk(1)=y_in;
for i=1:n
%RK2 Steps
k1=h*double(f(t_in,y_in));
k2=h*double(f((t_in+h/2),(y_in+k1/2)));
t_in=t_in+h;
y_in=y_in+k2;
t_rk(i+1)=t_in;
y_rk(i+1)=y_in;
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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 yl =0.3y y(3) = 0.2 (a) Use Euler's method to estimate y (-2with step size h 0.5 Give your approximation for y (-2)with a precision of ±0.01 y(2) Number (b) Use Euler's method to estimate y (-2)with step size h = 0.25 Give your approximation for y (-2)with a precision of ±0.01 y (-2) Number Consider the initial-value problem yl =0.3y y(3) = 0.2 (a) Use Euler's method to estimate y (-2with step size h 0.5...
(d) This part of question is concerned the use the Euler's method to solve the following initial-value problem dy dx4ar (i) Without using computer software, use Euler's method (described in Unit 2) with step size of 2, to find an approximate value y(2) of the given initial-value problem. Give your approximation to six decimal places. Clearly show all your working 6 (ii) Use Mathcad worksheet Έυ1er's method, associated with Unit 2 to computer the MATHCAD estimate solutions and absolute errors...
use matlab only please Problem # 1 P-1 Solve the following initial value problem using a4 order RK scheme: dy dx=tan(x), y(0)= 0.0 - Compare your results by calcudating the error andploting with the equation analytical solution y = In Isec(x)| for a = 0 to b = π/4 and step size 0.01 π: b- Solve the same problem with an accurate library scheme that can improve the answer 03 03 07 Problem # 1 P-1 Solve the following initial...
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...
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).
Use Euler's method with step size h = 0.2 to approximate the solution to the initial value problem at the points x = 4.2, 4.4, 4.6, and 4.8. y = {(V2+y),y(4)=1 Complete the table using Euler's method. xn Euler's Method 4.2 4.4 n 1 2 2 3 4.6 4 4.8 (Round to two decimal places as needed.)
Question 1: Given the initial-value problem 12-21 0 <1 <1, y(0) = 1, 12+10 with exact solution v(t) = 2t +1 t2 + 1 a. Use Euler's method with h = 0.1 to approximate the solution of y b. Calculate the error bound and compare the actual error at each step to the error bound. c. Use the answers generated in part (a) and linear interpolation to approximate the following values of y, and compare them to the actual value...
Question 19 1 pts Problem 19: Numerical solution of Ordinary differential equations Consider the following initial value problem GE: + 15y = + 1.C: y(0) 0.5 Using Euler's method, and a time step of At = 0.2. do you expect the numerical solution not to oscillate and to be stable? No, because the time step far exceeds the critical value At stable < 0.067 for this problem. None of the above Yes, because Euler's method is explicit and there is...
YOUR TEACHER Consider the initial-value problem y = (x + y - 1)?.Y(0) - 2. Use the improved Euler's method with h = 0.1 and h = 0.05 to obtain approximate values of the solution at x = 0.5. At each step compare the approximate value with the actual value of the analytic solution (Round your answers to four decimal places.) h 0.1 Y(0.5) h 0.05 Y(0.5) actual value Y(0.5) = Need Help? Tuto Tutor