Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Synthetic division
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Python implementation === The following snippet implements Expanded Synthetic Division in [[Python (programming language)|Python]] for arbitrary univariate polynomials: <syntaxhighlight lang="python"> def expanded_synthetic_division(dividend, divisor): """Fast polynomial division by using Expanded Synthetic Division. Also works with non-monic polynomials. Dividend and divisor are both polynomials, which are here simply lists of coefficients. E.g.: x**2 + 3*x + 5 will be represented as [1, 3, 5] """ out = list(dividend) # Copy the dividend normalizer = divisor[0] for i in range(len(dividend) - len(divisor) + 1): # For general polynomial division (when polynomials are non-monic), # we need to normalize by dividing the coefficient with the divisor's first coefficient out[i] /= normalizer coef = out[i] if coef != 0: # Useless to multiply if coef is 0 # In synthetic division, we always skip the first coefficient of the divisor, # because it is only used to normalize the dividend coefficients for j in range(1, len(divisor)): out[i + j] += -divisor[j] * coef # The resulting out contains both the quotient and the remainder, # the remainder being the size of the divisor (the remainder # has necessarily the same degree as the divisor since it is # what we couldn't divide from the dividend), so we compute the index # where this separation is, and return the quotient and remainder. separator = 1 - len(divisor) return out[:separator], out[separator:] # Return quotient, remainder. </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)