Quotient and remainder
collapse all in page
Syntax
[Q,R] =quorem(A,B,var)
[Q,R] =quorem(A,B)
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
.
[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
.
Examples
Divide Multivariate Polynomials
Compute the quotient and remainder of the division of these multivariate polynomials with respect to the variable y
:
syms x yp1 = 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 xp = x^3 - 2*x + 5;[q, r] = quorem(x^5, p)
q =x^2 + 2r =- 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
A
— Dividend (numerator)
symbolic integer | polynomial | symbolic vector | symbolic matrix
Dividend (numerator), specified as a symbolic integer, polynomial, or a vector or matrix of symbolic integers or polynomials.
B
— Divisor (denominator)
symbolic integer | polynomial | symbolic vector | symbolic matrix
Divisor (denominator), specified as a symbolic integer, polynomial, or a vector or matrix of symbolic integers or polynomials.
var
— Polynomial variable
symbolic variable
Polynomial variable, specified as a symbolic variable.
Output Arguments
collapse all
Q
— Quotient of the division
symbolic integer | symbolic expression | symbolic vector | symbolic matrix
Quotient of the division, returned as a symbolic integer, expression, or a vector or matrix of symbolic integers or expressions.
R
— Remainder of the division
symbolic integer | symbolic expression | symbolic vector | symbolic matrix
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
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Contact your local office