Find the coefficient of a certain term in an expression

2 次查看(过去 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
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.

类别

Help CenterFile Exchange 中查找有关 Number Theory 的更多信息

标签

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by