I have already tried reading some other similar questions but I had no luck. Does Matlab have problem then the same variable is on both sides or something? Simplify function also didn’t work.

댓글 수: 1

Dominik Stolfa
Dominik Stolfa 2023년 11월 16일
편집: Dominik Stolfa 2023년 11월 16일
Well, simplify function did sort of worked, but it didn’t simplify anything, regarding moving variables to the same side. This is the original equation I am trying to simplify/solve: (diff(x(t),t)==(1-x(t)/K)*x(t))

댓글을 달려면 로그인하십시오.

 채택된 답변

Walter Roberson
Walter Roberson 2023년 11월 16일

0 개 추천

Well, let us test the hypothesis that the problem is that the same variable is on both sides:
syms x(t) y(t) c
K = 1072764;
eqn1 = (x==int((1-(x/K))*x,t,0,3))
eqn1(t) = 
eqn2 = (y==int((1-(x/K))*x,t,0,3))
eqn2(t) = 
eqn3 = (c==int((1-(x/K))*x,t,0,3))
eqn3 = 
eqn4 = (4321==int((1-(x/K))*x,t,0,3))
eqn4 = 
sol1 = solve(eqn1, x)
Warning: Unable to find explicit solution. For options, see help.
sol1 = Empty sym: 0-by-1
sol2 = solve(eqn2, x)
Warning: Unable to find explicit solution. For options, see help.
sol2 = Empty sym: 0-by-1
sol3 = solve(eqn3, x)
Warning: Unable to find explicit solution. For options, see help.
sol3 = struct with fields:
c: [0×1 sym] t: [0×1 sym]
sol4 = solve(eqn4, x)
Warning: Unable to find explicit solution. For options, see help.
sol4 = Empty sym: 0-by-1
So the problem is not that the same variable occurs on both sides of the equation -- if it were then having y(t) on the left side would have worked. The problem is also not that the left side is a function x(t) instead of a constant -- if it were then using c on the left side instead of x(t) or y(t) would have worked. The problem is also not that using a symbolic variable instead of a specific numeric value makes the equation "too complicated" -- if that were the case then using 4321 on the left side would have worked.
What is left?
Well... there is the fact that you tried to find an explicit solution for an integral equation.
Generally speaking, MATLAB just doesn't know how to solve many integral equations.

댓글 수: 3

Dominik Stolfa
Dominik Stolfa 2023년 11월 16일
Oh. That sucks. Why though? I have been using Wolfram few years back and I think it didn’t have this problem. This doesn’t look like some horribly complicated integral neither.
Walter Roberson
Walter Roberson 2023년 11월 16일
I tested this equation with wolfram alpha, which was not able to solve it.
Dominik Stolfa
Dominik Stolfa 2023년 11월 19일
Ok. My bad then. Still. Why though? With so much advancement in technology one would think computers can solve any mathematical problem which humans can.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Torsten
Torsten 2023년 11월 16일
이동: Torsten 2023년 11월 16일

1 개 추천

You must use "dsolve", not "solve":
syms t x(t) K
eqn = diff(x,t) == (1-x/K)*x;
dsolve(eqn)
ans = 

댓글 수: 5

John D'Errico
John D'Errico 2023년 11월 16일
편집: John D'Errico 2023년 11월 16일
This, based on the fact that the equation can effectively be converted into a differential equation. Just differentiate both sides with respect to t.
Dominik Stolfa
Dominik Stolfa 2023년 11월 16일
Aha. The differential form of the equation can be solved by using “daolve” instead of “solve”.
What does the 0 and K mean? Also, is there a way to use Matlab to return solution with analytically expressed C and substituted into the formula?
Walter Roberson
Walter Roberson 2023년 11월 16일
When you take the derivative in this simple way, you lose the information about the bounds of the definite integral. The same equation would be generated no matter if the upper bound is 3 or 10^300. But clearly the upper bound does make a difference to the original equation... so this approach of just taking the derivative of both sides is insufficient.
John D'Errico
John D'Errico 2023년 11월 16일
Oh, yes. I forgot the integral bounds are fixed.
Dominik Stolfa
Dominik Stolfa 2023년 11월 19일
So how’s do I solve it in Matlab? Are you saying it is impossible?

