quorem
Quotient and remainder of the division of two symbolic polynomials or integers.
Category: Symbolic Computations in MATLAB > Operators and Elementary Operations
Syntax
[q, r] = quorem(a, b)
Divides a by b and returns quotient and remainder.
q = quorem(a, b)
Returns only the quotient.
Description
For polynomials in one variable, quorem performs long division and the remainder has a lower degree than the divisor. For integers it performs integer division with a remainder that is nonnegative for a positive divisor.
The identity a = q*b + r always holds, so expand(q*b + r - a) is zero.
Input arguments
a- Dividend: symbolic polynomial or integer.
b- Divisor, nonzero.
Output arguments
q- Quotient.
r- Remainder, so that
a = q*b + r.
Example
Polynomial and integer division
syms x
[q, r] = quorem(x^3 + 2*x, x^2 + 1)
[q2, r2] = quorem(sym(-17), sym(5))
Output
q = x
r = x
q2 = -4
r2 = 3