Question

In: Advanced Math

y' = 2 + t^2 + y^2 0<t<1 y(0)=0 use the euler method to determine step...

y' = 2 + t^2 + y^2 0<t<1 y(0)=0
use the euler method to determine step size (h) to keep global truncation error below .0001

Solutions

Expert Solution


clear all
close all

%function for which Euler method have to calculate
f=@(y,t) 2+t.^2+y.^2;
err=1;
N=10; count=0;
c1(1)=inf;
tol=0.0001;
while err>tol
  
    count=count+1;
    [y1_result,t_result] = euler_method(f,0,0,1,N);
    err=abs(c1(count)-y1_result(end));
    c1(count+1)=y1_result(end);
    N=N+1;
  
end
plot(t_result,y1_result)
xlabel('time')
ylabel('y(t)')
title('y(t) vs. t plot')
box on
fprintf('Step size required for error less than 0.0001 is %f\n',(1/N))

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

    %t end values
    tn=t0:h:tend;
    % Euler steps
    y1_result(1)=y0;
    t_result(1)=t0;
  
    for i=1:length(tn)-1
        t_result(i+1)= t_result(i)+h;
        y1_result(i+1)=y1_result(i)+h*double(f(y1_result(i),t_result(i)));
    end
end

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


Related Solutions

1313) Given the DEQ y'=1x-y^2*7/10. y(0)=8/2. Determine y(2) by Euler integration with a step size (delta_x)...
1313) Given the DEQ y'=1x-y^2*7/10. y(0)=8/2. Determine y(2) by Euler integration with a step size (delta_x) of 0.2. ans:1
1313) Given the DEQ y'=3x-y^2*7/10. y(0)=9/2. Determine y(2) by Euler integration with a step size (delta_x)...
1313) Given the DEQ y'=3x-y^2*7/10. y(0)=9/2. Determine y(2) by Euler integration with a step size (delta_x) of 0.2. ans:1
y'' - y = e^(-t) - (2)(t)(e^(-t)) y(0)= 1 y'(0)= 2 Use Laplace Transforms to solve....
y'' - y = e^(-t) - (2)(t)(e^(-t)) y(0)= 1 y'(0)= 2 Use Laplace Transforms to solve. Sketch the solution or use matlab to show the graph.
y′ = t, y(0) = 1, solution: y(t) = 1+t2/2 y′ = 2(t + 1)y, y(0)...
y′ = t, y(0) = 1, solution: y(t) = 1+t2/2 y′ = 2(t + 1)y, y(0) = 1, solution: y(t) = et2+2t y′ = 5t4y, y(0) = 1, solution: y(t) = et5 y′ = t3/y2, y(0) = 1, solution: y(t) = (3t4/4 + 1)1/3 For the IVPs above, make a log-log plot of the error of Backward Euler and Implicit Trapezoidal Method, at t = 1 as a function of hwithh=0.1×2−k for0≤k≤5.
y′ = t, y(0) = 1, solution: y(t) = 1+t2/2 y′ = 2(t + 1)y, y(0)...
y′ = t, y(0) = 1, solution: y(t) = 1+t2/2 y′ = 2(t + 1)y, y(0) = 1, solution: y(t) = et2+2t y′ = 5t4y, y(0) = 1, solution: y(t) = et5 y′ = t3/y2, y(0) = 1, solution: y(t) = (3t4/4 + 1)1/3 For the IVPs above, make a log-log plot of the error of Explicit Trapezoidal Rule at t = 1 as a function ofhwithh=0.1×2−k for0≤k≤5.
Use euler method to approiximate y(1) y' is given , solve for y. approiximate y(1) Create...
Use euler method to approiximate y(1) y' is given , solve for y. approiximate y(1) Create a table to show the approximate value of y(1) for each choice of h. y’ = -15y y(0) = 1 h = .25 h = .125 h = .0625 h = .03125
1- Use Heun’s method without iteration to solve ?2???2−0.5?+?=0 y(0) = 2 and y’(0) = 0...
1- Use Heun’s method without iteration to solve ?2???2−0.5?+?=0 y(0) = 2 and y’(0) = 0 solve from x = 0 to 3 using h = 0.2 (step size) present y values as a table versus x values (50p) Instructions about question 1: considering step size and interval for x it will not be reasonable to proceed through hand calculations. You may want to use excel or other software but you need to write down first 3 steps of the...
Consider the IVPs: (A) y'+2y = 1, 0<t<1 , y(0)=2. (B) y' = y(1-y), 0<t<1 ,...
Consider the IVPs: (A) y'+2y = 1, 0<t<1 , y(0)=2. (B) y' = y(1-y), 0<t<1 , y(0)=1/2. 1. For each one, do the following: a. Find the exact solution y(t) and evaluate it at t=1. b. Apply Euler's method with Δt=1/4 to find Y4 ≈ y(1). Make a table of tn, Yn for n=0,1,2,3,4. c. Find the error at t=1. 2. Euler's method is obtained by approximating y'(tn) by a forward finite difference. Use the backward difference approximation to y'(tn+1)...
a) ty’ −y/(1+T) = T,(T>0),y(1)=0 b) y′+(tanT)y=(cos(T))^2,y(0)=π2 Solve the above equations.
a) ty’ −y/(1+T) = T,(T>0),y(1)=0 b) y′+(tanT)y=(cos(T))^2,y(0)=π2 Solve the above equations.
T F If y' = 3y^(2) + 5y − 2 and y(1) = 0, then lim t→∞ y(t) = −2.
   T F If y'  = 3y^(2) + 5y − 2 and y(1) = 0, then lim t→∞ y(t) = −2.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT