How to write following equation with "dsolve" command?

1 次查看(过去 30 天)
I have written the code as below for the equation :
on MATLAB command window,
syms y(t); eqn = diff(y,t) == t^2/(1+y^2);
s=dsolve(eqn)
Warning: Unable to find symbolic solution.
> In dsolve>assignOutputs (line 242)
In dsolve (line 228)
s =
[ empty sym ]
I am not sure what mistake I've done here.
In the question it says
Observe that MATLAB finds three rather complicated explicit solutions. Note that two of them are complex-valued. Select the real one.
In fact, for this solution it is easier to work with an implicit form; so here are instructions for converting your solution. Substitute u = t3 (or t = u(1/3) to generate an expression in u. Set it equal to y and solve for u. Replace u by t3 to get an implicit solution of the form f(t, y) = c.
Would anyone be able to explain this to me, Please?

采纳的回答

Wan Ji
Wan Ji 2021-8-25
Hi,
That means
There is no symbolic solution for the differential equation you give.
  3 个评论
Wan Ji
Wan Ji 2021-8-25
Actually one can work it out by hand, if he uses Cardano formula, but matlab does not use this formula to produce the solution. So use dt/dy instead. Hope matlab will consider this problem

请先登录,再进行评论。

更多回答(1 个)

John D'Errico
John D'Errico 2021-8-25
编辑:John D'Errico 2021-8-25
Oh well. My fault, as i saw this question posted just before I went to bed last night. No rest for the weary. :) But we can at least come close to solving this problem, once we see the problem is a separable one. That is, multiply by 1+y^2.
Now you have the problem
(1+y^2)*dy = t^2*dt
Integrating both sides, we will see:
y + y^3/3 = t^3/3 + C
So an unknown constant of integration. If we had been given an initial value for the ODE, we could now solve for the constant of integration, C. But lacking that, it is an unknown. We can make things look a little simpler by rearranging, and multiply by 3.
y^3 + 3*y - t^3 + C = 0
C is different here, but still completely unknown, so that is irrelevant.
For example, had you told us that y(0) was 1, then we could solve for C as -4, simply by substitution.
Anyway, now solve for y. This is a cubic polynomial problem in y, so there must be three solutions, 0 or 2 of which in general will be complex valued since the coefficients are real valued.
syms y C t
ysol = solve(y^3 + 3*y - t^3 + C == 0,y,'maxdegree',3)
ysol = 
So three solutions. The problem is, depending on the initial condition, C might take on virtually any value. And that means it almost looks like we are stuck at this point. But then look more carefully at sigma1. What is inside the outer set of parens is always real, although it may be positive or negative. So if we select the real cube root of that number, then sigma1 will always be real. And that means the first solution is the one we need.
Surprisingly, dsolve did not find this solution. But that does not mean it did not exist. So can we nudge dsolve to find that solution? Yes. If you read the help for dsolve, it has an implicit flag.
syms y(t)
ysol = dsolve(diff(y,t) == t^2/(1+y^2),'implicit',true)
ysol = 
Ah. That looks exactly like what I did before by hand. Sorry, but I was not going to write this last night, half asleep.
  2 个评论
Wan Ji
Wan Ji 2021-8-25
编辑:Wan Ji 2021-8-25
I donot mean that there is no solution, I agree with the way you find the solution. But directly use dsolve, matlab cannot find the solution itself, and later on I commented on this problem. Let t be function of y. You see the the solution is easy to get. For this problem, you just see comment. Didnot I know y can be solved by solving a cubic equation in one unknown? I just meant dsolve is not able to do that.
Wan Ji
Wan Ji 2021-8-25
Generally speaking, a solution of dy/dt is hard to solve by hand, why can't we solve dt/dy? That's my point of view to give an optional choice. And you said I provided wrong solution, which really let me down

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Particle & Nuclear Physics 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by