I need the matlab codes for following question
(1) (a). Solve the following second-order differential equations by a pair of first-order equations, xyʹʹ − yʹ − 8x3y3 = 0; with initial conditions y = 0.5 and yʹ = −0.5 at x = 1.
(b). Solve the problem in part (a) above using MATLAB built-in functions ode23 and ode45, within the range of 1 to 4, and compare with the exact solution of y = 1/(1 + x2)
[Hint: ode23 à 0.0456, ode45 à 0.0588]
(c). How can we improve the accuracy for the solutions obtained in parts (a) and (b) above?
%%Matlab code for solving ode
clear all
close all
%Answering question b.
%Initial conditions for ode
y0=[0.5;-0.5];
%minimum and maximum
x
xspan=[1 4];
%Solution of ODEs using
ode45 matlab function
sol1= ode45(@(x,y)
odefcn1(x,y), xspan, y0);
%Equally splitting x
into small intervals
x1 =
linspace(xspan(1),xspan(end),501);
%yy is the corresponding
x y v and z
yy1 =
deval(sol1,x1);
figure(1)
hold on
plot(x1,yy1(1,:),'linewidth',2)
%minimum and maximum
x
xspan=[1 4];
%Solution of ODEs using
ode45 matlab function
sol2= ode23(@(x,y)
odefcn1(x,y), xspan, y0);
%Equally splitting x
into small intervals
x1 =
linspace(xspan(1),xspan(end),501);
%yy is the corresponding
x y v and z
yy2 =
deval(sol2,x1);
figure(1)
plot(x1,yy2(1,:),'linewidth',2)
%exact solution
y_ext=@(x)
1./(1+x.^2);
plot(x1,y_ext(x1),'linewidth',2)
hold off
title('Plot for y(x) vs. x solution')
xlabel('x')
ylabel('y(x)')
legend('ode45','ode23','Exact solution')
box on
grid on
fprintf('\tAt x=%2.f solution using ode45 is
%2.5f.\n',x1(end),yy1(1,end))
fprintf('\n\tAt x=%2.f solution using ode23 is
%2.5f.\n',x1(end),yy2(1,end))
fprintf('\n\tAt x=%2.f solution using exact analytic is
%2.5f.\n',x1(end),y_ext(x1(end)))
%Function for evaluating the ODE
function dydx = odefcn1(x,y)
eq1= y(2);
eq2= (y(2)./x)+8.*x.^2.*(y(1)).^3;
%Evaluate the ODE for our present problem
dydx = [eq1;eq2];
end
%----------------------------End of Code-----------------------------%
I need the matlab codes for following question (1) (a). Solve the following second-order differential equations by a pair of first-order equations, xyʹʹ − yʹ − 8x3y3 = 0; with initial conditions y = 0...
Matlab Code for these please. 4. Using inbuilt function in MATLAB, solve the differential equations: dx --t2 dt subject to the condition (01 integrated from0 tot 2. Compare the obtained numerical solution with exact solution 5. Lotka-Volterra predator prey model in the form of system of differential equations is as follows: dry dt dy dt where r denotes the number of prey, y refer to the number of predators, a defines the growth rate of prey population, B defines the...
solve it with matlab 25.24 Given the initial conditions, y(0) = 1 and y'(0) = 1 and y'(0) = 0, solve the following initial-value problem from t = 0 to 4: dy + 4y = 0 dt² Obtain your solutions with (a) Euler's method and (b) the fourth- order RK method. In both cases, use a step size of 0.125. Plot both solutions on the same graph along with the exact solution y = cos 2t.
write MATLAB scripts to solve differential equations. Computing 1: ELE1053 Project 3E:Solving Differential Equations Project Principle Objective: Write MATLAB scripts to solve differential equations. Implementation: MatLab is an ideal environment for solving differential equations. Differential equations are a vital tool used by engineers to model, study and make predictions about the behavior of complex systems. It not only allows you to solve complex equations and systems of equations it also allows you to easily present the solutions in graphical form....
solve using matlab or by hand. For the following differential equation, answer the questions. -y"+y=x (0.0 SX 35.0) y(0.0)=1.0, y(5.0)= 2.0 (1) Solve the differential equation analytically. (2) Solve the differential equation using centered finite difference approximation of y" with a step size of 1.0 and check the accuracy of the solutions.
Need help using Matlab to solve differential equations, will rate! Thank You! a) The code used to solve each problem b) The output form c) Use EZPLOT (where possible) to graph the result Use Matlab symbolic capabilities to solve the following Differential Equations: yy +36x = 0 3. ytky = e2kakis a constant y" +(x +1)y = ex'y' ;y(0) = 0.5 4 4y-20y'+25y = 0 xy-7x/+16y=0 xy-2xy'+2y=x' cos(x) yy =292 y-4y'+4y = (x + 1)e 2x
///MATLAB/// Consider the differential equation over the interval [0,4] with initial condition y(0)=0. 3. Consider the differential equation n y' = (t3 - t2 -7t - 5)e over the interval [0,4 with initial condition y(0) = 0. (a) Plot the approximate solutions obtained using the methods of Euler, midpoint and the classic fourth order Runge Kutta with n 40 superimposed over the exact solution in the same figure. To plot multiple curves in the same figure, make use of the...
A system of two first order differential equations can be written as 0 dc A second order explicit Runge-Kutta scheme for the system of two first order equations is Consider the following second order differential equation 7+4zy 4, with y(1)-1 and y'(1)--1. Use the Runge-kutta scheme to find an approximate solution of the second order differential equation, at x = 1.2, if the step size h Maintain at least eight decimal digit accuracy throughout all your calculations You may express...
Need help solving these two second order differential equations, the picture below are the answers to them. I'm just stuck on how to work them out to get those solutions 3 Assignments 3.1 Analysis in the absence of air resistance Ignoring alr resistance, Newton's equations of motion for an object under the influence of gravity alone are quite straightforward. We're also ignoring the fact that the gravitational pull on an object above the earth depends upon its height above the...
4. MATLAB can solve second order equations numerically, but it needs to convert it to a sys- tem first. We haven't covered systems yet, but we can make use of them (entirely in MAT- LAB) to solve this problem. The help page https://www.mathworks.com/help/symbolic/ solve-differential-equation-numerically-1.html shows how to do this. Follow those steps to get the solution to day +9y = cos(3) dt2 y(0) = 0 v(0) = 0 Plot this and your solution from the previous part on the same...
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...