Something or other, whatever!

Christian Lawson-Perfect's homepage

Constructive real numbers extension for Numbas

Constructive real numbers

This extension adds a creal data type, representing a constructive real number.

Constructive real numbers are guaranteed to be correct to any chosen precision. Digits of a calculated value are computed on demand, so you don't have to choose a level of precision in advance.

The following operations and functions are defined on creal values:

``` + - * / ^ < <=

=

sign dpformat max min abs exp cos sin acos asin ln sqrt ```

You can create creal values with the creal function, e.g. creal(2). You can give a string containing an expression in terms of number literals, pi, e, and any of the functions defined on creals. For example, creal("sqrt(2) + ln(3)^pi").

The function string(x) will render the value x to 10 decimal places. Use dpformat(x, precision) to render creal values to different levels of precision.

The function round(x) will return the closest integer to the value x.

This extension provides a JME notation called "creal" which is equivalent to the standard notation except for interpreting number literals as creal values instead of number or integer values.

This extension uses the library CReal.js, ported to JavaScript by Christian Lawson-Perfect from Hans-J. Boehm's original Java code.