Numerical Methods for Differential Equations - Please post full correct solution!!! - need to use MATLAB
We have developed a MATLAB code for the given problem.
-------------------------MATLAB Code-------------------------
f=@(x,y) -0.5*y.^3; % f(x,y)
fe=@(x) 1./(sqrt(1+x)); % exact function
a=0;
y0=1;
b=1;
stepsize=[1/40 1/80];
yexact=fe(b);
for i=1:2
h=stepsize(i);
tic;[x1,y_eul]=euler(f,a,y0,b,h);T1=toc;
fprintf('\n\nEuler method: stepsize=%g\n',h);
fprintf('---------------------------------------------\n');
fprintf('y(%g)=%.8f\t error=%.10f\t Time=%g
sec\n',b,y_eul,abs(y_eul-yexact),T1);
tic;[x2,y_mod]=eulermodified(f,a,y0,b,h);T2=toc;
fprintf('\n\nModified Euler method: stepsize=%g\n',h);
fprintf('---------------------------------------------\n');
fprintf('y(%g)=%.8f\t error=%.10f\t Time=%g
sec\n',b,y_mod,abs(y_mod-yexact),T2);
tic;[x3,y_imp]=eulerimproved(f,a,y0,b,h);T3=toc;
fprintf('\n\nImproved Euler method: stepsize=%g\n',h);
fprintf('---------------------------------------------\n');
fprintf('y(%g)=%.8f\t error=%.10f\t Time=%g
sec\n',b,y_imp,abs(y_imp-yexact),T3);
tic;[x4,y_rk4]=RK4(f,a,y0,b,h);T4=toc;
fprintf('\n\nRK4 method: stepsize=%g\n',h);
fprintf('---------------------------------------------\n');
fprintf('y(%g)=%.8f\t error=%.10f\t Time=%g
sec\n',b,y_rk4,abs(y_rk4-yexact),T4);
end
function [x,y]=euler(f,a,y0,b,stepsize)
h=stepsize;
xn=a:h:b;
yn=0*xn; % initializing the array;
yn(1)=y0;
for i=1:numel(xn)-1
yn(i+1)=yn(i)+h*f(xn(i),yn(i));
end
x=xn(end);
y=yn(end);
end
function [x,y]=eulermodified(f,a,y0,b,stepsize)
h=stepsize;
xn=a:h:b;
yn=0*xn; % initializing the array;
yn(1)=y0;
for i=1:numel(xn)-1
yp=yn(i)+h*f(xn(i),yn(i));
yn(i+1)=yn(i)+h*f(xn(i)+0.5*h,yp);
end
x=xn(end);
y=yn(end);
end
function [x,y]=eulerimproved(f,a,y0,b,stepsize)
h=stepsize;
xn=a:h:b;
yn=0*xn; % initializing the array;
yn(1)=y0;
for i=1:numel(xn)-1
yp1=f( xn(i),yn(i) );
yp2=f( xn(i+1),yn(i)+h*yp1 );
yn(i+1)=yn(i)+0.5*h*( yp1+yp2 );
end
x=xn(end);
y=yn(end);
end
function [x,y]=RK4(f,a,y0,b,stepsize)
h=stepsize;
xn=a:h:b;
yn=0*xn; % initializing the array;
yn(1)=y0;
for i=1:numel(xn)-1
k1 = f(xn(i),yn(i));
k2 = f(xn(i)+0.5*h,yn(i)+0.5*h*k1);
k3 = f((xn(i)+0.5*h),(yn(i)+0.5*h*k2));
k4 = f((xn(i)+h),(yn(i)+k3*h));
yn(i+1) = yn(i) + (1/6)*(k1+2*k2+2*k3+k4)*h;
end
x=xn(end);
y=yn(end);
end
-------------------------MATLAB Output-------------------------
Numerical Methods for Differential Equations - Please post full correct solution!!! - need to use MATLAB...
Is it possible to do this without matlab? 3In modelling the velocity y of a chain slipping off a horizontal platform, the differential equation y'- 10/y - y/x is derived. Suppose the initial condition is y (1)1 (a) Euler's method for solving y-f(x,y), y(XO-yo, is given byYn+1-yn+hf(xn,Yn) where h is a fixed stepsize, xnxo nh, and yn ~y(x). Apply one step of Euler's method to the initial value problem given above (b) Apply one step of the improved Euler method...
Please show MATLAB code for how to gain solution. 10.1 Consider the following first-order ODE: from x -0 to 2.1 with (0) 2 (a) Solve with Euler's explicit method using h 0.7. (b) Solve with the modified Euler method using h - 0.7. r Runge-Kutta method using h 0.7. The analytical solution of the ODE is24. In each part, calculate the eror between the true solution and the numerical solution at the points where the numerical solution is determined
hand written solution only (not computerised) if not possible then please refund the question becs i have already recieved a computerised solution from you but i dont understand. 3In modelling the velocity y of a chain slipping off a horizontal platform, the differential equation y, 10/y-y/x is derived. Suppose the initial condition is y( 1-1 (a) Euler's method for solving yf(x), y(xoyo, is given by yn+n+hf(an,yn), where h is a fixed stepsize, xn xo + nh, and yn y(xn). Apply...
MATLAB HELP 3. Consider the equation y′ = y2 − 3x, where y(0) = 1. USE THE EULER AND RUNGE-KUTTA APPROXIMATION SCRIPTS PROVIDED IN THE PICTURES a. Use a Euler approximation with a step size of 0.25 to approximate y(2). b. Use a Runge-Kutta approximation with a step size of 0.25 to approximate y(2). c. Graph both approximation functions in the same window as a slope field for the differential equation. d. Find a formula for the actual solution (not...
Matlab & Differential Equations Help Needed I need help with this Matlab project for differential equations. I've got 0 experience with Matlab other than a much easier project I did in another class a few semesters ago. All we've been given is this piece of paper and some sample code. I don't even know how to begin to approach this. I don't know how to use Matlab at all and I barely can do this material. Here's the handout: Here's...
1 st s2, y(1)1 The exact solution is given by yo) - = . 1+Int Write a MATLAB code to approximate the solution of the IVP using Midpoint (RK2) and Modified Euler methods when h [0.5 0.1 0.0s 0.01 0.005 0.001]. A) Find the vector w mid and w mod that approximates the solution of the IVP for different values of h. B) Plot the step-size h versus the relative error of both in the same figure using the LOGLOG...
Use Improved Euler for first question, Runge- Katta for 2nd one. Thank you In each of Problems 7 through 12, find approximate values of the solution of the given initial value problem at t-0.5,1.0, 1.5, and 2.0 (a) Use the improved Euler method with h 0.025 (b) Use the improved Euler method with h-0.0125 In each of Problems 7 through 12, find approximate values of the solution of the given initial value problem at0.5,1.0, 1.5, and 2.0. Compare the results...
PLEASE PLEASE,ONLY ANSWER THIS QUESTION IF YOU COULD GIVE ME THE MATLAB CODE.THANK YOU. Consider the following Ordinary Differential Equation (ODE): dy = 3.0*** + 1.08 * 210 – 3* y2 dat with initial condition at point xo = 0.375: Yo = 0.0044 Apply Runge-Kutta method of the second order with h = 0.25 and the set of parameters given below to approximate the solution of the ODE at the three points given in the table below. Fill in the...
Numerical methods for engineers (30%) ORDINARY DIFFERENTIAL EQUATIONS Solve ODE dy/dx-3xy, where xo-1; yo-2, with step size h-0.1, (calculate only the first point, ie at x,-1.1 yiz?, )using (a) Euler's method (b) Heun's method (b) Fourth-order RK's method 4"
Numerical Methods Consider the following IVP dy=0.01(70-y)(50-y), with y(0)-0 (a) [10 marks Use the Runge-Kutta method of order four to obtain an approximate solution to the ODE at the points t-0.5 and t1 with a step sizeh 0.5. b) [8 marks Find the exact solution analytically. (c) 7 marks] Use MATLAB to plot the graph of the true and approximate solutions in one figure over the interval [.201. Display graphically the true errors after each steps of calculations. Consider the...