Previous Page Next Page Contents

/ -- divide expressions

Introduction

x/y computes the quotient of x and y.

Call(s)


x/y _divide(x, y)

Parameters

x, y, ... - arithmetical expressions, polynomials of type DOM_POLY, or sets

Returns

an arithmetical expression, a polynomial, or a set.

Overloadable:

x, y

Related Functions

_invert, _negate, ^, *, +, -, div, divide, pdivide, poly

Details

Example 1

The quotient of numbers is simplified to a number:

>> 1234/234, 7.5/7, 6*I/2
                         617/117, 1.071428571, 3 I

Internally, a symbolic quotient x/y is represented as the product x * y^(-1):

>> type(x/y), op(x/y, 0), op(x/y, 1), op(x/y, 2)
                                              1
                           "_mult", _mult, x, -
                                              y
>> op(op(x/y, 2), 0), op(op(x/y, 2), 1), op(op(x/y, 2), 2)
                               _power, y, -1

Example 2

For finite sets X, Y, the quotient X/Y is the set {x/y; x in X; y in Y}:

>> {a, b, c} / {2, 3}
                           { a  a  b  b  c  c }
                           { -, -, -, -, -, - }
                           { 2  3  2  3  2  3 }

Example 3

Polynomials of type DOM_POLY can be divided by / if they have the same indeterminates, the same coefficient ring, and if exact division is possible:

>> poly(x^2 - 1, [x]) / poly(x - 1, [x])
                             poly(x + 1, [x])
>> poly(x^2 - 1, [x]) / poly(x - 2, [x])
                                   FAIL

The function divide provides division with a remainder:

>> divide(poly(x^2 - 1, [x]), poly(x - 2, [x]))
                      poly(x + 2, [x]), poly(3, [x])

The polynomials must have the same indeterminates and the same coefficient ring:

>> poly(x^2 - 1, [x, y]) / poly(x - 1, [x])
      Error: Illegal argument [divide]

Example 4

Various library domains such as matrix domains overload _divide. The matrix domain defines x/y as x * (1/y), where 1/y is the inverse of y:

>> x := Dom::Matrix(Dom::Integer)([[1, 2], [3, 4]]):
   y := Dom::Matrix(Dom::Rational)([[10, 11], [12, 13]]):
   x/y
                             +-            -+
                             |  11/2, -9/2  |
                             |              |
                             |   9/2, -7/2  |
                             +-            -+

The inverse of x has rational entries. Therefore, 1/x returns FAIL, because the component ring of x is Dom::Integer. Consequently, also y/x returns FAIL:

>> y/x
                                   FAIL
>> delete x, y:

Example 5

This example demonstrates the behavior of _divide on user-defined domains. In the first case below, the user-defined domain does not have a "_divide" slot. Thus x/y is transformed to x * (1/y):

>> Do := newDomain("Do"): x := new(Do, 1): y := new(Do, 2):
   x/y; op(x/y, 0..2)
                                new(Do, 1)
                                ----------
                                new(Do, 2)
      
                                              1
                       _mult, new(Do, 1), ----------
                                          new(Do, 2)

After the slot "_divide" is defined in the domain Do, this method is used to divide elements:

>> Do::_divide := proc() begin "The Result" end: x/y
                               "The Result"
>> delete Do, x, y:

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000