# The computable-reals Reference Manual

Next: , Previous: , Up: (dir)   [Contents][Index]

# The computable-reals Reference Manual

This is the computable-reals Reference Manual, version 1.0.1, generated automatically by Declt version 2.4 "Will Decker" on Wed Jun 20 11:38:21 2018 GMT+0.

Next: , Previous: , Up: Top   [Contents][Index]

# Computable Reals

## Introduction

Computable real numbers `x` are interpreted as (potentially) infinite fractions in base 2 that are specified through a rule for computation of an integer `a` with `|(2^k)*x - a| <= 1` for any `k>=0`.

The internal data structure should not be accessed.

The interface for the outside world is as follows:

The type `CREAL` is a supertype of the type `RATIONAL`. `(CREAL-P x)`, for an object `x`, returns `T` if `x` is of type `CREAL`, otherwise `NIL`.

`(APPROX-R x k)`, for a `CREAL` `x` and an integer `k>=0`, returns an integer `a` with `|(2^k)*x - a| < 1`.

`(MAKE-REAL fun)` returns the real number given by `fun`. Here `fun` is a function taking an argument `k`, that computes `a` as above.

`CREAL`s are output by print etc. as a decimal fraction. The error hereby is at most one unit in the last digit that was output. The number of decimal digits after the decimal point is defined through the dynamic variable `*PRINT-PREC*`.

For comparison operations etc. a precision threshold is used. It is defined through the dynamic variable `*CREAL-TOLERANCE*`. Its value should be a nonnegative integer `n`, meaning that numbers are considered equal if they differ by at most `2^(-n)`.

## Exported Functions and Constants

The following functions, constants and variables are exported. (The package is named `"REALS"`.)

``````CREAL                  type        type of the computable real numbers
CREAL-P object         function    tests for type CREAL
*PRINT-PREC*           variable    specifies precision of output
*CREAL-TOLERANCE*      variable    precision threshold for comparison
APPROX-R x:creal k:int>=0
function    returns approximation of x to k digits
MAKE-REAL function     function    creates object of type CREAL
RAW-APPROX-R x:creal   function    returns 3 values a,n,s with:
if a = 0: |x| <= 2^(-n), s = 0
and n >= *CREAL-TOLERANCE*
else: a0 integer > 4, n0 integer >=0,
s = +1 or -1, and sign(x) = s,
(a-1)*2^(-n) <= |x| <= (a+1)*2^(-n)
PRINT-R x:creal k:int>=0 &optional (flag t)
function    outputs x with k decimal digits.
If flag is true, first a newline.
+R {creal}*            function    computes the sum of the arguments
-R creal {creal}*      function    computes negative or difference
*R {creal}*            function    computes the product of the arguments
/R creal {creal}*      function    computes reciprocal or quotient
SQRT-R creal           function    computes the square root
+LOG2-R+               constant    log(2)
+PI-R+                 constant    pi
+2PI-R+                constant    2*pi
+PI/2-R+               constant    pi/2
+PI/4-R+               constant    pi/4
LOG-R x:creal &optional b:creal
function    computes the logarithm of n in base b;
default is the natural logarithm
EXP-R creal            function    computes the exponential function
EXPT-R x:creal y:creal function    computes x^y
SIN-R creal            function    computes the sine
COS-R creal            function    computes the cosine
TAN-R creal            function    computes the tangent
ATAN-R x:creal &optional y:creal
function    computes the arctangent of x or
the phase angle of (x,y)
ASH-R x:creal n:int    function    computes x * 2^n
ROUND-R x:creal &optional y:creal
function    computes two values q (integer) and r
(creal) with x = q*y + r and |r|<=|y|/2
according to the precision specified by
*CREAL-TOLERANCE*
FLOOR-R x:creal &optional y:creal
function    like ROUND-R, corresponding to floor
CEILING-R x:creal &optional y:creal
function    like ROUND-R, corresponding to ceiling
TRUNCATE-R x:creal &optional y:creal
function    like ROUND-R, corresponding to truncate
``````

Next: , Previous: , Up: Top   [Contents][Index]

## 2 Systems

The main system appears first, followed by any subsystem dependency.

Previous: , Up: Systems   [Contents][Index]

### 2.1 computable-reals

