Created
February 7, 2022 13:46
-
-
Save tueda/ca7163753975c4595b9af386c0241502 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
PolynomialDivCofficientList | |
Return the coefficient list by dividing polynomials;PolynomialDivCofficientList[x^2+1,x+1,x]\[LongRightArrow]{1,-2,2},which means x^2+1==(x+1)^2-2(x+1)+2. | |
*) | |
PolynomialDivCofficientList[expr_, denom_, x_] := Module[ | |
{result, rem, cnt, i}, | |
result = {}; | |
rem = expr; | |
cnt = Floor[Exponent[expr, x]/Exponent[denom, x]]; | |
For[i = cnt, i > 0, i--, | |
result = result~Append~PolynomialQuotient[rem, Power[denom, i], x]; | |
rem = PolynomialRemainder[rem, Power[denom, i], x]; | |
]; | |
result~Append~rem | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment