I have three coupled differential equation and need help to solve them

4 views (last 30 days)
Initial condition: x(0) = 0.5, y(0)=0.9, z(0) = 7.5.
The problem is, I don't know how to call in Eq. 1. To solve these equations I am using ode45.
Kindly help me to solve this issue.
Thank you
  1 Comment
Star Strider
Star Strider on 24 Jun 2022
Because of the presence of t in the denominator, the system is not defined (appoaches ) at .
The system likely has no finite solution.

Sign in to comment.

Accepted Answer

Sam Chak
Sam Chak on 25 Jun 2022
The equations are rearranged. However, to simulate at , where division-by-zero occurs, I'm unable to comply.
syms x(t) y(t) z(t)
eqn1 = diff(x) == - (x/(4*t) + ((x^3)*z)/t + diff(z)) - y/t;
eqn2 = diff(y) == - (x*y/4 + (5*y/x)*diff(x)) - (x^4)/t;
eqn3 = diff(z) == - ((pi^2)/15)*(x/t + ((z^2)/x)*diff(x) - y/x);
eqns = [eqn1 eqn2 eqn3];
[V, S] = odeToVectorField(eqns) % convert to state equations for ode45 solver
V = 
S = 
Looking at the denominators, if , and , then singularities will occur at some points along this parabola of :
% Y1 = z(t), Y2 = x(t), Y3 = y(t)
sigma1 = @(x, z) 5926499560405365*z.^2 - 9007199254740992*x;
fimplicit(sigma1, [0 40 -8 8], 'LineWidth', 1.5)
grid on
xlabel({'$x(t)$'}, 'Interpreter', 'latex')
ylabel({'$z(t)$'}, 'Interpreter', 'latex')
Since the system cannot be simulated exactly at , and , then the initial sec is selected
odefcn = matlabFunction(V, 'vars', {'t', 'Y'})
odefcn = function_handle with value:
tspan = [1e-2 1.5]; % time span of simulation
y0 = [7.5 0.5 0.9]; % initial values: assumes z(1) = 7.5, x(1) = 0.5, y(1) = 0.9
opt = odeset('RelTol', 1e-4, 'AbsTol', 1e-6);
[t, Y] = ode45(@(t, Y) odefcn(t, Y), tspan, y0);
plot(t, Y, 'LineWidth', 1.25), grid on,
xlabel({'$t$'}, 'Interpreter', 'latex')
Captain Rituraj Singh
Captain Rituraj Singh on 8 Jul 2022
Dear @Sam Chak,
Thank you so much for the helping me. Please, can you tell me how to extract the value of x, y, and z from Y and store these values in a file against t. I shall be very grateful to you.
Thank you once again.

Sign in to comment.

More Answers (3)

Sam Chak
Sam Chak on 8 Jul 2022
After this line
[t, Y] = ode45(@(t, Y) odefcn(t, Y), tspan, D);
the ode45 solver will generate the solutions in the Y array with respect ro the time vector t. To extract the solutions in the form that you are familiar with, you can do this:
z = Y(:, 1); % because the odeToVectorField arranges them this way
x = Y(:, 2);
y = Y(:, 3);
and these solution vectors should appear on the Workspace. You can plot them if you wish
plot(t, x)
plot(t, y)
plot(t, z)
If you want to keep and store the data {t, x, y, z} in a mat-file, where you can load and access it later, then delete the rest in the Workspace and enter this command:
save Captain.mat
If you want to load the data, enter this:
load Captain.mat
If you like the support, consider voting 👍 this Answer above as a small token of appreciation.

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 24 Jun 2022
Your given exercise is a type of implicitly defined ODEs and thus, you should employ ode15i - see this doc.

Torsten on 24 Jun 2022
You have a linear system of equations in dx/dt, dy/dt and dz/dt.
Solve it for these variables. Then you can write your system explicitly as
dx/dt = f1(t,x,y,z)
dy/dt = f2(t,x,y,z)
dz/dt = f3(t,x,y,z)
and use ode45 to solve (maybe by starting at t=1e-6 instead of t=0).

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!