Created
May 6, 2013 01:34
-
-
Save vr2262/5522894 to your computer and use it in GitHub Desktop.
This file contains 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
def ruffinis_rule(coefficients, factor): | |
"""Perform synthetic division and evaluate a polynomial at a factor.""" | |
deflated = np.empty(len(coefficients) - 1, dtype=complex) | |
deflated[0] = coefficients[0] | |
for i, coeff in enumerate(coefficients[1:-1], start=1): | |
deflated[i] = coeff + deflated[i - 1] * factor | |
evaluation = coefficients[-1] + deflated[-1] * factor | |
return deflated, evaluation |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment