Up | Next | Prev | PrevTail | Tail |

REDUCE allows for a variety of numerical domains for the numerical coefficients of polynomials used in calculations. The default mode is integer arithmetic, although the possibility of using real coefficients has been discussed elsewhere. Rational coefficients have also been available by using integer coefficients in both the numerator and denominator of an expression, using the ON DIV option to print the coefficients as rationals. However, REDUCE includes several other coefficient options in its basic version which we shall describe in this section. All such coefficient modes are supported in a table-driven manner so that it is straightforward to extend the range of possibilities. A description of how to do this is given in R.J. Bradford, A.C. Hearn, J.A. Padget and E. Schrüfer, “Enlarging the REDUCE Domain of Computation,” Proc. of SYMSAC ’86, ACM, New York (1986), 100–106.

Instead of treating rational numbers as the numerator and denominator of a rational expression, it is also possible to use them as polynomial coefficients directly. This is accomplished by turning on the switch RATIONAL.

Example: With RATIONAL off, the input expression a/2 would be converted into a rational expression, whose numerator was A and denominator 2. With RATIONAL on, the same input would become a rational expression with numerator 1/2*A and denominator 1. Thus the latter can be used in operations that require polynomial input whereas the former could not.

The switch ROUNDED permits the use of arbitrary sized real coefficients in polynomial expressions. The actual precision of these coefficients can be set by the operator PRECISION. For example, precision 50; sets the precision to fifty decimal digits. The default precision is system dependent and can be found by precision 0;. In this mode, denominators are automatically made monic, and an appropriate adjustment is made to the numerator.

Example: With ROUNDED on, the input expression a/2 would be converted into a rational expression whose numerator is 0.5*A and denominator 1.

Internally, REDUCE uses floating point numbers up to the precision supported by the underlying machine hardware, and so-called bigfloats for higher precision or whenever necessary to represent numbers whose value cannot be represented in floating point. The internal precision is two decimal digits greater than the external precision to guard against roundoff inaccuracies. Bigfloats represent the fraction and exponent parts of a floating-point number by means of (arbitrary precision) integers, which is a more precise representation in many cases than the machine floating point arithmetic, but not as efficient. If a case arises where use of the machine arithmetic leads to problems, a user can force REDUCE to use the bigfloat representation at all precisions by turning on the switch ROUNDBF. In rare cases, this switch is turned on by the system, and the user informed by the message

ROUNDBF turned on to increase accuracy

Rounded numbers are normally printed to the specified precision. However, if the user wishes to print such numbers with less precision, the printing precision can be set by the command PRINT_PRECISION. For example, print_precision 5; will cause such numbers to be printed with five digits maximum.

Under normal circumstances when ROUNDED is on, REDUCE converts the number 1.0 to the integer 1. If this is not desired, the switch NOCONVERT can be turned on.

Numbers that are stored internally as bigfloats are normally printed with a space between every five digits to improve readability. If this feature is not required, it can be suppressed by turning off the switch BFSPACE.

Further information on the bigfloat arithmetic may be found in T. Sasaki, “Manual for Arbitrary Precision Real Arithmetic System in REDUCE”, Department of Computer Science, University of Utah, Technical Note No. TR-8 (1979).

When a real number is input, it is normally truncated to the precision in effect at the time the number is read. If it is desired to keep the full precision of all numbers input, the switch ADJPREC (for adjust precision) can be turned on. While on, ADJPREC will automatically increase the precision, when necessary, to match that of any integer or real input, and a message printed to inform the user of the precision increase.

When ROUNDED is on, rational numbers are normally converted to rounded representation. However, if a user wishes to keep such numbers in a rational form until used in an operation that returns a real number, the switch ROUNDALL can be turned off. This switch is normally on.

Results from rounded calculations are returned in rounded form with two exceptions: if the result is recognized as 0 or 1 to the current precision, the integer result is returned.

REDUCE includes facilities for manipulating polynomials whose coefficients are computed modulo a given base. To use this option, two commands must be used; SETMOD ⟨integer⟩, to set the prime modulus, and ON MODULAR to cause the actual modular calculations to occur. For example, with setmod 3; and on modular;, the polynomial (a+2*b)^3 would become A^3+2*B^3.

The argument of SETMOD is evaluated algebraically, except that non-modular (integer) arithmetic is used. Thus the sequence

setmod 3; on modular; setmod 7;

will correctly set the modulus to 7.

Modular numbers are by default represented by integers in the interval [0,p-1] where p is the current modulus. Sometimes it is more convenient to use an equivalent symmetric representation in the interval [-p/2+1,p/2], or more precisely [-floor((p-1)/2), ceiling((p-1)/2)], especially if the modular numbers map objects that include negative quantities. The switch BALANCED_MOD allows you to select the symmetric representation for output.

Users should note that the modular calculations are on the polynomial coefficients only.
It is not currently possible to reduce the exponents since no check for a prime modulus is
made (which would allow x^{p-1} to be reduced to 1 mod p). Note also that any division by
a number not co-prime with the modulus will result in the error “Invalid modular
division”.

Although REDUCE routinely treats the square of the variable i as equivalent to -1, this is not sufficient to reduce expressions involving i to lowest terms, or to factor such expressions over the complex numbers. For example, in the default case,

factorize(a^2+1);

gives the result

{{A**2+1,1}}

and

(a^2+b^2)/(a+i*b)

is not reduced further. However, if the switch COMPLEX is turned on, full complex arithmetic is then carried out. In other words, the above factorization will give the result

{{A + I,1},{A - I,1}}

and the quotient will be reduced to A-I*B.

The switch COMPLEX may be combined with ROUNDED to give complex real numbers; the appropriate arithmetic is performed in this case.

Complex conjugation is used to remove complex numbers from denominators of expressions. To do this if COMPLEX is off, you must turn the switch RATIONALIZE on.

Up | Next | Prev | PrevTail | Front |