Solving coupled differential equations
35 views (last 30 days)
Show older comments
I am trying to solve the following coupled differential equation:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1363218/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1363223/image.png)
The goal is to obtain analytic solutions of
and
in terms of
, and
.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1363228/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1363233/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1363238/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1363243/image.png)
However, MATLAB doesn't seem to obtain the analytic solutions, as posted below. But I do think that we can get
and
in terms of
, and
. Is there any other way I can try to solve the problem in MATLAB (or analytically)?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1363248/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1363253/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1363258/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1363263/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1363268/image.png)
1 Comment
David Goodmanson
on 23 Apr 2023
Hi Jon,
In general there won't be an analytical solution, even if Int f(t) dt has an analytic expression. For y, you have the second order differential equation
y'' + y'(-f/f + gamma) + f^2 y = 0
(there is a similar expression for x''). This may or may not (and in most cases does not) have an analytic solution.
Answers (2)
Sam Chak
on 22 Apr 2023
Hi @Jon
I'm unsure if the system has a general analytical solution.
In Pure Math, from the properties of a stable 2nd-order ODE, if
,
and
is monotonically increasing, then the system will converge to the origin. Perhaps, the analytical solution exists for a certain type of
.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1363618/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1363623/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1363628/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1363633/image.png)
Here is a simple demonstration using 3 different monotonically increasing functions of
:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1363638/image.png)
Definition of state variables:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1363643/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1363648/image.png)
tspan = linspace(0, 20, 2001);
x0 = [1 0];
[t, x] = ode45(@odefcn, tspan, x0);
% Solution Plot
plot(t, x(:,1), 'linewidth', 1.5, 'color', '#528AFA'),
grid on, xlabel('t'), ylabel('x_{1}')
% Phase Portrait
plot(x(:,1), x(:,2), 'linewidth', 1.5, 'color', '#FA477A'),
grid on, xlabel('x_{1}'), ylabel('x_{2}')
function xdot = odefcn(t, x)
ft1 = tanh(t);
ft2 = t;
ft3 = t^3;
gamma = 1; % gamma > 0
xdot = zeros(2, 1);
xdot(1) = ft3*x(2); % <-- change to ft1, or ft2
xdot(2) = - ft3*x(1) - gamma*x(2); % <-- change to ft1, or ft2
end
2 Comments
Sam Chak
on 22 Apr 2023
syms y(t) x(t) gamma
sym('gamma', 'real');
assume(t > 0)
f(t) = sign(t);
eqns = [diff(y,t) == f(t)*x,
diff(x,t) == - f(t)*y - gamma*x];
sol = dsolve(eqns);
display(sol.y)
However, WolframAlpha shows that analytical solutions (click on the ODEs) exist for
and
Sam Chak
on 22 Apr 2023
Edited: Sam Chak
on 22 Apr 2023
Analytical solution:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1363898/image.png)
Click on the 2nd-order ODE to see the analytical solution and plots on WolframAlpha.
Note: By the way, this ODE can be rewritten in Sturm–Liouville form. Perhaps, if your problem can be transformed to become a Sturm–Liouville problem, then the analytical solution exists.
syms y(t) gamma
gamma = 2;
Dy = diff(y,t);
eqn = diff(y,t,2) + (gamma - 1)*Dy + exp(2*t)*y == 0;
cond = [y(0)==1, Dy(0)==0];
ySol(t) = dsolve(eqn, cond)
Numerical solution:
tspan = linspace(0, 10, 1001);
x0 = [1 0];
[t, x] = ode45(@odefcn, tspan, x0);
% Solution Plot
plot(t, x(:,1), 'linewidth', 1.5, 'color', '#528AFA'),
grid on, xlabel('t'), ylabel('x_{1}')
% Phase Portrait
plot(x(:,1), exp(t).*x(:,2), 'linewidth', 1.5, 'color', '#FA477A'),
ylim([-2 2]), grid on,
xlabel({'$y_{t}$'}, 'interpreter', 'latex', 'fontsize', 16),
ylabel({'$\dot{y}_{t}$'}, 'interpreter', 'latex', 'fontsize', 16)
function xdot = odefcn(t, x)
ft = exp(t);
gamma = 2; % gamma > 0
xdot = zeros(2, 1);
xdot(1) = ft*x(2); % <-- change to ft1, or ft2
xdot(2) = - ft*x(1) - gamma*x(2); % <-- change to ft1, or ft2
end
See Also
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!