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 CenterFile Exchange에서 Number Theory에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by