Solving coupled differential equations
53 次查看(过去 30 天)
显示 更早的评论
I am trying to solve the following coupled differential equation:


The goal is to obtain analytic solutions of
and
in terms of
, and
.




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)?





1 个评论
David Goodmanson
2023-4-23
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.
回答(2 个)
Sam Chak
2023-4-22
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
.




Here is a simple demonstration using 3 different monotonically increasing functions of
:

Definition of state variables:


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 个评论
Sam Chak
2023-4-22
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
2023-4-22
编辑:Sam Chak
2023-4-22
Analytical solution:

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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!