Polynomial synthetic division: Difference between revisions

m
J draft
m (Added TOC)
m (J draft)
Line 3:
 
__TOC__
=={{header|J}}==
 
Solving this the easy way:
 
<lang J> psd=: [:(}. ;{.) ([ (] -/@,:&}. (* {:)) ] , %&{.~)^:(>:@-~&#)~
(1, (-12), 0, -42) psd (1, -3)</lang>
 
Task example:
 
<lang J>┌────────┬────┐
│1 _9 _27│_123│
└────────┴────┘
</lang>
 
=={{header|Python}}==
Here is an extended synthetic division algorithm, which means that it supports a divisor polynomial (instead of a monomial or a binomial). It also supports non-monic polynomials (polynomials which first coefficient is different than 1). Polynomials are represented by lists of coefficients with decreasing degree (left-most is the major degree , right-most is the constant).
6,962

edits