Exp4j

exp4j is a small Java library for evaluation of mathematical expressions. 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.

exp4j
Stable release
0.4.3 / 2014-10-10
Written inJava
TypeMath
LicenseApache License 2.0
Websitewww.objecthunter.net/exp4j/

Features

  • 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

exp4j is released under the terms of the Apache License 2.0

Examples of usage

Calculating the result of 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();
gollark: I don't think you've understood quite how extremely terrible it would be if that was the case.
gollark: You probably should, as bad viruses are in fact bad.
gollark: Markets seem to be the best way around to allocate most resources right now, as long as they're managed reasonably. The alternatives people have seem to generally involve either centrally planning stuff, which is maybe computationally hard and has bad incentives, having some communal system and hoping people get along, which doesn't scale, or voting on things, which has the central planning issues plus exciting new ones.
gollark: I see.
gollark: Something involving lots of effort doesn't make it good. Human culture has a weird thing with effort and hard work being intrinsically good and not just good as a way to achieve other things.

See also

References

    This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.