Question

In: Advanced Math

Use eulers Method with step size h=.01 to approximate the solution to the initial value problem...

Use eulers Method with step size h=.01 to approximate the solution to the initial value problem y'=2x-y^2, y(6)=0 at the points x=6.1, 6.2, 6.3, 6.4, 6.5

Solutions

Expert Solution


%%Matlab code for Euler method
clear all
close all
%Function for ode
f=@(x,y) 2.*x-y.^2;
%step size
h=0.01;
%x intervals
x_in=6; x_end=7;
%initial y
y_in=0;
%equally spaced interval
x_int=6.1:0.1:6.5;

%creating the table for Euler solution
[x,y]=euler(f,x_in,x_end,y_in,h);
for j=1:length(x_int)
      
        p=find(abs(x-x_int(j))<10^-5);
        y_data=y(p);
        fprintf('\tAt x=%f value of y(%f) is %f\n',x(p),x(p),y(p))
      
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Function for Euler ode solution
%Euler method
function [x,y]=euler(f,x_in,x_end,y_in,h)
    %function (i)
    %f=@(x,y) 50*exp(-10*x)-2*y;
    %initial and final x
    %x_in=0; x_end=2;
    %y_in=40;
    %initial conditions
    x(1)=x_in; y(1)=y_in;        
    x_max=x_end;       %Final x
    N=(x_max-x_in)/h; %number of steps
    %Euler iterations
    for i=1:N   
        x(i+1)=x_in+i*h;
        y(i+1)=double(y(i)+h*(f(x(i),y(i))));
    end
end

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


Related Solutions

Use Eulers method to find approximate values of the solution of the given initial value problem...
Use Eulers method to find approximate values of the solution of the given initial value problem at T=0.5 with h=0.1. 12. y'=y(3-ty) y(0)=0.5
Compute, by Euler’s method, an approximate solution to the following initial value problem for h =...
Compute, by Euler’s method, an approximate solution to the following initial value problem for h = 1/8 : y’ = t − y , y(0) = 2 ; y(t) = 3e^(−t) + t − 1 . Find the maximum error over [0, 1] interval.
use the method of order two to approximate the solution to the following initial value problem...
use the method of order two to approximate the solution to the following initial value problem y'=e^(t-y),0<=t<=1, y(0)=1, with h=0.5
Use Euler's Method with step size 0.11 to approximate y (0.55) for the solution of the...
Use Euler's Method with step size 0.11 to approximate y (0.55) for the solution of the initial value problem    y ′ = x − y, and y (0)= 1.2 What is y (0.55)? (Keep four decimal places.)
Use power series approximations method to approximate the solution of the initial value problem: y"− (1+...
Use power series approximations method to approximate the solution of the initial value problem: y"− (1+ x) y = 0 y(0) = 1 y'(0) = 2 (Write all the terms up to the power ). x^4
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
Using Runge-Kutta method of order 4 to approximate y(1) with step size h = 0.1 and...
Using Runge-Kutta method of order 4 to approximate y(1) with step size h = 0.1 and h = 0.2 respectively (keep 8 decimals): dy/dx = x + arctan y, y(0) = 0. Solutions: when h = 0.1, y(1) = 0.70398191. when h = 0.2, y(1) = 0.70394257.
Use the Runge-Kutta method with step sizes h = 0.1, to find approximate values of the...
Use the Runge-Kutta method with step sizes h = 0.1, to find approximate values of the solution of y' + (1/x)y = (7/x^2) + 3 , y(1) = 3/2 at x = 0.5 . And compare it to thee approximate value of y = (7lnx)/x + 3x/2
Use the finite difference method and the indicated value of n to approximate the solution of...
Use the finite difference method and the indicated value of n to approximate the solution of the given boundary-value problem. (Round your answers to four decimal places.) x2y'' + 3xy' + 5y = 0,    y(1) = 6,  y(2) = 0;  n = 8 x y    1.000 ? 1.125 ? 1.250 ? 1.375 ? 1.500 ? 1.625 ? 1.750 ? 1.875 ? 2.000 ?
Use the method of steepest ascent to approximate the optimal solution to the following problem: max⁡...
Use the method of steepest ascent to approximate the optimal solution to the following problem: max⁡ z=-(x1-2)^2-x1-(x2)^2 . Begin at the point(2.5,1.5) (p.s. The answer already exists on the Chegg.Study website is incorrect)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT