What's a good library for parsing mathematical expressions in java?

I’m an Android Developer and as part of my next app I will need to evaluate a large variety of user created mathematical expressions and equations. I am looking for a good java library that is lightweight and can evaluate mathematical expressions using user defined variables and constants, trig and exponential functions, etc.

I’ve looked around and Jep seems to be popular, but I would like to hear more suggestions, especially from people who have used these libraries before.

  • SharedPreferences application context vs activity context
  • How to adjust text font size to fit textview
  • GoogleSignInResult returns DEVELOPER_ERROR in Android app using Firebase
  • Firebase and Crashlytics - Which one to use?
  • How to get the Dimensions of a Drawable in an ImageView?
  • Supported devices is extremely low
  • Related posts:

    how to get background color from current theme programmatically
    How to send/receive push notifications from ionic mobile app?
    How to let a TextView have multiple lines?
    Android takes more time on application start up during first time launch
    android ArrayAdapter items update
    Mock HttpResponse with Robolectric
  • Autostart Android application after installation complete
  • TranslateAnimation applied to an ImageView leaves trail
  • Firebase DB Update from Background Service
  • SMS Manager for Dual Sim Phones?
  • How to right-align text in an Android TextView or EditText?
  • singletap touch detect in Ontouch method of the view
  • 5 Solutions collect form web for “What's a good library for parsing mathematical expressions in java?”

    JEval is a good alternative. I abandoned Jep due to it becoming commercial. The only concern is that JEval seems to be a little dormant at the moment (last release in 2008).

    I wrote a simple but capable Math Expression Evaluator a while back, which is free and open-source. It’s main advantage is being fast and tiny – both are a good thing with hand-held devices. If it meets your need you are welcome to use it.

    Primary Features:

    • Basic math operators, with inferred precedence (^ * × · / ÷ % + -).
    • Explicit precedence with parenthesis.
    • Implicit multiplication of bracketed subexpressions.
    • Correct right-associativity of exponentials (power operator).
    • Direct support for hexadecimal numbers prefixed by 0x.
    • Constants and variables.
    • Extensible operators.
    • Extensible functions.
    • 20 KiB footprint.

    Example

    MathEval math=new MathEval();
    
    math.setVariable("Top",    5);
    math.setVariable("Left",  20);
    math.setVariable("Bottom",15);
    math.setVariable("Right", 60);
    
    System.out.println("Middle: "+math.evaluate("floor((Right+1-Left)/2)"));
    

    Try https://code.google.com/p/expressionoasis/. It is an extensible Expression Evaluation framework and will meet such requirements.

    This doesn’t exactly fit my initial conditions, but I found a wonderful parser written in C++. I’m trying to figure out Android’s Native code support to see if I can use it. It’s exactly what I need.

    Here’s the documentation for the project.
    http://www.codeproject.com/KB/recipes/MathieuMathParser.aspx

    There is a new commercial tool called formula4j, which may be of interest to some.

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.