Extra variable in differential equation's symbolic solution

I'm trying to understand where this extra variable, z, comes from in the analytical solution of this differential equation. I used the Symbolic Toolbox to evaluate the solution. Is there another efficient or better way to provide the general solution of this equation?
syms y(t)
eqn2 = diff(y)==-(4*t+3*y)/(2*t+y)
eqn2(t) = 
ans1=dsolve(eqn2)
ans1 = 

 Respuesta aceptada

Notice that the z occurs within the context of a call to root
In the Symbolic Toolbox, root(EXPRESSION,VARIABLE) is a placeholder standing in for the set of values of VARIABLE such that when the value is substituted for the VARIABLE into the EXPRESSION, the result is 0. root(EXPRESSION,VARIABLE,INDEX) stands for the INDEX'th such value.
In other words, root() stands for the roots of a polynomial.
Starting in R2023a, you can use rewrite() with 'expandroot' to generate the explicit formula for roots up to degree 4.
syms y(t)
eqn2 = diff(y)==-(4*t+3*y)/(2*t+y)
eqn2(t) = 
ans1 = dsolve(eqn2)
ans1 = 
rewrite(ans1, 'expandroot')
ans = 
In my experience, if you are finding that you need to rewrite roots of degree 3 or 4 explicitly, you are likely getting into situations where the solutions are going to be pretty much incomprehensible. This particular case does not look too bad, but a lot of the time the expressions get pretty ugly.

Más respuestas (1)

Torsten
Torsten el 1 de Abr. de 2023
Editada: Torsten el 1 de Abr. de 2023
ans1=dsolve(eqn2,'MaxDegree',3)
gives the explicit (complicated) solution.
For each t, root(...) means the root of the polynomial(z) in brackets.
Compare with

Categorías

Más información sobre Symbolic Math Toolbox en Centro de ayuda y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by