ode does not appear to give correct answer
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Aisling Lynch
el 30 de Nov. de 2021
Comentada: Aisling Lynch
el 30 de Nov. de 2021
Can anybody help with this very simple ode problem?
Here is the differential equation that I am trying to solve with MATLAB: dy/dx = (4*x^2)/y .
The answer should be: y = ±√((8x^3)/3+2c)
But the answer that MATLAB gives me is: (2^(1/2)*3^(1/2)*(4*x^3 + C1)^(1/2))/3
-(2^(1/2)*3^(1/2)*(4*x^3 + C1)^(1/2))/3 . In simpler terms, it gives me y = ±√((8x^3)+2c)/3. It differs from what I get 'on paper' because the 2c is also divided by 3 and I don't believe that it should be.
What am I doing wrong? Here is my code:
ode = diff(y,x) == (4*x^2)/y
ysol(x) = dsolve(ode)
0 comentarios
Respuesta aceptada
John D'Errico
el 30 de Nov. de 2021
Editada: John D'Errico
el 30 de Nov. de 2021
I think you misunderstand what is happening.
You get a constant in there, in the form of 2*c. But is c an unknown constant? Would it have mattered if the solution merely had c in there? My point is an extra scalar value multiplied by the constant is irrelevant. If you have 2*c/3, is c still an unknown constant? YES!
So are you doing something "wrong" Well, yes, and no. The error you have is in your expectation and understanding of what does it mean to have an unknown constant. Both solutions are equally valid. They just end up with subtly different variations on a completely unknown constant. And all of this is effectively caused because you have provided no initial condition for the ODE.
syms y(x)
ODE = diff(y) == 4*x^2/y;
If I now try to solve that ODE without an initial condition, I will get an unknown constant. It arises because there is no initial condition, that allows dsolve to eliminate the unknown constant.
dsolve(ODE)
So there we see two solutions, both of which have an unknown constant. The two solutions arise because there is a square root. I can resolve the constant by including an initial condition of course.
dsolve(ODE, y(0) == 1)
Now there are no arbitrary factors of 2 or 3, because the constant is now KNOWN, and even better, one of the solutions has disappeared.
That factor of 2 or 3 on an unknown constant is just a mirage.
Más respuestas (0)
Ver también
Categorías
Más información sobre Ordinary Differential Equations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!