problem with symbolic factorization with two symbols
4 ビュー (過去 30 日間)
古いコメントを表示
The output is not a factorized one. I want this form : (s+s1)*(s+s2)*(s+s3). What is the problem?
syms s K
factor(s^3 + 10*s^2 + (21+K)*s + 4*K, [s, K],'FactorMode','full')
The output is
4*K + 21*s + K*s + 10*s^2 + s^3
1 件のコメント
Dyuman Joshi
2023 年 10 月 21 日
It is factorized according to the inputs given.
From the documentation - F = factor(x,vars) returns an array of factors F, where vars specifies the variables of interest. All factors not containing a variable in vars are separated into the first entry F(1). The other entries are irreducible factors of x that contain one or more variables from vars.
Note the last sentence.
What is the expected output from the vectorization?
採用された回答
John D'Errico
2023 年 10 月 21 日
編集済み: John D'Errico
2023 年 10 月 21 日
That you want to see a simple set of factors is not relevant. You essentially need to obtain the roots of this cubic polynomial in s, where K is a parameter, which would give you that factorization.
syms s K
sroots = solve(s^3 + 10*s^2 + (21+K)*s + 4*K,s,'maxdegree',3)
As you can see, they are fairly messy, and depending on the value of K, they may well be complex even if K is real. This is expected for any cubic polynomial, that we may find exactly two conjugate complex roots.
The factors now are just
prod(s-sroots)
We can expand that to show the result recovers your original polynomial.
simplify(expand(ans))
Finally, why did not factor understand what you wanted to see? You gave it two variables s and K. How should factor possibly know that you wanted it to do what I just did, essentially, that s is the variable of interest, and K a symbolic parameter in the problem? Software cannot read your mind, at least, not yet.
7 件のコメント
Walter Roberson
2023 年 10 月 21 日
Factorization of expressions with real components (or components of unknown reality) traditionally only proceeds to the point where any further factoring would require use of imaginary components.
syms x
factor(x^2 + 1)
factor(x^2 - 1)
P1 = expand((x-2) * (x+7) * (x-7))
factor(P1)
P2 = expand((x-2) * (x+7i) * (x-7i))
factor(P2)
P3 = expand((x-2i) * (x+7) * (x-7))
factor(P3)
参考
カテゴリ
Help Center および File Exchange で Symbolic Variables, Expressions, Functions, and Preferences についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!