numden

Extract numerator and denominator

Description

example

[N,D] = numden(A) converts A to a rational form where the numerator and denominator are relatively prime polynomials with integer coefficients. The function returns the numerator and denominator of the rational form of an expression.

If A is a symbolic or a numeric matrix, then N is the symbolic matrix of numerators, and D is the symbolic matrix of denominators. Both N and D are matrices of the same size as A.

Examples

Numerators and Denominators of Symbolic Numbers

Find the numerator and denominator of a symbolic number.

[n, d] = numden(sym(4/5))
n =
4

d =
5

Numerators and Denominators of Symbolic Expressions

Find the numerator and denominator of the symbolic expression.

syms x y
[n,d] = numden(x/y + y/x)
n =
x^2 + y^2

d =
x*y

Numerators and Denominators of Matrix Elements

Find the numerator and denominator of each element of a symbolic matrix.

syms a b
[n,d] = numden([a/b, 1/b; 1/a, 1/(a*b)])
n =
[ a, 1]
[ 1, 1]

d =
[ b,   b]
[ a, a*b]

Input Arguments

collapse all

Input, specified as a symbolic number, expression, function, vector, or matrix.

Output Arguments

collapse all

Numerator, returned as a symbolic number, expression, function, vector, or matrix.

Denominator, returned as a symbolic number, expression, function, vector, or matrix.