Getting a solution for two coupled nonlinear differential equations

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.

 Accepted Answer

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

The convergence becomes faster if .
The system has some interesting mathematical properties worth to be investigated, depending on the signs of the constants A and B.
I really thank you Mr. Sam. If y0 becamoes greater than z0, will the convergence have any problem? I mean does it mak any problem if y0 is grater than z0?
I have not caculated the amounts of A and B yet. I don't konw that which one is positie or negative or which one is greater or lower. I want to konw this can influence the obtained results? I mean the proedure will be different if A is higher than B or vice versa, or A and B are both positives or negatives?
Because I have several cases, It may occure that each of A nad B becaomes negative or positive or any value else. Does this affect the type of writting the code?
Is it important to use this time span: tspan = [0 1e2];? I mean why do you use this time span?
If I change this time span, does it have any effect of the obtained equation f(x)?
I'm not an expert to your highly nonlinear system, but you are, and you absolutely know what and are. So, you are the most suited person for investigating the system and be recognized for your scientific contributions to the knowledge of this system.
Moreover, the sample ODE-solving code has been provided, all thanks to @Torsten's initiative. In other words, you are absolutely in control to determine what values to be used in the numerical settings ( and , and ), whether you program the code in MATLAB or in Maple, or even in Wolfram Mathematica.
The nonlinear system can converge or diverge, depending on your selections for and . If you want to know, assign some experimental values into them and look at the results. The ODE-solving code remains the same, you just have to enter whatever values you are investigating into and , and . I selected simulation time up to 100 seconds to show the convergence of the system states. No other reason.
Depending whether the system converges or diverges, you may need to change the fitting model accordingly in these two lines:
f1 = fit(T, y, 'rat23') % fit Rat23 model f1(t) into y(t) data
f2 = fit(T, z, 'rat33') % fit Rat33 model f2(t) into z(t) data
There is no one size fits everything.
Really welldone Mr. Sam. You helped me alot. I am not as expert as you in MATLAB coding and this is the reason that I wanted an expert person like you to help me. I think you gave me a very goo code that is capable of solving my problem.
Thank you alot Mr. Sam.
If I have any other question, I will ask you in future. I will accept your answer in Mathwork site.
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.
Mr. Sam, I am very thankful of you. You did your best. I will try both of these fitting models in the next days because I have not yet finished my formulations and I still don't have values of A and B and initial conditions. I will inform you. But you really helped me and you solved the problem. Thank you very much for proposing Rat23 and Rat22 fiting models.

Sign in to comment.

More Answers (1)

Thankyou Mr. Sam. I think you got a reasonable answer. It seems to be very relaible.
I must try the result in my next calculations. It may take some time, but I will inform you about the correctness of the results.
Let me ask you another question about the obtained results. The curve fitted to the y-axis data gives us the following equation;
f(x) = (p1*x^2 + p2*x + p3) /(x^3 + q1*x^2 + q2*x + q3)
Here f(x) is y(t) or z(t)? (I maen is f(x)=y(t)?)
It seems that f(x)=y(t) here, and the obtained equation is an eqaution for y(t) which leads:
y(t)=f(t) = (p1*t^2 + p2*t + p3) /(t^3 + q1*t^2 + q2*t + q3)
If I am right, so, please tell me that can we find an equations for function z(t) if we use
f=fit(T, Z(:,2), 'rat23')
plot(f, T, Z(:,2))
instead of using
f = fit(T, Z(:,1), 'rat23')
plot(f, T, Z(:,1))
Please if z(t) is not obtained as what I said, so how we can find z(t) equation?

4 Comments

I have edited my Answer to include the approximate analytical solutions for both y(t) and z(t).
You may need to try other Rational function models until you find the one that fits.
Hope the explanations are helpful.
Thankyou Mr. Sam. The explantions are now more helpful. I will inform you later the effect of these results on my final results. Thanks agin. I really approciate you for your effort.
What do you mean by this sentence"You may need to try other Rational function models until you find the one that fits."?
The MATLAB code only gives me one Rational function. What do you mean by other Rational function models? How can I get the other Rational function models by the code that you generated above?
May you explain it clearer?
Your Sincerely
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
Mr. Sam, I am very thankful of you. You did your best. I will try both of these fitting models in the next days because I have not yet finished my formulations and I still don't have values of A and B and initial conditions. I will inform you. But you really helped me and you solved the problem. Thank you very much for proposing Rat23 and Rat22 fiting models.

Sign in to comment.

Categories

Community Treasure Hunt

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

Start Hunting!