Root() in answer of solve function
Show older comments
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 Comments
pepe
on 23 Dec 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
on 23 Dec 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
Accepted Answer
More Answers (1)
Victor Prohorov
on 1 Mar 2021
0 votes
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 Comment
Walter Roberson
on 1 Mar 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.
Categories
Find more on Linear Algebra in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!