How to write following equation with "dsolve" command?

3 views (last 30 days)
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?

Accepted Answer

Wan Ji
Wan Ji on 25 Aug 2021
Hi,
That means
There is no symbolic solution for the differential equation you give.
  3 Comments
N/A
N/A on 25 Aug 2021
I am truly grateful for your kind explanation.
Wan Ji
Wan Ji on 25 Aug 2021
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

Sign in to comment.

More Answers (1)

John D'Errico
John D'Errico on 25 Aug 2021
Edited: John D'Errico on 25 Aug 2021
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 Comments
Wan Ji
Wan Ji on 25 Aug 2021
Edited: Wan Ji on 25 Aug 2021
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 on 25 Aug 2021
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

Sign in to comment.

Products

Community Treasure Hunt

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

Start Hunting!