Factorization With Symbolic Terms
古いコメントを表示
Hello! Does any one knows how can I group a specific term in a long equation?
For example, imagine i have the equation
, which is equivalent to
.
.If I use the factor function, I obtain:
syms x
eq = x^2 + 6*x + 9
factor(eq,x)
ans = [ x + 3, x + 3]
However, I want to group those terms inside the eq itself, so I can keep manipulating the symbolic expression (eq = (x+3)^2). I am asking these because I am solving a Lagrange equation and I need to group the terms in the forma (x + y) and (x - y). Once they are grouped, I want to make a variable change: subs(eq,(x+y),z) and subs(eq,(x-y),w).
Thanks a lot!
1 件のコメント
madhan ravi
2018 年 11 月 24 日
eq = x^2 + 6*x + 9 -> should be 9 not 3
採用された回答
その他の回答 (1 件)
madhan ravi
2018 年 11 月 24 日
編集済み: madhan ravi
2018 年 11 月 25 日
AFAIK - I don't think there is a possibility to do that in symbolic math toolbox
After all the struggles: see isequaln()
eq=x^2 + 6*x + 9
s=factor(eq)
if isequaln(s(1),s(2)) %assuming only two factors
result=s(1)*s(2);
else
result = s;
end
2 件のコメント
Giulio Cesare Mastrocinque Santo
2018 年 11 月 25 日
madhan ravi
2018 年 11 月 25 日
Anytime :) , you can vote for the answer if it was helpful.
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!