Find the coefficient of a certain term in an expression
3 次查看(过去 30 天)
显示 更早的评论
Suppose I have:
syms X Y Z
A = 1.123 * X^3 + 4.234 * X * Y * Z + 5.32 * X^2 *Y
Is there a way to obtain the exact coefficient of, let's say:
X^2 * Y
from A automatically (usually I will have a much larger polynomial expression)?
In my application, I will have a large homogenous polynomial A. Eventually, I will choose a i, j and k, defining the trinomial:
,
and then I will have to obtain the corresponding coefficient
A_ijk
that is multiplying:
X^i * Y^j * Z^k
.
3 个评论
回答(1 个)
Walter Roberson
2020-9-24
Not directly, no.
However, you can coeffs(A,X, 'all') and look in the third last entry (highest degree is first so third last is degree 2). The result would be a summation of terms (for example it might be 5.32 * Y + 7 if the expression included 5.32*X^2*Y + 7*X^2 ) .
You can then coeffs() that entry for Y and pull out all but the constant term.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Number Theory 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!