Polynomial long division: Difference between revisions

Content added Content deleted
(octave)
m (→‎{{header|Octave}}: specify the builtin to make the poly long div)
Line 398: Line 398:


=={{header|Octave}}==
=={{header|Octave}}==
Octave has already facilities to divide two polynomials; and the reason to adopt the convention of keeping the higher power coefficient first, is to make the code compatible with builtin functions: we can use <tt>polyout</tt> to output the result.
Octave has already facilities to divide two polynomials (<code>deconv(n,d)</code>); and the reason to adopt the convention of keeping the higher power coefficient first, is to make the code compatible with builtin functions: we can use <tt>polyout</tt> to output the result.


<lang octave>function [q, r] = poly_long_div(n, d)
<lang octave>function [q, r] = poly_long_div(n, d)
Line 436: Line 436:
[q, r] = poly_long_div([1,3], [1,-12,0,-42]);
[q, r] = poly_long_div([1,3], [1,-12,0,-42]);
polyout(q, 'x');
polyout(q, 'x');
polyout(r, 'x');</lang>
polyout(r, 'x');</lang>


=={{header|Python}}==
=={{header|Python}}==