Finding roots of a polynomial function

9 ビュー (過去 30 日間)
sandeep das
sandeep das 2022 年 2 月 10 日
回答済み: John D'Errico 2022 年 2 月 10 日
how to find roots of a cubic function which includes some symbolic variable ?
I am trying to obtain the roots of equation: ? The roots should come as 0.198k/m , 1.55k/m, 3.247k/m. But i am unable to interpret the result obtained.? Kindly help me out.
syms x k m
E = x^3 - 5*x^2*(k/m)+ 6*x*(k/m)^2-(k/m)^3
E = 
solve(E,x)
ans = 

採用された回答

John D'Errico
John D'Errico 2022 年 2 月 10 日
The best way to solve this specific problem is to transform it, in the form of a non-dimensional variable. That is, we see the cubic equation:
syms x k m
E = x^3 - 5*x^2*(k/m)+ 6*x*(k/m)^2-(k/m)^3;
In fact though, k and m just confuse things. They are additional variables that introduce units into the probem. Consider instead, this transformation: u = x*m/k. Or, if we solve for x, x = u*k/m.
syms u
Eu = expand(subs(E,x,u*k/m))
Eu = 
Since we want to find the roots, Eu == 0 is our problem. But do you see that now we can factor out k^3/m^3? ANd that leaves us with a very simple problem to solve, since only u appears in the resulting expression.
simplify(Eu*m^3/k^3)
ans = 
usol = solve(Eu*m^3/k^3 == 0,'maxdegree',3)
Warning: Solutions are only valid under certain conditions. To include parameters and conditions in the solution, specify the 'ReturnConditions' value as 'true'.
usol = 
Yes, it still looks a bit messy, but the solutions to a cubic polynomial are often a mess of radicals, and there are often some complex roots too. We can resolve all of that into simple numbers using vpa.
usol = vpa(usol)
usol = 
We are clearly almost there. Now recover x. That just means we need to put back in the ratio of k/m that we took out before. Since we don't care to see those pesky complex solutions almost always, we should consider that the imaginary part of the second and third solutions were infinitessimally tiny. In fact, they are just floating point trash, introduced when we converted into floating point arithmetic using vpa. So we can discard those imaginary parts. And that leaves us with 3 solutions to the problem.
xsol = real(usol)*k/m
xsol = 
Take your pick, as all are equally valid in terms of mathematics, but all I see is the equation. It is often the case that the real world can now intrude, and tell us that two of those solutions are meaningless in terms of physical constraints. But only you know that, since you are the one who proposed the problem.

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2022 年 2 月 10 日
Your proposed solutions appear to be mistaken for that equation.
format long g
syms x k m k_over_m
E = x^3 - 5*x^2*(k/m)+ 6*x*(k/m)^2-(k/m)^3
E = 
E2 = subs(E, k, k_over_m*m)
E2 = 
method1 = solve(E2, x)
method1 = 
string(method1)
ans = 3×1 string array
"root(z^3 - 5*k_over_m*z^2 + 6*k_over_m^2*z - k_over_m^3, z, 1)" "root(z^3 - 5*k_over_m*z^2 + 6*k_over_m^2*z - k_over_m^3, z, 2)" "root(z^3 - 5*k_over_m*z^2 + 6*k_over_m^2*z - k_over_m^3, z, 3)"
vpa(method1)
ans = 
method2 = solve(E2, x, 'MaxDegree', 3)
method2 = 
string(method2)
ans = 3×1 string array
"(5*k_over_m)/3 + ((-(49*k_over_m^6)/108)^(1/2) + (7*k_over_m^3)/54)^(1/3) + (7*k_over_m^2)/(9*((-(49*k_over_m^6)/108)^(1/2) + (7*k_over_m^3)/54)^(1/3))" "(5*k_over_m)/3 - (3^(1/2)*(((-(49*k_over_m^6)/108)^(1/2) + (7*k_over_m^3)/54)^(1/3) - (7*k_over_m^2)/(9*((-(49*k_over_m^6)/108)^(1/2) + (7*k_over_m^3)/54)^(1/3)))*1i)/2 - ((-(49*k_over_m^6)/108)^(1/2) + (7*k_over_m^3)/54)^(1/3)/2 - (7*k_over_m^2)/(18*((-(49*k_over_m^6)/108)^(1/2) + (7*k_over_m^3)/54)^(1/3))" "(5*k_over_m)/3 + (3^(1/2)*(((-(49*k_over_m^6)/108)^(1/2) + (7*k_over_m^3)/54)^(1/3) - (7*k_over_m^2)/(9*((-(49*k_over_m^6)/108)^(1/2) + (7*k_over_m^3)/54)^(1/3)))*1i)/2 - ((-(49*k_over_m^6)/108)^(1/2) + (7*k_over_m^3)/54)^(1/3)/2 - (7*k_over_m^2)/(18*((-(49*k_over_m^6)/108)^(1/2) + (7*k_over_m^3)/54)^(1/3))"
vpa(method2)
ans = 

カテゴリ

Help Center および File ExchangePolynomials についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by