Issue solving a non-linear differential equation in Matlab

조회 수: 1 (최근 30일)
ErikJon Pérez Mardaras
ErikJon Pérez Mardaras 2021년 7월 29일
댓글: Star Strider 2021년 7월 29일
Hi everyone,
I am trying to resolve the following non-linear differential equation in matlab:
For which I have written the following code
syms y(t)
ode = (diff(y,t))==((((t^2)/2)-(y))^(1/2));
cond = y(0) == 0;
ySol(t) = dsolve(ode,cond)
The result that Matlab calculates is the following:
But I do not understand why Matlab gives me the result in that way.
Why appears like that? Why appears (t^2)/4-(t^2)/2 instead of -(t^2)/4 ?
Is it okay the result? By hand I have reached the result (t^2)/4 and If you check this solution in the equation it make sense, but it does not make sense the result that Matlab gives. Am I wrong?
Thanks a lot

채택된 답변

Star Strider
Star Strider 2021년 7월 29일
Am I wrong?
No. The result is not always as simple as it might be.
In R2021a, the Symbolic Math Toolbox apparently simplifies this result automatically. In situations where that does not occur, call simplify after calculating the result to get a simpllified final result.
syms y(t)
ode = (diff(y,t))==((((t^2)/2)-(y))^(1/2));
cond = y(0) == 0;
ySol(t) = dsolve(ode,cond)
ySol(t) = 
ySol = simplify(ySol, 500) % Equivalent to: simplify(ySol, 'Steps',500)
ySol(t) = 
.
  댓글 수: 2
ErikJon Pérez Mardaras
ErikJon Pérez Mardaras 2021년 7월 29일
Thanks a lot for your reply!
The equation that I have introduced is the following one:
Which has only one result, which is: (t^2)/4
As long as the equation is a square root, what MATLAB has done is calculate also the solution for
Which is only: -(t^2)/2
Why MATLAB has done this?
MATLAB's solution would be correct if I would introduced this
But that is not what I have introduced
So, why MATLAB has done this? Why did MATLAB not resolved the equation exactly as I have introduced?
Thanks a lot
Star Strider
Star Strider 2021년 7월 29일
Every function has two square roots.
That’s just math!
.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by