Root() in answer of solve function

37 visualizaciones (últimos 30 días)
Linh Dang
Linh Dang el 6 de Mayo de 2016
Comentada: Walter Roberson el 1 de Mzo. de 2021
Hello, I am solving a partial derivative equation using symbolic expression. After using f1= diff(f,Qs) and solve(f1,Qs), I got the following answer that have root(....). Anybody can explain to me how can I get rid of root()? Note: z is not defined initially
Thanks for your help
Example:ans= root(3*a^2*k^2*z^6 - 2*Qn*a^2*k^2*z^5 + 4*a*k*z^5 - 3*Qn^2*a^2*k^2*z^4 + 8*Qn*a*k*z^4,z,1)
  2 comentarios
pepe
pepe el 23 de Dic. de 2019
I have had a similar version dependent exprience. My code is:
syms x
solve(x^3+x-1==0)
In Matlab 2019 it produces the useless root() output that you also mentioned. But in MATLAB 2014 it produces a nicer result comprised of fractions and sums of numbers;...so I recommend you also give it a try using a old version of MATLAB.
good luck
پویا پاکاریان
پویاپاکاریان
Walter Roberson
Walter Roberson el 23 de Dic. de 2019
syms x
>> simplify(solve(x^3+x-1==0, 'maxdegree', 3),'steps',50)
ans =
-(12^(1/3)*((93^(1/2) - 9)^(1/3) - (93^(1/2) + 9)^(1/3)))/6
(2^(2/3)*3^(1/3)*((93^(1/2) - 9)^(1/3) - (93^(1/2) + 9)^(1/3)))/12 - (2^(2/3)*(3^(5/6)*(93^(1/2) - 9)^(1/3) + 3^(5/6)*(93^(1/2) + 9)^(1/3))*1i)/12
(2^(2/3)*(3^(5/6)*(93^(1/2) - 9)^(1/3) + 3^(5/6)*(93^(1/2) + 9)^(1/3))*1i)/12 + (2^(2/3)*3^(1/3)*((93^(1/2) - 9)^(1/3) - (93^(1/2) + 9)^(1/3)))/12

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 6 de Mayo de 2016
RootOf(f(z), z) represents the set of values, z, that satisfy f(z) == 0 -- the roots of the expression.
You have a polynomial of degree 6. There are not generally exact solutions to such polynomials, but if the polynomial is what is shown, that particular one can be factored to create four 0's and two exact roots.
You could try applying simple() to the output.
  5 comentarios
Ariel Chazan
Ariel Chazan el 5 de Mzo. de 2020
Walter, I have a question on the nature of an expression of the form root(...). Is the expression an integer?
For example, if I apply the solve function a polynomial and get an array x with three elements all in the form of root(...), i.e. x = [root(...), root(...), root(...)], can I now assign a variable to one of these elements, i.e a = x(1), and use a later in a piece of code just like any other variable? Many thanks for your help
Walter Roberson
Walter Roberson el 5 de Mzo. de 2020
The expression would seldom be an integer. It would also not necessarily be real-valued.
However, yes you can assign it to a variable and use it in symbolic expressions.
If the root() expression contains only constants and the variable z then MATLAB will understand the represented value as being a constant.

Iniciar sesión para comentar.

Más respuestas (1)

Victor Prohorov
Victor Prohorov el 1 de Mzo. de 2021
Read Matlab help:
Try to get an explicit solution for such equations by calling the solver with 'MaxDegree'. The option specifies the maximum degree of polynomials for which the solver tries to return explicit solutions. The default value is 2. Increasing this value, you can get explicit solutions for higher order polynomials.Solve the same equations for explicit solutions by increasing the value of 'MaxDegree' to 3.
  1 comentario
Walter Roberson
Walter Roberson el 1 de Mzo. de 2021
Already discussed https://www.mathworks.com/matlabcentral/answers/282911-root-in-answer-of-solve-function#comment_365402
Also, when you are working with partial derivatives then when matlab sees the diff() then if you called solve() then matlab will call dsolve() in order to work out the solution. However, dsolve does not support the MaxDegree option and will return RootOf (though the presentation interface will rewrite them as root() to show to the user.) There is no method provided by matlab to reduce a RootOf that has already been returned.

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by