# Arbitary Field Console

This console can perform calculations using various different fields including integers, fractions, decimals with a specific number of decimal places. Use

• `setfield integer` for normal integers
• `setfield bigint` for integers with unlimited size
• `setfield rational` for fractions (rational numbers)
• `setfield double` for standard floating point numbers
• `setfield bigdec` for decimals with a specified number of decimal places
• `setprec 30` to set 30 significant figures
• `setfield complex` for complex numbers

Note that changing the field resets all variables. The JavaScript versions may not always give the same results as the Java version as JavaScript has different ways of representing numbers.

## Examples

The `factorial(x)` function can be used to test the range of the various types. In a webbrowser with the javascript version:

Integer factorials upto 21 can be calculated:
```> setfield integer
Setting field INTEGER
> factorial(10)
3628800
> factorial(20)
2432902008176640000
> factorial(21)
51090942171709440000
> factorial(22)
1.1240007277776077e+21
```
Doubles work the same
```> setfield double
Setting field DOUBLE
> factorial(21)
51090942171709440000
> factorial(22)
1.1240007277776077e+21
```
BigIntegers allow much larger values
```> setfield bigint
Setting field BIGINT
> factorial(20)
2432902008176640000
> factorial(30)
265252859812191058636308480000000
> factorial(40)
815915283247897734345611269596115894272000000000
> factorial(50)
30414093201713378043612608166064768844377641568960512000000000000
```

Calculations with fractions

```Setting field RATIONAL
> 1/6+1/2
2/3
> 1/6*2/5
1/15
```

## Jep Extensions

The arbitaty fields are part of Jep Extensions a set of add-ons for the Jep mathematical expression parser. They include

 Structured programming Allows block style programming, such as `for`, `while` and `do` loops, as well as java-style if-else blocks. Fast Evaluation Allows very fast evaluation for double precision, typically 4-5 times faster. This is used by the Implicit plotter applet. It can evaluating `(x^2+y^2)^3-4 x^2 y^2` for 250K points in 0.064 seconds, i.e. 220 nano-seconds per evaluation. Mathml Conversion to/from presentation MathML Simplification removes redundant parts of expression like adding zero or multiplying by 1. Polynomial Conversion to polynomials. Can be used to compare two polynomials. Matrices Allows vectors and matrices to be used. Includes a range of vector and matrix functions like determinant and dot product. Statistical A range of statistical functions Differentiation Symbolic differentiation of expressions Fields Allow calculations over specific fields such as the rationals.