Main Content

quorem

Quotient and remainder

Description

[Q,R] = quorem(A,B,var) divides A by B and returns the quotient Q and remainder R of the division, such that A = Q*B + R. This syntax regards A and B as polynomials in the variable var.

If A and B are matrices, quorem performs elements-wise division, using var as a variable. It returns the quotient Q and remainder R of the division, such that A = Q.*B + R.

example

[Q,R] = quorem(A,B) uses the variable determined by symvar(A,1). If symvar(A,1) returns an empty symbolic object sym([]), then quorem uses the variable determined by symvar(B,1).

If both symvar(A,1) and symvar(B,1) are empty, then A and B must both be integers or matrices with integer elements. In this case, quorem(A,B) returns symbolic integers Q and R, such that A = Q*B + R. If A and B are matrices, then Q and R are symbolic matrices with integer elements, such that A = Q.*B + R, and each element of R is smaller in absolute value than the corresponding element of B.

example

Examples

Divide Multivariate Polynomials

Compute the quotient and remainder of the division of these multivariate polynomials with respect to the variable y:

syms x y
p1 = x^3*y^4 - 2*x*y + 5*x + 1;
p2 = x*y;
[q, r] = quorem(p1, p2, y)
q =
x^2*y^3 - 2
 
r =
5*x + 1

Divide Univariate Polynomials

Compute the quotient and remainder of the division of these univariate polynomials:

syms x
p = x^3 - 2*x + 5;
[q, r] = quorem(x^5, p)
q =
x^2 + 2

r =
- 5*x^2 + 4*x - 10

Divide Integers

Compute the quotient and remainder of the division of these integers:

[q, r] = quorem(sym(10)^5, sym(985))
q =
101
 
r =
515

Input Arguments

collapse all

Dividend (numerator), specified as a symbolic integer, polynomial, or a vector or matrix of symbolic integers or polynomials.

Divisor (denominator), specified as a symbolic integer, polynomial, or a vector or matrix of symbolic integers or polynomials.

Polynomial variable, specified as a symbolic variable.

Output Arguments

collapse all

Quotient of the division, returned as a symbolic integer, expression, or a vector or matrix of symbolic integers or expressions.

Remainder of the division, returned as a symbolic integer, expression, or a vector or matrix of symbolic integers or expressions.

Version History

Introduced before R2006a

See Also

|