Maintainer

Robert Smith <robert@stylewarning.com>

Author

Michael Stoll

Description

Computable real numbers.

Long Description

Arbitrary-precision, re-computing real-numbers.

Version

1.0.1

Source

computable-reals.asd (file)

Components

Next: , Previous: , Up: Top   [Contents][Index]

## 3 Files

Files are sorted by type and then listed depth-first from the systems components trees.

Previous: , Up: Files   [Contents][Index]

### 3.1 Lisp

Next: , Previous: , Up: Lisp files   [Contents][Index]

#### 3.1.1 computable-reals.asd

Location

computable-reals.asd

Systems

computable-reals (system)

Next: , Previous: , Up: Lisp files   [Contents][Index]

#### 3.1.2 computable-reals/package.lisp

Parent

computable-reals (system)

Location

package.lisp

Packages

#### 3.1.3 computable-reals/constants.lisp

Dependency

package.lisp (file)

Parent

computable-reals (system)

Location

constants.lisp

Exported Definitions

#### 3.1.4 computable-reals/reals.lisp

Dependency

constants.lisp (file)

Parent

computable-reals (system)

Location

reals.lisp

Exported Definitions
Internal Definitions

Previous: , Up: Lisp files   [Contents][Index]

#### 3.1.5 computable-reals/get-approximations.lisp

Dependency

reals.lisp (file)

Parent

computable-reals (system)

Location

get-approximations.lisp

Next: , Previous: , Up: Top   [Contents][Index]

## 4 Packages

Packages are listed by definition order.

Previous: , Up: Packages   [Contents][Index]

### 4.1 computable-reals

Source

package.lisp (file)

Nickname

cr

Use List

common-lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

## 5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.

Next: , Previous: , Up: Definitions   [Contents][Index]

### 5.1 Exported definitions

Next: , Previous: , Up: Exported definitions   [Contents][Index]

#### 5.1.1 Special variables

Special Variable: *creal-tolerance*

precision threshold for the comparison of CREALs, denoting the number of binary digits after the decimal point

Package
Source

reals.lisp (file)

Special Variable: *print-prec*

number of decimal digits after the decimal point during output of CREALs

Package
Source

reals.lisp (file)

Special Variable: +2pi-r+

2*pi as CREAL

Package
Source

constants.lisp (file)

Special Variable: +log2-r+

log(2) as CREAL

Package
Source

constants.lisp (file)

Special Variable: +pi-r+

pi as CREAL

Package
Source

constants.lisp (file)

Special Variable: +pi/2-r+

pi/2 as CREAL

Package
Source

constants.lisp (file)

Special Variable: +pi/4-r+

pi/4 as CREAL

Package
Source

constants.lisp (file)

Next: , Previous: , Up: Exported definitions   [Contents][Index]

#### 5.1.2 Functions

Function: *r &rest ARGS &aux PN RL

Multiplication for CREALs

Package
Source

reals.lisp (file)

Function: +r &rest ARGS &aux SN RL

Package
Source

reals.lisp (file)

Function: -r X1 &rest ARGS

subtraction and negation of CREALs

Package
Source

reals.lisp (file)

Function: /r X1 &rest ARGS

division for CREALs

Package
Source

reals.lisp (file)

Function: approx-r X K

Computes approximations for CREALs

Package
Source

reals.lisp (file)

Function: ash-r X N

shift function for CREALs

Package
Source

reals.lisp (file)

Function: atan-r X &optional Y

arctangent for CREALs

Package
Source

reals.lisp (file)

Function: ceiling-r X &optional Y L

ceiling for CREALs

Package
Source

reals.lisp (file)

Function: cos-r X

cosine for CREALs

Package
Source

reals.lisp (file)

Function: creal-p X

Is X a CREAL?

Package
Source

reals.lisp (file)

Function: exp-r X

exponential function for CREALs

Package
Source

reals.lisp (file)

Function: expt-r X Y &aux S

exponentiation function for CREALs

Package
Source

reals.lisp (file)

Function: floor-r X &optional Y L

floor for CREALs

Package
Source

reals.lisp (file)

Function: log-r X &optional B

logarithm for CREALs

Package
Source

reals.lisp (file)

Function: make-real COMP

Create a C-REAL from a computation function COMP.

