Up

 

You can easily start using the package.

  1. To read Expressions use:

 

package myTestPackage;

 

import hussam.math.operations.parser.*;

import hussam.math.operations.dataBase.*;

import hussam.math.operations.*;

 

public class TestPackage{

        public static void main(String[]args)throws MathException{

                OperationReader reader = ExpressionReader.getInstance();

                Operation o1=reader.readOperation("x*2+8/Cos(x)");

                //Print the result

                System.out.println(o1.result());

               

                //change the value of (x)

                Variable x = reader.getOperatorSource().getLocalVariable("x");

                x.setOperation(new ConstantNumber(3));

                System.out.println(o1.result());

               

               

        }

}

Notes:

  1. Expressions are parsed once, the same compiled Tree of operations is evaluated many times as needed!

  2. An ExpressionReader can read many expressions, these expressions share the same variables and dynamic functions.

  3. If you need to create a different scope of variables, you should just use another ExpressionReader using ExpressionReader.getInstance().

--------------------

 

2- To add new Functions:

 Create your new functions by extending the Function class and overriding the result() method and the optimize method if necessary.

 

This page will be updated in the future.

Check this example in the documentation.