Problem 1:
Programming code in MATLAB
---------------------- ode45
---------------------- let
f=@(t,y) [ y(1)-y(2); -y(1)-y(2)];
tspn=[0 1];
y0=[0 4];
tol=10^(-6);
[t,ya]=ode45(f,tspn,y0,tol);
disp('using ode45 :');
disp(ya(end,:));
--------------------- Euler method
h=0.1;
t1=0:h:1;
%%% let x=y(1), y=y(2)
f1=@(x ,y) x-y;
f2=@(x ,y) -x-y;
x(1)=0;
y(1)=4;
for k=1:length(t1)
x(k+1)=x(k)+h*feval(f1,x(k),y(k));
y(k+1)=y(k)+h*feval(f2,x(k),y(k));
end
sol=[x(end) y(end)];
disp('using Eular :');
disp(sol);
err=sum((ya(end,:)-[x(end) y(end)]).^2);
fprintf('Error in vector : %f \n',err);
MATLAB O/P:
using ode45 :
-5.4732 3.2395
using Euler :
-5.7950 3.1479
Error in vector : 0.111941
---------------------- Exact solution
clc;
clear all;
close all;
syms s
A=[1 -1;-1 -1];
x0=[0;4];
tf=s*eye(2)-A;
gh=ilaplace(inv(tf)*x0);
subs(gh,1)
disp('Exact solution :');
disp(gh);
disp('at t=1');
sol=subs(gh,1);
fprintf('solution is[%f , %f ] : \n',sol(1),sol(2));
MATLAB O/P:
ans =
-2*2^(1/2)*sinh(2^(1/2))
4*cosh(2^(1/2)) - 2*2^(1/2)*sinh(2^(1/2))
Exact solution :
-2*2^(1/2)*sinh(2^(1/2)*t)
4*cosh(2^(1/2)*t) - 2*2^(1/2)*sinh(2^(1/2)*t)
at t=1
solution is[-5.473195 , 3.239539 ] :
>> err
Problem 1. (15 points) Solve the following system of ODEs using your Euler implementation and ode...
6. The differential equation: y 4y 2x y(0) 1/16 has the exact solution given by the following equation: v = (1 /2)s, + (14)s +1.16 Calculate y (2.0) using a step size h-0.5 using the following methods: (a) Euler (b) Euler P-c (c)4h order Runge-Kutta (d) Compare the errors for each method. (e) Solve using Matlab's ode45.m function. Include your code and a print of the solution.
(d)A first-order system is described by the following differential equation +24x(t) = r(1) dī i) Discretize the system using (a) forward (Euler) approximation, and (b) backward (Euler) approximation, respectively, with a sampling time of T - 0.1 for both. Write down the two resulting systems as difference equations. 20% (ii) Check the stability of the continuous-time system described by equation (2) 10% (iii) Discuss the stability of the above two discretised systems obtained in (d(i)). Explain how to choose the...
Problem 8 [5 points The following system of ODEs, formulated by Lorenz, represents are crude model of atmospheric circulation: Set σ-10, b = 8/3, r 28, take initial values yi (0) 15, 32(0) 15, and y3(0) 36, and integrate this ODE from t 0 to t 100 using Matlab's ode45. Plot each component of the solution as a function of t. Plot also (yi,2), (Ji. U3), and (2,y3) in separate plots). Change the initial values by a tiny amount (e.g....
Problem 2. Solve the following pair of ODEs over the interval from 0 to 0.4 using a step size of 0.1. The initial conditions are (0)-2 and (0) 4. Obtain your solution with (a) Euler's method and (b) the fourth-order RK method. Display your results as a plot. dy =-2y+Sze dt dz dt 2
The Program for the code should be matlab 5. [25 pointsl Given the initial value problem with the initial conditions y(0) 2 and y'(0)10, (a) Solve analytically to obtain the exact solution y(x) (b) Solve numerically using the forward Euler, backward Euler, and fourth-order Runge Kutta methods. Please implement all three methods yourselves do not use any built- in integrators (i.e., ode45)). Integrate over 0 3 r < 4, and compare the methods with the exact solution. (For example, using...
Please show me the steps to solve this problem using both backward and forward Euler Question 44 4/4 pts Given the ODE with initial condition x' (t) = 3x +t, «(1) = 2 We solve it with implicit backward Euler method, using time step h=0.1. What is the approximate solution for x(1.1)? 2.8745 0 3.62 3.0143 0 2.7
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...
Differential Equations 1. (10 points) Identify the equation and solve it. 2. (10 points) Solve the following initial value problem 3.(5 points) Solve the following exact equation. (Solve it by using the method for exact equations)
Need help with this MATLAB problem: Using the fourth order Runge-Kutta method (KK4 to solve a first order initial value problem NOTE: This assignment is to be completed using MATLAB, and your final results including the corresponding M- iles shonma ac Given the first order initial value problem with h-time step size (i.e. ti = to + ih), then the following formula computes an approximate solution to (): i vit), where y(ti) - true value (ezact solution), (t)-f(t, v), vto)...
a can be skipped Consider the following second-order ODE representing a spring-mass-damper system for zero initial conditions (forced response): 2x + 2x + x=u, x(0) = 0, *(0) = 0 where u is the Unit Step Function (of magnitude 1). a. Use MATLAB to obtain an analytical solution x(t) for the differential equation, using the Laplace Transforms approach (do not use DSOLVE). Obtain the analytical expression for x(t). Also obtain a plot of .x(t) (for a simulation of 14 seconds)...