Introduction to the mathematical expression parser

Source: Internet
Author: User
Tags define function mathematical functions

In actual project development, if you need to parse the mathematical formula and do not need to use the interpreter mode for design, you can directly use some third-party parsing toolkit, which can be collectively referred toMath expression parser (MEP), Such as expression4j, Jep, jbcparser, symja, math
Expression string Parser (MESP) and so on replace the interpreter mode, which can easily explain some more complex grammar, powerful functions, simple use, and better efficiency.

The following describes two commonly used third-party parsing toolkit based on the Java language:

(1) expression4j

Expression4j is an open-source Java-based framework used to operate mathematical expressions. It is a mathematical formula parser. In expression4j, mathematical expressions can be stored in string objects, for example, "F (x, B) = 2 * X-cos (B)" and "g (x, y) = f (y, x) *-2. Expression4j is highly customized. Users can customize the literal method. Its main functions include basic mathematical operations of real numbers and plural numbers, and support basic mathematical functions (such as sin and COS), complex functions (such as f (x) = 2 * x + 5, g (x) = 3 * f (x + 2)-x) you can also define function directories (function sets) and support xml configuration files. It is not yet a very mature framework and is still being improved. For more information about expression4j, visit: http://expression4j.sourceforge.net /.

(2) Jep

Jep (javamathematical expression parser) is a Java class library used to parse and solve mathematical expressions. Using the pack provided by Jep, We can enter any mathematical formula represented by a string and then solve it immediately. Jep supports User-Defined variables, constants, and udfs. It also contains a large number of common mathematical functions and constants. For more information about Jep, visit the website: http://www.singularsys.com/jep /.

 

[Author: Liu Wei http://blog.csdn.net/lovelion]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.