Root() in answer of solve function
36 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
pepe
2019 年 12 月 23 日
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
2019 年 12 月 23 日
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
採用された回答
Walter Roberson
2016 年 5 月 6 日
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 件のコメント
Ariel Chazan
2020 年 3 月 5 日
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
2020 年 3 月 5 日
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.
その他の回答 (1 件)
Victor Prohorov
2021 年 3 月 1 日
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 件のコメント
Walter Roberson
2021 年 3 月 1 日
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.
参考
カテゴリ
Help Center および File Exchange で Linear Algebra についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!