Dom::Rational

Field of rational numbers

MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

Syntax

Dom::Rational(x)

Description

Dom::Rational is the domain of rational numbers represented by elements of the domains DOM_INT or DOM_RAT. Dom::Rational represents the field of rational numbers.

Elements of Dom::Rational are usually not created explicitly. However, if one creates elements using the usual syntax, it is checked whether the input is of type DOM_INT or DOM_RAT. This means Dom::Rational is a façade domain which creates elements of domain type DOM_INT or DOM_RAT.

Viewed as a differential ring Dom::Rational is trivial, it contains constants only.

Dom::Rational has the domain Dom::Numerical as its super domain, i.e., it inherits each method which is defined by Dom::Numerical and not re-implemented by Dom::Rational. Methods described below are re-implemented by Dom::Rational.

Superdomain

Dom::Numerical

Examples

Example 1

Creating some rational numbers using Dom::Rational. This example also shows that Dom::Rational is a façade domain.

Dom::Rational(2/3) ; domtype(%)

Dom::Rational(2.0)
Error: Invalid arguments. [Dom::Rational::new]

Example 2

By tracing the method Dom::Rational::testtypeDom we can see the interaction between testtype and Dom::Rational::testtypeDom.

prog::trace(Dom::Rational::testtypeDom):
delete x:
testtype(x, Dom::Rational);
testtype(3/4, Dom::Rational);
prog::untrace(Dom::Rational::testtypeDom):
enter Dom::Rational::testtypeDom(x, Dom::Rational)
computed FAIL


enter Dom::Rational::testtypeDom(3/4, Dom::Rational)
computed TRUE

Parameters

x

An integer or a rational number

Methods

expand all

Mathematical Methods

denom(x)

diff(z, <x, …>)

numer(x)

random()

retract(x)

Conversion Methods

convert(x)

convert_to(x, T)

The following domains are allowed for T: DOM_INT, Dom::Integer, Dom::Rational, DOM_RAT, DOM_FLOAT, Dom::Float and Dom::Numerical.

testtype(x, T)

In general this method is called from the function testtype and not directly by the user. Example 2 demonstrates this behaviour.