댓글을 달려면 로그인하십시오.

Walter Roberson
Walter Roberson 2023년 11월 16일
편집: Walter Roberson 2023년 11월 16일

0 개 추천

If we assume that x is a function of one variable, t, then the definite integral of an expression involving only x and constants, is an expression that does not involve t. So by inspection you are asking to solve x(t) = constant. We can then substitute constant into the equation, say X, getting
X == int((1-X/K)*X,t,0,3)
This gives you a definite result on the right, and you can solve the quadratic by factoring, for solutions x(t) = 0 and x(t) = 2/3 * K
The solutions proposed by Torsten do not work except for the 0.

댓글 수: 6

Torsten
Torsten 2023년 11월 16일
편집: Torsten 2023년 11월 16일
This was the OPs comment to his original question:
This is the original equation I am trying to simplify/solve: (diff(x(t),t)==(1-x(t)/K)*x(t))
What should be the meaning of
X == int((1-X/K)*X,t,0,3)
?
The right-hand side is a constant, the left-hand side is a function of t.
What comes out when integrating the differential equation from above is
x(t)-x(0) = integral_{t'=0}^{t'=t} (1-x(t')/K)*x(t') dt'
or for t = 3
x(3)-x(0) = integral_{t'=0}^{t'=3} (1-x(t')/K)*x(t') dt'
Dominik Stolfa
Dominik Stolfa 2023년 11월 19일
편집: Dominik Stolfa 2023년 11월 19일
The equation I stated is actually supposed to be logistic formula for population growth. The differential form is what we use in Simulink for modelling. But I wanted to use Matlab code in order to calculate it, without necessity of knowing its other (derived) form: x(t)=(K*x(0)*e^(r*t))/(K+x(0)*(e^(r*t)-1).
I admit I am not very good at Math nor Matlab, so I am not entirely sure what you two were arguing about. In Torsten’s equation I have problem with undefined “C1”. Which is necessary to calculate in order to find solution, but I don’t know how to do that in Matlab, neither what “0” and “K” underneath the expression means. In Walter Robertson’s proposed solution I am not even sure how he managed to find it. But I think it doesn’t look like what I was expecting to get.
I am sorry for late replies to everyone.
Torsten
Torsten 2023년 11월 19일
편집: Torsten 2023년 11월 19일
The logistic equation
dx/dt=rx(1-x/K), x(0) = x0
is a differential equation.
To get an explicit solution in MATLAB, you have to use "dsolve":
syms t x(t) x0 K r
eqn = diff(x,t) == r*x*(1-x/K);
cond = x(0)==x0;
x = dsolve(eqn,cond)
x = 
x = simplify(x)
x = 
Walter Roberson
Walter Roberson 2023년 11월 19일
If you have an equation in derivative form then try using dsolve. If the result contains a constant then that indicates that at least one boundary condition is not fixed.
Sometimes matlab does just fine with boundary conditions passed to dsolve, but unfortunately it is not uncommon that you might need to ask dsolve for the general form and solve the boundaries with substitution and solve()
Walter Roberson
Walter Roberson 2023년 11월 19일
The original equation you posted was an integral equation in which an expression in t was integrated over a definite range of t. A definite integral no longer has the variable of integration in the expression (unless the variable was used in the limit.) The finished definite integral is effectively constant with respect to the variable of integration... so if you then take the derivative with respect to the variable of integration then the definite integral vanishes.
f(x) = int(g(x), x, a, b)
take derivative of both sides to get
df/dx = d(int(g(x), x, a, b)/dx
but the int will not have x in it so the derivative is 0, leading to
df/dx = 0
Dominik Stolfa
Dominik Stolfa 2023년 11월 20일
I think I understand what you mean now, Walter Roberson.
Also, thank you Torsten for finding solution that I wanted. And to Walter for explaining a lot of things to me.
I am sorry but I am not sure as what should I mark as correct answer. I mean, all of the answers you two gave me are right, in my opinion. It is just me who could not explain properly what I wanted, or well, wanted to know several things at once.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

질문:

2023년 11월 16일

댓글:

2023년 11월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by