Exp4j

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
exp4j
Stable release
0.4.3 / 2014-10-10
Repository
  • {{URL|example.com|optional display text}}Lua error in Module:EditAtWikidata at line 29: attempt to index field 'wikibase' (a nil value).
Written inJava
Engine
    Lua error in Module:EditAtWikidata at line 29: attempt to index field 'wikibase' (a nil value).
    TypeMath
    LicenseApache License 2.0
    Websitewww.objecthunter.net/exp4j/

    exp4j is a small Java library for evaluation of mathematical expressions.[1] It implements Dijkstra's Shunting-yard algorithm to translate expressions from infix notation to Reverse Polish notation and calculates the result using a simple Stack algorithm.

    Features

    [edit | edit source]
    • Variables can be used in expressions
    • exp4j comes with a set of common built-in functions
    • Users can create and use their own custom operators
    • Users can create and use their own custom functions

    License terms

    [edit | edit source]

    exp4j is released under the terms of the Apache License 2.0

    Examples of usage

    [edit | edit source]

    Calculating the result of 3*sin(π)2e can be done in the following way:

    Expression e = new ExpressionBuilder("3 * (sin(pi) - 2 )/ e")
            .variables("pi", "e")
            .build()
            .setVariable("pi", Math.PI)
            .setVariable("e", Math.E);
    double result = e.evaluate();
    

    See also

    [edit | edit source]
    • mXparser - Mathematical Expressions Parser / Evaluator

    References

    [edit | edit source]
    1. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).