Package
Source

reals.lisp (file)

Function: print-r X K &optional FLAG STREAM

output function for CREALs

Package
Source

reals.lisp (file)

Function: raw-approx-r X

Returns an approximation for CREALs

Package
Source

reals.lisp (file)

Function: round-r X &optional Y L

round for CREALs

Package
Source

reals.lisp (file)

Function: sin-r X

sine for CREALs

Package
Source

reals.lisp (file)

Function: sqrt-r X

square root for CREALs

Package
Source

reals.lisp (file)

Function: tan-r X

tangent for CREALs

Package
Source

reals.lisp (file)

Function: truncate-r X &optional Y L

truncate for CREALs

Package
Source

reals.lisp (file)

Previous: , Up: Exported definitions   [Contents][Index]

#### 5.1.3 Types

Type: creal ()

The type of the computable real numbers.

Package
Source

reals.lisp (file)

Previous: , Up: Definitions   [Contents][Index]

### 5.2 Internal definitions

Next: , Previous: , Up: Internal definitions   [Contents][Index]

#### 5.2.1 Functions

Function: atan-r0 X
Package
Source

reals.lisp (file)

Function: atan-r1 X
Package
Source

reals.lisp (file)

Function: c-real-compute INSTANCE
Package
Source

reals.lisp (file)

Function: c-real-p OBJECT
Package
Source

reals.lisp (file)

Function: c-real-precision INSTANCE
Function: (setf c-real-precision) VALUE INSTANCE
Package
Source

reals.lisp (file)

Function: c-real-value INSTANCE
Function: (setf c-real-value) VALUE INSTANCE
Package
Source

reals.lisp (file)

Function: cos-r1 X
Package
Source

reals.lisp (file)

Function: creal-print X K FLAG STREAM
Package
Source

reals.lisp (file)

Function: divide-r NAME WHAT X Y L
Package
Source

reals.lisp (file)

Function: exp-r1 X
Package
Source

reals.lisp (file)

Function: expt-r1 X Y
Package
Source

reals.lisp (file)

Function: get-approx X K
Package
Source

reals.lisp (file)

Function: invert-r X
Package
Source

reals.lisp (file)

Function: log-r1 X
Package
Source

reals.lisp (file)

Function: log-r2 X
Package
Source

reals.lisp (file)

Function: make-c-real &key (VALUE VALUE) (PRECISION PRECISION) (COMPUTE COMPUTE)
Package
Source

reals.lisp (file)

Function: minus-r X
Package
Source

reals.lisp (file)

Function: print-c-real X STREAM D
Package
Source

reals.lisp (file)

Function: rational-sqrt X
Package
Source

reals.lisp (file)

Function: raw-approx-cr X
Package
Source

reals.lisp (file)

Function: rest-help-r X Y Q
Package
Source

reals.lisp (file)

Function: round-cr A K
Package
Source

reals.lisp (file)

Function: sin-r1 X
Package
Source

reals.lisp (file)

Function: tenpower K
Package
Source

reals.lisp (file)

Function: transf X
Package
Source

reals.lisp (file)

Previous: , Up: Internal definitions   [Contents][Index]

#### 5.2.2 Structures

Structure: c-real ()
Package
Source

reals.lisp (file)

Direct superclasses

structure-object (structure)

Direct methods

print-object (method)

Direct slots
Slot: value
Type

integer

Initform

0

c-real-value (function)

Writers

(setf c-real-value) (function)

Slot: precision
Type

(integer -1 *)

Initform

-1

c-real-precision (function)

Writers

(setf c-real-precision) (function)

Slot: compute
Type

(function ((integer 0 *)) integer)

c-real-compute (function)

Writers

(setf c-real-compute) (function)

Previous: , Up: Top   [Contents][Index]

## Appendix A Indexes

Next: , Previous: , Up: Indexes   [Contents][Index]

### A.1 Concepts

Next: , Previous: , Up: Indexes   [Contents][Index]

### A.2 Functions

Jump to: (   *   +   -   /   A   C   D   E   F   G   I   L   M   P   R   S   T
Jump to: (   *   +   -   /   A   C   D   E   F   G   I   L   M   P   R   S   T

Next: , Previous: , Up: Indexes   [Contents][Index]