# How to write following equation with "dsolve" command?

조회 수: 12(최근 30일)
Matthew Worker 2021년 8월 25일
편집: John D'Errico 2021년 8월 25일
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 2021년 8월 25일
Hi,
That means
There is no symbolic solution for the differential equation you give.
##### 댓글 수: 3표시숨기기 이전 댓글 수: 2
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 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표시숨기기 이전 댓글 수: 1
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

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

### Community Treasure Hunt

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

Start Hunting!