Issue solving a non-linear differential equation in Matlab
3 ビュー (過去 30 日間)
古いコメントを表示
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/698372/image.png)
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/698377/image.png)
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
0 件のコメント
採用された回答
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 = simplify(ySol, 500) % Equivalent to: simplify(ySol, 'Steps',500)
.
2 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Ordinary Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!