The degree of function is unknown
조회 수: 1 (최근 30일)
이전 댓글 표시
syns Q, x, a
Q=5*x^(2+a)
polynomialDegree(Q)
I want the answer to be 2+a
댓글 수: 0
답변 (2개)
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
2020년 10월 25일
No, the user stated clearly they had x^(2+a) and wanted (2+a) as the answer.
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)
?
댓글 수: 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!