- JavaDoc

# JEP

- Basic Usage
- Variables
- Data types
- Operators
- Functions
- Advanced Features
- Grammar
- FAQ
- Version History

# Extensions

- Overview
- XJep
- Differentiation
- Vectors and Matrices
- Groups
- Version History

# Frequently Asked Questions

Q: I've noticed that JEP does not give accurate results for certain expressions. Why is this? What can I do about it?

> A: You will notice that when you evaluate something as simple as "8 - 7.9" the result will be 0.09999999999999964 rather than 0.1. These inaccuracies are the result of floating point arithmetic. Internally JEP uses the `double` type to represent numbers by default. Unfortunately, even for trivial calculations such as "8 - 7.9" the calculation can not be performed accurately.

> You will notice the same if you run

>       double a=8, b=7.9;
>       System.out.println("a-b = " + (a-b));

> in a Java program.

> Although floating point numbers are accurate enough for many applications, these types of errors should not be ignored in applications where accuracy is critical.

> The DJEP library provides tools to perform accurate calculations using more sophisiticated number types. DJEP includes GroupJep which is intended for exact arithmetic on groups. See the Groups documentation for details. It utilizes the BigInteger and BigDecimal classes to represent numbers rather than the double type.

Q: I don't need all the functions supplied by JEP. Is there a way to not load some of them, or completely remove some from the package?

> A: Stripping down JEP into a lean mean arithmetic machine!

> Option 1:
> In some cases you will not require all the built in functions supported by JEP. The easiest way to accomplish this is simply not calling the addStandardFunctions() method before parsing. Then, you can call addFunction() for any specific functions you may require.

> Option 2:
> If you think it is necessary to minimize the size of JEP to a minimum, you can remove all function classes other than the operators (if you don't need them). This will leave you with a parser that can still do basic arithmetic, but not the fancy functions like sin() and cos(). It saves you about 17KB of classes (15% of JEP in total).

> Instructions:
> - The function classes are all located in the org.nfunk.jep.function package. Operators (+, -, *, /,…) are also implemented as functions. These should NOT be removed if you still want JEP to work properly. The following function classes are used to implement operators:

> > Add | Modulus | Subtract
> > Comparative | Multiply | UMinus
> > Divide | Not |
> > Logical | Power |

> - Open the source code for JEP and look for the addStandardFunctions() method. It contains a list of almost all non-operator functions. For every function class you remove from the function directory, you must also remove the associated line from this method.
> - Recompile JEP, and you should have a lean mean arithmetic machine!