The degree of function is unknown

1 回表示 (過去 30 日間)
Mohamed Mahmoud
Mohamed Mahmoud 2020 年 10 月 24 日
回答済み: Walter Roberson 2020 年 10 月 25 日
syns Q, x, a
Q=5*x^(2+a)
polynomialDegree(Q)
I want the answer to be 2+a

回答 (2 件)

VBBV
VBBV 2020 年 10 月 25 日
編集済み: Walter Roberson 2020 年 10 月 25 日
Do you mean this expression ?
syms x a
Q=5*x^2 + a;
polynomialDegree(Q)
ans =
2
  1 件のコメント
Walter Roberson
Walter Roberson 2020 年 10 月 25 日
No, the user stated clearly they had x^(2+a) and wanted (2+a) as the answer.

サインインしてコメントする。


Walter Roberson
Walter Roberson 2020 年 10 月 25 日
This is proving to be a challenge to implement in the general case.
So far I have code that automatically reduces multiples of x to remove the multiplier, and I have code that can extract the power coefficient for x^power . However, I have not figured out yet how to handle sum of polynomial terms, and I have not figured out yet how to handle situations such as 1/(x^2+3) .
Oh yes, and my code at the moment is only valid for variable x . The polynomialDegree function by default works over all variables, so if you need to replicate that then you would need to figure out what you meant by the polynomial degree of Q with respect to variable a and not just variable x
The polynomial degree with respect to a given variable is the maximum degree for the terms, and that is not conceptually difficult for constant powers, but suppose you had
R = 5*x^(2+a) - 3*x^(2*a)
then what is the polynomial degree with respect to x? It would be max(2+a, 2*a) and you would have to leave it expressed as a maximum because 2+a > 2*a for a < 2. But symbolic toolbox does not actually have a delayed max function: you have to express max(2+a,2*a) by piecewise(2+a <= 2*a, 2+a, 2*a) and that quickly gets pretty messy as soon as you have three terms.
And what should the result be when a < -2 ? Or in the case of x^(2*a) if a < 0 ? What should be the degree for
x^2 + x^(-2)
?

カテゴリ

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

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by