The differential equation : dy/dx = 2x -3y , has the initial conditions that y = 2 , at x = 0
Obtain a numerical solution for the differential equation, correct to 6 decimal place , using ,
%%Matlab code for Euler and RK4 method
clear all
close all
%Function for which solution have to do
f=@(x,y) 2*x-3*y;
fprintf('\n\tEuler Method for step size h=%.2f\n',0.2)
%Euler method
h=0.2;
% amount of intervals
x=0;
% initial x
y=2;
% initial y
x_eval=1; % at what point
we have to evaluate
n=(x_eval-x)/h; % Number of steps
x2(1)=x;
y2(1)=y;
fprintf(' At x(%.2f) solution of y is
%f\n',x,y)
for i=1:n
%Eular Steps
m=double(f(x,y));
x=x+h;
y=y+h*m;
x2(i+1)=x;
y2(i+1)=y;
fprintf(' At x(%.2f)
solution of y is %f\n',x,y)
end
fprintf('\n\tThe solution using Euler Method for
h=%.2f at x(%.1f) is %f\n',h,x2(end),y2(end))
%RK4 method
fprintf('\n\tRK4 Method for step size
h=%.2f\n',0.2)
x=0;
% initial x
y=2;
% initial y
x_eval=1; % at what point
we have to evaluate
n=(x_eval-x)/h; % Number of steps
x4(1)=x;
y4(1)=y;
fprintf(' At x(%.2f) solution of y is
%f\n',x,y)
for i=1:n
%RK4 Steps
k1=h*double(f(x,y));
k2=h*double(f((x+h/2),(y+k1/2)));
k3=h*double(f((x+h/2),(y+k2/2)));
k4=h*double(f((x+h),(y+k3)));
dx=(1/6)*(k1+2*k2+2*k3+k4);
x=x+h;
y=y+dx;
x4(i+1)=x;
y4(i+1)=y;
fprintf(' At x(%.2f) solution
of y is %f\n',x,y)
end
fprintf('\n\tThe solution using Runge Kutta 4
for h=%.2f at x(%.1f) is %f\n',h,x4(end),y4(end))
%%Plotting solution using Euler method
figure(1)
hold on
plot(x2,y2,'Linewidth',2)
plot(x4,y4,'Linewidth',2)
xlabel('x')
ylabel('y(x)')
title('Solution plot y vs. x')
legend('Euler Method','RK4 Method','Location','northeast')
grid on
%%%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%%%
The differential equation : dy/dx = 2x -3y , has the initial conditions that y = 2 , at x = 0 Obt...
Help with these questions please. A mathematical model has been described by an engineer into the following differential equation: dy dx y(0) 2.5 Demonstrate an Euler method simulation of y versus x with a tabular algorithm using Ax 0.5 and 0.0 X 3.0. Demonstrate a 4th-order Runge Kutta method simulation of y versus x with a tabular algorithm using What can you say about y(x) and the methods used? a. b. Ax 0.5 and 0.0 3.0 x c. A mathematical...
Using the Runge-Kutta fourth-order method, obtain a solution to dx/dt=f(t,x,y)=xy^3+t^2; dy/dt=g(t,x,y)=ty+x^3 for t= 0 to t= 1 second. The initial conditions are given as x(0)=0, y(0) =1. Use a time increment of 0.2 seconds. Do hand calculations for t = 0.2 sec only.
Question 4 A mathematical model has been described by an engineer into the following differential equation: dy 0.5x0 dx y(0) 2.5 Demonstrate an Euler method simulation of y versus x with a tabular algorithm using a. 0.5 and 0.0 3.0. x Demonstrate a 4th-order Runge Kutta method simulation of y versus x with a tabular b. algorithm using дх-0.5 and 0.0 XS 3.0. What can you say about y(x) and the methods used? c. Question 4 A mathematical model has...
Solve the system of differential equations dx/dt = x-y, dy/dt = 2x+y subject to the initial conditions x(0)= 0 and y(0) = 1.
3. Consider the differential equation dy 2x2y dx 0, y 1 In the following questions work to 4 decimal places with the initial conditions x = throughout and give your answer to 3 decimal places, or use exact fractions (a) Use the Euler method to calculate an estimate of the value of y after four steps of length h 0.5 [4 marks] (b) Use the Modified Euler method to calculate an estimate of the value of y after two steps...
The solution of the differential equation X dy dx – 3y = x sin2x + x4-4x5 is y - "Cos2x = *sin2x+*+-2x + cx True False
(2x+ 2 x y²) dx + ( x ²) - 3y) dy = 0 solve your equation
Given (dy/dx)=(3x^3+6xy^2-x)/(2y) with y=0.707 at x= 0, h=0.1 obtain a solution by the fourth order Runge-Kutta method for a range x=0 to 0.5
Problem Thre: 125 points) Consider the following initial value problem: dy-2y+ t The y(0) -1 ea dt ical solution of the differential equation is: y(O)(2-2t+3e-2+1)y fr exoc the differential equation numerically over the interval 0 s i s 2.0 and a step size h At 0.5.A Apply the following Runge-Kutta methods for each of the step. (show your calculations) i. [0.0 0.5: Euler method ii. [0.5 1.0]: Heun method. ii. [1.0 1.5): Midpoint method. iv. [1.5 2.0): 4h RK method...
Find the solution of the differential equation with the given initial condition. Dy/dx = 2x + sec^2x/2y, y(0) = 5.