
Getting a solution for two coupled nonlinear differential equations
6 views (last 30 days)
Show older comments
Hello dears. I am looking for the solutions for y(t) and z(t) in two coupled differential equations simultaneously. I need solutions for each of y and z as the equations (for example y=C1 exp (A/B)t or z=C1 exp (B//A)t) not as numbers if it is possible.
At least, an Approximate Analytical Solution is desired, which may be achievable with the generation of sufficient dot points and the Curve-Fitting Toolbox.
- ODE of the nonlinear system,
- constant values of A and B,
- initial values of y0 and z0.

Both y(t) and z(t) are functions of t. Here, A and B are constant values. We want to get a solution for each of the dependent variables of y(t) and z(t). If it is needed the initial values of y0=y(0) and z0=z(0) can be used to achieve the solution.
0 Comments
Accepted Answer
Sam Chak
on 12 Apr 2022
Edited: Sam Chak
on 12 Apr 2022
Please check if this works out for your study:
A = 1.0;
B = 1.0;
fun = @(t, x)[-A*x(1)*x(2)^4; % 1st ODE
-B*x(1)^2*x(2)^3]; % 2nd ODE
tspan = [0 1e2];
y0 = 1.0; % initial value of y(t)
z0 = 1.125*y0; % initial value of z(t)
x0 = [y0;
z0];
[T, Z] = ode45(fun, tspan, x0); % Solver assigns solutions to Z array
y = Z(:,1); % numerical solution for y(t)
z = Z(:,2); % numerical solution for z(t)
% Fit well if A = 1; B = 1, and A = 1; B = -1
f1 = fit(T, y, 'rat23') % fit Rat23 model into y(t) data
f2 = fit(T, z, 'rat33') % fit Rat33 model into z(t) data
% Fit well if A = -1; B = 1
% f1 = fit(T, y, 'rat22') % fit Rat22 model into y(t) data
% f2 = fit(T, z, 'rat22') % fit Rat22 model into z(t) data
subplot(2, 1, 1)
plot(f1, T, y)
subplot(2, 1, 2)
plot(f2, T, z)
The Approximate Analytical Solution is a Rational Function:
f1 =
General model Rat23:
f1(x) = (p1*x^2 + p2*x + p3) /
(x^3 + q1*x^2 + q2*x + q3)
Coefficients (with 95% confidence bounds):
p1 = 1.925 (1.768, 2.083)
p2 = -0.4781 (-0.9759, 0.01979)
p3 = -0.246 (-0.5008, 0.008754)
q1 = 2.363 (1.718, 3.009)
q2 = -0.9528 (-1.554, -0.3518)
q3 = -0.2443 (-0.5014, 0.01292)
f2 =
General model Rat33:
f2(x) = (p1*x^3 + p2*x^2 + p3*x + p4) /
(x^3 + q1*x^2 + q2*x + q3)
Coefficients (with 95% confidence bounds):
p1 = 0.5208 (0.5195, 0.5221)
p2 = 12.22 (10.04, 14.4)
p3 = 50.82 (43.67, 57.96)
p4 = 21.52 (18.88, 24.16)
q1 = 24.87 (20.4, 29.34)
q2 = 68.33 (59.2, 77.46)
q3 = 19.15 (16.8, 21.5)
Results:

6 Comments
Sam Chak
on 12 Apr 2022
Thank you for your acceptance. Of course you may ask. This is a forum for users to discuss matters related to Mathworks products and to help each other. By the way, I have also edited the Answer to add a little more info on the code about the selection of the Rational function models.
More Answers (1)
sardar peysin
on 12 Apr 2022
4 Comments
Sam Chak
on 12 Apr 2022
I also learn from examples.
To give an example why another Rational model should be chosen, let say we select
A = -1;
B = 1;
then the previous proposed Rational model (Rat23) does not fit well for y(t).

So, by trial-and-error, it is found that Rat22 model fits well for both y(t) and z(t) in this case.
f1 = fit(T, y, 'rat22') % fit Rat22 model into y(t) data
f2 = fit(T, z, 'rat22') % fit Rat22 model into z(t) data

See Also
Categories
Find more on Linear Model Identification 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!
