Popular recipes tagged "polynomial"http://code.activestate.com/recipes/tags/polynomial/2014-02-13T20:55:55-08:00ActiveState Code RecipesPolynomial Factoring Using Rational Root Theorem (Python)
2011-12-03T23:51:07-08:00Alexander James Wallarhttp://code.activestate.com/recipes/users/4179768/http://code.activestate.com/recipes/577974-polynomial-factoring-using-rational-root-theorem/
<p style="color: grey">
Python
recipe 577974
by <a href="/recipes/users/4179768/">Alexander James Wallar</a>
(<a href="/recipes/tags/poly/">poly</a>, <a href="/recipes/tags/polynomial/">polynomial</a>, <a href="/recipes/tags/polyroots/">polyroots</a>, <a href="/recipes/tags/poly_roots/">poly_roots</a>, <a href="/recipes/tags/rational/">rational</a>, <a href="/recipes/tags/rational_root_theorem/">rational_root_theorem</a>, <a href="/recipes/tags/root/">root</a>, <a href="/recipes/tags/roots/">roots</a>, <a href="/recipes/tags/theorem/">theorem</a>).
</p>
<p>This algorithm factors a polynomial but will only factor it by giving the rational roots. For instance if one of the roots in the polynomial was irrational, the polynomial would not be factored correctly. </p>
Simple polynomial class (Python)
2014-02-13T20:55:55-08:00Sam Dentonhttp://code.activestate.com/recipes/users/4172262/http://code.activestate.com/recipes/576953-simple-polynomial-class/
<p style="color: grey">
Python
recipe 576953
by <a href="/recipes/users/4172262/">Sam Denton</a>
(<a href="/recipes/tags/arithmetic/">arithmetic</a>, <a href="/recipes/tags/calculator/">calculator</a>, <a href="/recipes/tags/polynomial/">polynomial</a>).
Revision 7.
</p>
<p>This implements polynomial functions over a single variable in Python. It represents the polynomial as a list of numbers and allows most arithmetic operations, using conventional Python syntax. It does not do symbolic manipulations. Instead, you can do things like this:</p>
<pre class="prettyprint"><code>x = SimplePolynomial()
eq = (x-1)*(x*1)
print eq # prints 'X**2 - 1'
print eq(4) # prints 15
</code></pre>